我使用 CupertinoTabBar,但想在用户的设备是 Android 时显示材料设计 BottomSheet。但是,当我同时使用它们时,BottomSheet 隐藏在 CupertinoTabBar 后面,如下所示。
你能帮我解决这个问题吗?还是两者都用不好?
我的简化代码
class MyApp extends StatelessWidget {
void onPressed(BuildContext context) async {
await showModalBottomSheet(
context: context,
builder: (context) => Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
title: Text('Delete'),
onTap: () => Navigator.of(context).pop('delete'),
),
Divider(),
ListTile(
title: Text('Cancel'),
onTap: () => Navigator.of(context).pop('cancel'),
)
],
),
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: CupertinoTabScaffold(
tabBar: CupertinoTabBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.music_note),
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
),
]
),
tabBuilder: (context, index) {
switch (index) {
case 0:
return CupertinoTabView(
builder: (context) {
return CupertinoPageScaffold(
child: FlatButton(
child: Text('button'),
onPressed: () => onPressed(context),
),
);
},
);
case 1:
return CupertinoTabView(
builder: (context) {
return CupertinoPageScaffold(
child: Text('tab 2'),
);
},
);
}
return Container();
}
)
);
}
}