flutter - 如何创造安全区域的条件?
问题描述
我有以下小部件,它带有TabBarView
:
child: Scaffold(
extendBodyBehindAppBar: true,
extendBody: true,
body: Container(
padding: const EdgeInsets.only(top: 20),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/black-bg.png'),
fit: BoxFit.fill,
),
),
child: SafeArea(
child: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
SlotScreen(),
MapScreen(),
DeviceScreen(),
],
),
),
),
appBar: AppBar(
title: homeViewModel.slotsSize == 0
? Container()
: Row(
children: [
Container(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: normal12TextGold(
tr('slot_1'),
color: Colors.white,
// color: cubit.selectedSim == SIM.sim1 ? goldDefaultColor : null,
),
),
decoration: BoxDecoration(
color:
currentSlotIndex == 0 ? goldDefaultColor : null,
borderRadius: homeViewModel.slotsSize != 0
? BorderRadius.all(
Radius.circular(5),
)
: BorderRadius.only(
topLeft: Radius.circular(5),
bottomLeft: Radius.circular(5),
),
),
).onTap(
() {
homeViewModel.changeSelectedSlot(0);
locator<SlotViewModel>().changeSlotIndex();
},
),
homeViewModel.slotsSize == 2
? Container(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: normal12TextGold(
tr('slot_2'),
color: Colors.white,
// color: cubit.selectedSim == SIM.sim1 ? goldDefaultColor : null,
),
),
decoration: BoxDecoration(
color:
currentSlotIndex == 1 ? goldDefaultColor : null,
borderRadius: homeViewModel.slotsSize != 0
? BorderRadius.all(
Radius.circular(5),
)
: BorderRadius.only(
topLeft: Radius.circular(5),
bottomLeft: Radius.circular(5),
),
),
).onTap(
() {
homeViewModel.changeSelectedSlot(1);
locator<SlotViewModel>().changeSlotIndex();
},
)
: Container(),
],
),
actions: [
IconButton(
onPressed: () {
homeViewModel.goToSpeedTest();
},
icon: Image.asset(
'assets/icons/speet-tst-ic.png',
height: 25,
),
),
IconButton(
onPressed: () {
homeViewModel.navigateToSettingsScreen();
},
icon: Icon(IconBroken.Setting),
),
],
bottom: TabBar(
indicatorColor: goldDefaultColor,
indicator: BoxDecoration(
border: Border.all(color: goldDefaultColor, width: 1),
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(50),
color: Colors.grey[600],
),
labelColor: goldDefaultColor,
unselectedLabelColor: Colors.white,
tabs: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(tr('Live')),
CircleAvatar(
radius: 5.0,
backgroundColor: Colors.red,
),
],
),
Text(tr('Map')),
Text(tr('Device Info')),
],
),
),
),
当我在脚手架中添加以下属性时:
extendBodyBehindAppBar: true,
extendBody: true,
所以我需要的是,我想在屏幕MapScreen
保持安全区域时删除安全区域......
解决方案
这就是我会做的,但我会把 TabBarView 和它所有的孩子放在它自己的类里面
child : extendBody ? SafeArea(the all tree) : TabBarView(...)
推荐阅读
- python - Django 只扩展了一个模板
- json - React - 创建递归子代
- javascript - JavaScript 待办事项列表 - 当我单击“编辑”按钮时,它不显示能够更改待办事项的输入
- python - google-api-python-client httplib2 超时
- powershell - 从远程计算机调用时交换 cmdlet
- ios - 通过选择触摸行来预览表格视图单元格中的视图
- ios - 来自不兼容指针类型的类型分配是否应该在objective-c中总是失败?
- c# - 对于具有不同参考的实体,将实体状态设置为已修改
- loopbackjs - 关于“PUT”和“DELETE”查询
- animation - 如何在ue4中停止声音并返回到空闲动画