android - 找不到脚手架小部件 : Getting exception while opening Bottom Dialog sheet

标签 android flutter flutter-layout bottom-sheet

我正在使用 Scaffold 小部件,但是在打开底部对话框时出现此异常

@override
Widget build(BuildContext context) {

return Scaffold(
  appBar: AppBar(
    title: Text("Calendar"),
  ),
  body: SafeArea(
  .......
  .......

    child: GestureDetector(
                        onTap: (){
                          //getting exception here
                          showBottomSheet(
                              context: context,
                              builder: (context) => Container(
                                color: Colors.red,
                              ));
                        },

我被困在这段代码上,如果有人可以提出任何建议,那将非常有帮助。谢谢你。

最佳答案

使用showModalBottomSheet而不是 showBottomSheet试用以下例如。

void _settingModalBottomSheet(BuildContext context){
    showModalBottomSheet(
        context: context,
        builder: (BuildContext bc){
      return Container(
        child: new Wrap(
          children: <Widget>[
            new ListTile(
                leading: new Icon(Icons.music_note),
                title: new Text('Music'),
                onTap: () => {}
            ),
            new ListTile(
              leading: new Icon(Icons.videocam),
              title: new Text('Video'),
              onTap: () => {},
            ),
          ],
        ),
      );
    });
}

关于android - 找不到脚手架小部件 : Getting exception while opening Bottom Dialog sheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60071855/

相关文章:

android - 在android中无间断地播放连续视频流

dart - flutter : Bad state: Stream has already been listened to

android - 更改工具栏中汉堡包图标的大小?

Android - 我们可以使用 flash 文件(.flv 或 .swf)为 Android 设备制作动态壁纸吗?

java - libGdx 和 facebook

dart - 在 Flutter 中将图像对齐到左上角

flutter - 如何在列表上方添加按钮?

mobile - 有没有其他方法可以改变脚手架抽屉的宽度?

firebase - 如何在 Crashlytics/Flutter (Android) 中查看 Dart 代码堆栈跟踪而不是 Java 代码堆栈跟踪

flutter - 让小部件静静地溢出外部屏幕