Flutter 如何在Flatter中的抽屉旁边添加按钮

Flutter 如何在Flatter中的抽屉旁边添加按钮,flutter,flutter-layout,navigation-drawer,Flutter,Flutter Layout,Navigation Drawer,嘿,如果有一个参数,我如何在抽屉旁边添加按钮,如图所示。抽屉的长方形关闭按钮,像这样, =>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

嘿,如果有一个参数,我如何在抽屉旁边添加按钮,如图所示。抽屉的长方形关闭按钮,像这样, =>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

导入“包装:颤振/材料.省道”;
void main()=>runApp(MyApp());
类MyApp扩展了无状态小部件{
最终appTitle=‘抽屉演示’;
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:appTitle,
主页:我的主页(标题:appTitle),
);
}
}
类MyHomePage扩展了无状态小部件{
最后的字符串标题;
MyHomePage({Key,this.title}):超级(Key:Key);
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(标题:文本(标题)),
正文:居中(子项:文本(“我的页面!”),
抽屉(
//向抽屉添加列表视图。这确保用户可以滚动
//如果没有足够的垂直线,请通过抽屉中的选项
//空间适合所有东西。
子:ListView(
//重要提示:从ListView中删除任何填充。
填充:EdgeInsets.zero,
儿童:[
抽屉阅读器(
子项:文本(“抽屉标题”),
装饰:盒子装饰(
颜色:颜色,蓝色,
),
),
列表砖(
标题:文本(“项目1”),
onTap:(){
//更新应用程序的状态
// ...
//然后关上抽屉
Navigator.pop(上下文);
},
),
列表砖(
标题:文本(“项目2”),
onTap:(){
//更新应用程序的状态
// ...
//然后关上抽屉
Navigator.pop(上下文);
},
),
],
),
),
);
}
}

或者您可以使用此插件,或者您可以使用FractionlOffset()小部件翻译其子小部件

请共享代码,然后我将能够帮助您
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  final appTitle = 'Drawer Demo';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: appTitle,
      home: MyHomePage(title: appTitle),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(child: Text('My Page!')),
      drawer: Drawer(
        // Add a ListView to the drawer. This ensures the user can scroll
        // through the options in the drawer if there isn't enough vertical
        // space to fit everything.
        child: ListView(
          // Important: Remove any padding from the ListView.
          padding: EdgeInsets.zero,
          children: <Widget>[
            DrawerHeader(
              child: Text('Drawer Header'),
              decoration: BoxDecoration(
                color: Colors.blue,
              ),
            ),
            ListTile(
              title: Text('Item 1'),
              onTap: () {
                // Update the state of the app
                // ...
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
            ListTile(
              title: Text('Item 2'),
              onTap: () {
                // Update the state of the app
                // ...
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
    );
  }
}