flutter - 如何在颤动中在抽屉旁边添加按钮
问题描述
嘿,如果有一个参数,我如何在抽屉旁边添加按钮,如图所示。抽屉的长方形关闭按钮。像这样,=>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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);
},
),
],
),
),
);
}
}
解决方案
或者您可以使用此插件https://pub.dev/packages/align_positioned,或者您可以使用 FractionlOffset() 小部件来翻译他的子小部件
推荐阅读
- angular - Angular 2 - 复选框列表 - 如何检查复选框的状态
- rx-java2 - Rxjava : Schedulers.io() 与 Schedulers.from(scheduledExecutorService)
- c# - 如何删除除某些文件夹以外的所有文件夹
- c# - 我在桌子附近遇到语法错误,它说不知道到底需要做什么
- javascript - 如何在不知道先执行哪个 then() 的情况下返回已解决的承诺
- java - 连接数据库后代号一个登录表单
- ruby - 在 Stripe 中创建费用后响应
- python - Pandas 中的插值水平独立于每一行
- tsql - 这个连接怎么写?
- android - android有序广播是原子的吗?如果不是,如何为此类广播实现原子性?