我是新手,所以如果我的问题不清楚,请不要杀死我。我想使状态栏和底部栏始终可见。现在默认情况下,当我在屏幕上显示时,它们是隐藏的。
如何使它们始终可见或可见?
这是我的代码
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'HomePage.dart';
class business extends StatefulWidget {
@override
_business createState() => new _business();
}
class _business extends State<business> with SingleTickerProviderStateMixin {
TabController controller;
@override
void initState(){
controller = new TabController(length: 3, vsync: this);
// SystemChrome.setEnabledSystemUIOverlays([]);
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
centerTitle: true,
leading: new Icon(
Icons.business,
color: Colors.white,
),
title: new Text(
"مرسال بيزنيس",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
bottom: new TabBar(controller: controller,
tabs: <Widget>[
new Tab(icon: new Icon(Icons.shopping_cart,color: Colors.white),text: "مرسال ستور",),
new Tab(icon: new Icon(Icons.school,color: Colors.white),text: "مرسال أكاديمي"),
new Tab(icon: new Icon(Icons.account_balance,color: Colors.white),text: "مساحات مرسال"),
],),
backgroundColor: Color(0xFF009091),
elevation: 0.0,
),
body: Container(
// margin: EdgeInsets.only(top: 140,left: 25,right: 25),
child: Column(
children: <Widget>[
],
),
),
bottomNavigationBar:
new BottomNavigationBar(items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.home, color: Colors.black45),
title: new Text(
"الرئيسية",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.business, color: Colors.black45),
title: new Text(
"مرسال بيزنيس",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.local_activity, color: Colors.black45),
title: new Text(
"أنشطة مرسال",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.favorite_border, color: Colors.black45),
title: new Text(
"تبرع",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.help, color: Colors.black45),
title: new Text(
"الأسئلة الشائعة",
style: TextStyle(color: Colors.black45),
))
],
onTap: onTabTapped,),
);
}
void onTabTapped(void index)
{
}
}
但我希望它像
答案 0 :(得分:0)
首先导入
import 'package:flutter/services.dart';
然后称呼
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values)
像下面这样在MaterialApp
调用MyApp()
之前行以防止其隐藏:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.green,
),
home: business (),
);
}
}
class business extends StatefulWidget {
@override
_business createState() => new _business();
}
class _business extends State<business> with SingleTickerProviderStateMixin {
TabController controller;
@override
void initState(){
controller = new TabController(length: 3, vsync: this);
// SystemChrome.setEnabledSystemUIOverlays([]);
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
centerTitle: true,
leading: new Icon(
Icons.business,
color: Colors.white,
),
title: new Text(
"مرسال بيزنيس",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
bottom: new TabBar(controller: controller,
tabs: <Widget>[
new Tab(icon: new Icon(Icons.shopping_cart,color: Colors.white),text: "مرسال ستور",),
new Tab(icon: new Icon(Icons.school,color: Colors.white),text: "مرسال أكاديمي"),
new Tab(icon: new Icon(Icons.account_balance,color: Colors.white),text: "مساحات مرسال"),
],),
backgroundColor: Color(0xFF009091),
elevation: 0.0,
),
body: Container(
// margin: EdgeInsets.only(top: 140,left: 25,right: 25),
child: Column(
children: <Widget>[
],
),
),
bottomNavigationBar:
new BottomNavigationBar(items: <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: new Icon(Icons.home, color: Colors.black45),
title: new Text(
"الرئيسية",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.business, color: Colors.black45),
title: new Text(
"مرسال بيزنيس",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.local_activity, color: Colors.black45),
title: new Text(
"أنشطة مرسال",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.favorite_border, color: Colors.black45),
title: new Text(
"تبرع",
style: TextStyle(color: Colors.black45),
)),
new BottomNavigationBarItem(
icon: new Icon(Icons.help, color: Colors.black45),
title: new Text(
"الأسئلة الشائعة",
style: TextStyle(color: Colors.black45),
))
],
onTap: onTabTapped,),
);
}
void onTabTapped(void index)
{
}
}