Android 对于从屏幕底部弹出的小窗口,使用什么小部件

Android 对于从屏幕底部弹出的小窗口,使用什么小部件,android,ios,flutter,dart,Android,Ios,Flutter,Dart,我正在尝试获得一个小的弹出屏幕,当按下某个按钮时,它会从屏幕底部弹出,而不是指向另一个省道文件,并且上一个屏幕可以变暗并被看到。我试着搜索小部件,但我找不到我要找的那个 举例说明我的意思 为此,请使用模式底页。请遵循或浏览来自的文档 比如说 import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); /// This is the main application widget. class

我正在尝试获得一个小的弹出屏幕,当按下某个按钮时,它会从屏幕底部弹出,而不是指向另一个省道文件,并且上一个屏幕可以变暗并被看到。我试着搜索小部件,但我找不到我要找的那个

举例说明我的意思


为此,请使用模式底页。请遵循或浏览来自的文档

比如说

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

/// This is the main application widget.
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: const MyStatelessWidget(),
      ),
    );
  }
}

/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
  const MyStatelessWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ElevatedButton(
        child: const Text('showModalBottomSheet'),
        onPressed: () {
          showModalBottomSheet<void>(
            context: context,
            builder: (BuildContext context) {
              return Container(
                height: 200,
                color: Colors.amber,
                child: Center(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      const Text('Modal BottomSheet'),
                      ElevatedButton(
                        child: const Text('Close BottomSheet'),
                        onPressed: () => Navigator.pop(context),
                      )
                    ],
                  ),
                ),
              );
            },
          );
        },
      ),
    );
  }
}
导入“包装:颤振/材料.省道”;
void main()=>runApp(const MyApp());
///这是主要的应用程序小部件。
类MyApp扩展了无状态小部件{
constmyapp({Key?Key}):超级(Key:Key);
静态常量字符串_title='颤振代码示例';
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:_标题,
家:脚手架(
appBar:appBar(标题:常量文本(_title)),
正文:const MyStatelessWidget(),
),
);
}
}
///这是主应用程序实例化的无状态小部件。
类MyStatelessWidget扩展了无状态小部件{
const MyStatelessWidget({Key?Key}):super(Key:Key);
@凌驾
小部件构建(构建上下文){
返回中心(
儿童:升降按钮(
子项:const Text('showModalBottomSheet'),
已按下:(){
showModalBottomSheet(
上下文:上下文,
生成器:(BuildContext上下文){
返回容器(
身高:200,
颜色:颜色。琥珀色,
儿童:中心(
子:列(
mainAxisAlignment:mainAxisAlignment.center,
mainAxisSize:mainAxisSize.min,
儿童:[
常量文本(“模式底页”),
升降按钮(
子项:常量文本('Close BottomSheet'),
onPressed:()=>Navigator.pop(上下文),
)
],
),
),
);
},
);
},
),
);
}
}