bottomSheet出现在bottomNavigationbar上方,有没有办法让它出现在下面?
这是一个示例应用程序:
import 'package:Flutter/material.dart';voID main() { runApp(SampleApp());}class SampleApp extends StatefulWidget { @overrIDe _SampleAppState createState() => new _SampleAppState();}class _SampleAppState extends State<SampleApp> { final _scaffoldKey = GlobalKey<ScaffoldState>(); PersistentBottomSheetController _sheetController; @overrIDe Widget build(BuildContext context) { final _showBottomSheet = () { _sheetController = _scaffoldKey.currentState.showBottomSheet((context) { return Container( color: colors.grey[200],child: Column(mainAxisSize: MainAxisSize.min,children: [ RadioListTile(dense: true,Title: Text('Test'),groupValue: 'test',onChanged: (value) {},value: true),RadioListTile(dense: true,])); }); }; return MaterialApp( home: Scaffold( key: _scaffoldKey,appbar: Appbar( Title: Text('Sample App'),),bottomNavigationbar: Container( child: Iconbutton( icon: Icon(Icons.edit),onpressed: _showBottomSheet,); }}解决方法 您可以使用Column将d出窗口与底部导航栏组合使用,并使用 Expandable模拟底部工作表行为:
import 'package:Flutter/material.dart';import 'package:expandable/expandable.dart';voID main() { runApp(SampleApp());}class SampleApp extends StatefulWidget { @overrIDe _SampleAppState createState() => new _SampleAppState();}class _SampleAppState extends State<SampleApp> { @overrIDe Widget build(BuildContext context) { buildBottomSheet() { return Container( color: colors.grey[200],children: [ RadioListTile(dense: true,])); } return MaterialApp( home: Scaffold( appbar: Appbar( Title: Text('Sample App'),body: Container( color: colors.green,bottomNavigationbar: ExpandableNotifIEr( child: Column( mainAxisSize: MainAxisSize.min,children: [ Expandablebutton( child: SizedBox(height: 50,child: Center( child: Icon(Icons.edit),Expandable( expanded: buildBottomSheet(),],); }}
对于生产应用程序,请考虑使用SafeArea在底部添加适当的填充.
总结以上是内存溢出为你收集整理的flutter – 在bottomNavigationBar下显示bottomSheet全部内容,希望文章能够帮你解决flutter – 在bottomNavigationBar下显示bottomSheet所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)