我注意到Scaffold的抽屉.只有当有AppBar of Scaffold时,才会出现抽屉.

但我没有使用AppBar,而是使用了BottomNavigationBar中的BottomAppBar.

如何让Drawer使用BottomAppBar?

class homieclass extends State<homie>{

@Override 小部件生成(BuildContext上下文){ 退货MaterialApp( debugShowCheckedModeBanner:False, 主页:新脚手架(

    backgroundColor: Colors.white70.withOpacity(0.9),
    floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    floatingActionButton: FloatingActionButton(onPressed: (){},backgroundColor: Colors.redAccent,child: ImageIcon(new AssetImage("ast/hello123.png")),),
    bottomNavigationBar: BottomAppBar(child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,mainAxisSize: MainAxisSize.max,children: <Widget>[
        IconButton(icon: Icon(Icons.menu), onPressed: (){}),IconButton(icon: Icon(Icons.message), onPressed: (){}),
    ],
    ),
    ),
    body: new Column(
      children: <Widget>[new SizedBox(height: 50.0, ),
        Container(margin: EdgeInsets.only(left: 0.0),child: new Text("Events",textAlign: TextAlign.left,style: TextStyle(fontFamily: 'ssfr',fontSize: 35.0,fontWeight: FontWeight.bold),),)
        , Container(margin: EdgeInsets.only(left: 10.0,right: 10.0) ,width: 360.0,height: 40.0,decoration: new BoxDecoration(color: Colors.blueGrey.withOpacity(0.2),
          border: new Border.all(color: Colors.blueGrey.withOpacity(0.0), width: 2.0),
          borderRadius: new BorderRadius.circular(10.0),),child: new Row(children: <Widget>[SizedBox(width: 10.0,),Icon(Icons.search,color: Colors.blueGrey.withOpacity(0.9),),Text(" Search",style: TextStyle(fontFamily: 'ssft',color: Colors.blueGrey,fontSize: 20.0),)],),)
      ,new SizedBox(height: 10.0,),new SizedBox(
        height: 5.0,
        child: new Center(
          child: new Container(
            margin: new EdgeInsetsDirectional.only(start: 1.0, end: 1.0),
            height: 2.0
            ,
            color: Colors.redAccent.withOpacity(0.8),
          ),
        ),
      ),],
    ),drawer: new Drawer(
    child: new ListView(
      children: <Widget>[ListTile(title: Text("hello"),)],
    ),
  ),

  ),
);

}

推荐答案

它非常适合我.下面是一个工作示例,底部栏中有一个专用的"显示抽屉"按钮(也可以从左侧拖入抽屉):

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Playground',
      home: TestPage(),
    );
  }
}

class TestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text('Body'),
      ),
      bottomNavigationBar: Builder(builder: (BuildContext context) {
        return BottomAppBar(
          color: Colors.orange,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              IconButton(icon: Icon(Icons.menu), onPressed: () {
                Scaffold.of(context).openDrawer();;
              }),
              IconButton(icon: Icon(Icons.message), onPressed: () {}),
            ],
          ),
        );
        },),
      drawer: Drawer(
        child: SafeArea(
          right: false,
          child: Center(
            child: Text('Drawer content'),
          ),
        ),
      ),
    );
  }
}

Ffltter版本:最新的主版本(虽然我也非常确定它可以与测试版一起工作)

Dart相关问答推荐

如何找到这个Currate函数的返回类型?

为什么我们在dart 里有工具?

为什么使用三元条件运算符会产生return_of_invalid_type错误?

无法在 IOS 上使用 firebase 运行Flutter应用程序

Flutter 中的with关键字

从列表中删除项目后更新 UI

如何签署 Flutter 的应用程序

Flutter 中的嵌套数据和 BLoC

有没有可能用Flatter摄像头插件播放视频?

如何在 Flutter CustomPainter 中使用Bezier Curves绘制形状

Flutter插件和Flutter模块之间有什么区别?

如何使我的对话框可滚动?

Flitter中的谷歌 map 没有出现

基于镜子的反射和传统反射有什么区别?

如何使用工厂构造函数扩展抽象类?

有没有更好的方法来找出文件或目录是否存在?

如何在 timeLimit 之后使future 的计算超时?

在dart中获取列表的最后一个元素

Dart 中的多行字符串

在 Dart 中创建具有可变数量的参数或参数的函数