gpt4 book ai didi

flutter - 在bottomNavigationBar下方显示bottomSheet

转载 作者:IT老高 更新时间:2023-10-28 12:38:20 24 4
gpt4 key购买 nike

在我们的应用中,我们使用了一个bottomSheet 和一个bottomNavigationBar。

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, title: Text('Test'), groupValue: 'test', onChanged: (value) {}, value: true),
]));
});
};

return MaterialApp(
home: Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text('Sample App'),
),
bottomNavigationBar: Container(
child: IconButton(
icon: Icon(Icons.edit),
onPressed: _showBottomSheet,
),
),
),
);
}
}

最佳答案

添加:useRootNavigator: true,

showModalBottomSheet(
context: context,
useRootNavigator: true,
builder: (context) {},
);

关于flutter - 在bottomNavigationBar下方显示bottomSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50667783/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com