我有一个视图作为附件
body: TabBarView(
controller: _tabController,
children: [
TabSreen(index: _tabController.index, eventId: widget.eventEntity.eventId),
TabScreen(index: _tabController.index, eventId: widget.eventEntity.eventId)
]
),
TabScreen是StatefulWiget, 单击TabScreen列表中的每个项目,然后打开SecondScreen
如何使第二个屏幕显示为全屏。我的意思是SecondView应该删除该部分:Event1,Event Name,Status。只是将导航下方的视图显示为全屏
当前,我正在使用以下代码从TabScreen打开SecondScreen(StatefulWiget)
Navigator.push(
context,
MaterialPageRoute(builder: (context) => new SecondScreen(title: _forms[index].name)),
);
答案 0 :(得分:0)
这是一个简单的示例,因为您没有共享足够的代码,因此您可以将其与此进行比较。
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Test',
theme: ThemeData(
brightness: Brightness.dark,
primaryColor: Color(0xFF048ec8),
indicatorColor: Colors.red,
cursorColor: Colors.red,
),
home: MainScreenWithTab(),
);
}
}
class MainScreenWithTab extends StatefulWidget {
@override
State<StatefulWidget> createState() => MainScreenWithTabState();
}
class MainScreenWithTabState extends State<MainScreenWithTab> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text('Screen'),
),
body: Column(
children: <Widget>[
TabBar(
tabs: <Widget>[
Tab(
text: 'Left',
),
Tab(
text: 'Right',
)
],
),
Expanded(
child: TabBarView(children: [
RaisedButton(
child: Text('Tap for new screen'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Screen()));
},
),
FlatButton(
child: Text('Push View 2'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => Screen()));
},
),
]),
),
],
),
),
);
}
}
class Screen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Screen'),
),
body: Container(
width: double.infinity,
height: double.infinity,
color: Colors.yellow,
child: Center(
child: Text('New Screen'),
),
),
);
}
}