flutter - 系统状态下的 Flutter 容器
问题描述
flutter
默认情况下,当我们在系统状态下使用该AppBar
显示时,例如:
appBar: AppBar(
title: Text(
Strings.appName,
style: appBarTextStyle,
),
automaticallyImplyLeading: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.menu),
onPressed: () => Scaffold.of(context).openDrawer(),
),
),
),
现在,在我的应用程序中,我没有AppBar
,我想Container
在这个系统状态下拥有,但我不能这样做
我的实现:
child: Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {},
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: new BottomAppBar(
shape: CircularNotchedRectangle(),
child: Container(
height: 50.0,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 40.0),
child: Row(
...
),
),
),
),
drawer: AppDrawer(),
body: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.indigo,
)
]),
height: 70.0,
child: Row(
children: <Widget>[
Center(child: Text("TOOLBAR", style: defaultAppBarTextStyle)),
],
),
),
Expanded(child: _fragments[_currentIndex]),
],
),
解决方案
使用 SafeArea 避免将项目保留在状态栏上。
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child:
child: Text(
_timeRemaining.toString(),
style: TextStyle(fontSize: 100),
),
),
),
);
}
在这种情况下,您需要使用https://pub.dev/packages/flutter_statusbarcolor手动更改状态栏颜色。
@override
Widget build(BuildContext context) {
FlutterStatusbarcolor.setStatusBarColor(Colors.blue);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
推荐阅读
- sql - Oracle插入中缺少逗号
- sql - 无法从 csv 文件中选择列
- javascript - 模拟 Aws-sdk 中的笑话范围错误:ReferenceError:在初始化之前无法访问“variable_name”
- vb.net - 为 PropertyGrid 更改多个属性中的一个 - .NET -
- python - 我正在使用 python-social-auth 但是当用户退出 Google 时我的应用程序没有退出
- asp.net - 使事件函数等到 UpdatePanel 异步回发在代码隐藏中完成
- r - R中表格中的顶级特征组合
- devops - 如果我从 VS 中的项目中删除一个 cs 文件并从 DevOps 获取最新的,它会返回到项目中吗?
- javascript - 使用 Button 移动数据但只有 True Entries
- kubernetes - 作业无效:“选择器”未自动生成