底部菜单选项

问题描述 投票:0回答:2

如何在Flutter中实现简单的底部菜单?我想显示一定数量的菜单项并对点击做出适当的响应。我在画廊

中找不到任何东西

这是我想要实现的示例,其中包含自定义选项(不仅仅是媒体选项)

material-design flutter material-ui flutter-layout
2个回答
1
投票

也许这可以帮助https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/modal_bottom_sheet_demo.dart

@override
 Widget build(BuildContext context) {
 return new Scaffold(
  appBar: new AppBar(title: const Text('Modal bottom sheet')),
  body: new Center(
    child: new RaisedButton(
      child: const Text('SHOW BOTTOM SHEET'),
      onPressed: () {
        showModalBottomSheet<void>(context: context, builder: (BuildContext context) 
         {
          return new Container(
            child: new Padding(
              padding: const EdgeInsets.all(32.0),
              child: ListView(
               children: <Widget>[
                 ListTile(title: Text('Map'),onTap:null),//handle on tap here
                 //build other menu here
                 ],
              );
                )
                textAlign: TextAlign.center,
                style: new TextStyle(
                  color: Theme.of(context).accentColor,
                  fontSize: 24.0
                )
              )
            )
          );
        });
      }
    )
  )
);

0
投票

“我之前编写过具有相同底部表用户界面的代码,您可以更新它”

Future _selectImage(BuildContext context) 异步 { 等待 showModalBottomSheet( 背景颜色:颜色.透明, 上下文:上下文, 形状:const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(顶部: Radius.circular(20)), ), 构建器:(BuildContext 上下文){ 返回容器( 填充:const EdgeInsets.all(15), 子项:列( mainAxisSize:MainAxisSize.min, 孩子们: [ 卡片( 颜色: Colors.grey.shade200, 子项:列( 孩子们: [ 填充( 填充:const EdgeInsets.all(10.0), 孩子:文本( '将视频上传到您的工作区', 样式:文本样式( 字体大小:17,颜色:Colors.grey.shade500), ), ), 常量除法器(), 列表图块( 标题:中心( 孩子:常量文本( '拍个照', 样式:文本样式( 颜色: 颜色.蓝色, 字体大小:17, ), ), ), onTap: () 异步 { 导航器.pop(上下文); Uint8List?文件=等待pickImage(ImageSource.camera); 如果(文件!=空){ 设置状态((){ _文件=文件; _isImageFullscreen = false; }); } }, ), 除法器(), 列表图块( 标题: 填充( 填充:const EdgeInsets.all(8.0), 孩子:中心( 孩子:常量文本( '从画廊中选择', 样式:文本样式( 颜色: 颜色.蓝色, 字体大小:17, ), ), ), ), onTap: () 异步 { 导航器.pop(上下文); Uint8List?文件=等待pickImage(ImageSource.gallery); 如果(文件!=空){ 设置状态((){ _文件=文件; _isImageFullscreen = false; }); } }, ), ], ), ), SizedBox(height: 10), // 在卡片之间添加一些空间 卡片( 颜色: Colors.grey.shade200, 子项:ListTile( 标题:中心( 孩子:常量文本( '取消', 样式:文本样式( 颜色: 颜色.蓝色, 字体大小:17, ), ), ), 点击: () { 导航器.pop(上下文); }, ), ), ], ), ); }, ); }

© www.soinside.com 2019 - 2024. All rights reserved.