So if you want to use the DefaultTabController
widget then you must start your widget tree with the DefaultTabController
widget and then add your Scaffold
. After that I used only one Scaffold
and added rest of part with the help of Expanded
widget
Here is output image
class SelectionScreen extends StatefulWidget{
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _selectionScreen();
}
}
class _selectionScreen extends State<SelectionScreen>{
@override
Widget build(BuildContext context) {
// TODO: implement build
return DefaultTabController(
length: 3,
initialIndex: 0,
child: Scaffold(
appBar: AppBar(
title: Text('Launch',),
actions: [IconButton(icon: Icon(Icons.share_outlined), onPressed: () {})],
),
body: Column(
children: [
Image.network("https://i.stack.imgur.com/45Aaj.png", height: 150,),
Container(
height: 70,
child: AppBar(
centerTitle: true,
title: Text("New Titile"),
bottom: TabBar(
tabs: [
Tab(text: 'State',),
Tab(text: 'Mission',),
Tab(text: 'Rocket',)
],
),
),
),
Expanded(
child: TabBarView(
children: [
Text('Tab 1',),
Text('Tab 2'),
Text('Tab 3')
],
),
)
],
),
));
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…