22、Scaffold属性 抽屉菜单Drawer
class MyFlutterApp extends StatelessWidget {
const MyFlutterApp({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Flutter App")),
drawer: const Drawer(
child: Text("左侧侧边栏"),
),
endDrawer: const Drawer(
child: Text("左侧侧边栏"),
),
);
}
}

Flutter DrawerHeader
常见属性:

class MyFlutterApp extends StatelessWidget {
const MyFlutterApp({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Flutter App")),
drawer: const Drawer(
child: Column(
children: [
Row(
children: [
Expanded(
flex: 1,
child: DrawerHeader(
decoration: BoxDecoration( //头部
color: Colors.red, //背景颜色
image: DecorationImage(
image: NetworkImage("https://www.itying.com/images/flutter/3.png"),
fit: BoxFit.cover) //背景图片(不是圆形)
),
child: Text("头部")
),
)
],
),
// SizedBox(height: 60,), //顶部间距
// DrawerHeader(
// decoration: BoxDecoration(
// color: Colors.red //背景颜色
// ),
// child: Text("头部"),
// ),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.people),
),
title: Text("个人中心"),
),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.toll),
),
title: Text("设置"),
)
],
)),
endDrawer: const Drawer(
child: Text("右侧侧边栏"),
),
);
}
}

自定义头像
//头像需要自己去定义
class MyFlutterApp extends StatelessWidget {
const MyFlutterApp({super.key}); @override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Flutter App")),
drawer: const Drawer(
child: Column(
children: [
Row(
children: [
Expanded(
flex: 1,
child: DrawerHeader(
//头部
decoration: BoxDecoration(
color: Colors.red, //背景颜色
image: DecorationImage(
image: NetworkImage(
"https://www.itying.com/images/flutter/3.png"),
fit: BoxFit.cover) //背景图片(不是圆形)
),
child: Column(
children: [
ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage(
"https://www.itying.com/images/flutter/3.png",
), //图片(圆形)
// child: Image.network("https://www.itying.com/images/flutter/3.png"),图片(不是圆形)
),
title: Text("个人中心"),
),
ListTile(
title: Text("邮箱: 111111111@qq.com"),
)
],
),
),
)
],
), // SizedBox(height: 60,), //顶部间距
// DrawerHeader(
// decoration: BoxDecoration(
// color: Colors.red //背景颜色
// ),
// child: Text("头部"),
// ),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.people),
),
title: Text("个人中心"),
),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.toll),
),
title: Text("设置"),
)
],
)),
endDrawer: const Drawer(
child: Text("右侧侧边栏"),
),
);
}
}
Flutter UserAccountsDrawerHeader
常见属性:

class MyFlutterApp extends StatelessWidget {
const MyFlutterApp({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Flutter App")),
drawer: Drawer(
width: 500, // 设置自定义宽度
child: Column(
children: [
Row(
children: [
Expanded(
flex: 1,
child: UserAccountsDrawerHeader(
decoration: const BoxDecoration(
image: DecorationImage(
image: NetworkImage(
"https://www.itying.com/images/flutter/3.png"),
fit: BoxFit.cover,
) //背景图片
),
currentAccountPicture: const CircleAvatar(
backgroundImage: NetworkImage(
"https://www.itying.com/images/flutter/3.png"), //用户头像
),
otherAccountsPictures: [ //他账户头像(图片)
//
Image.network(
"https://www.itying.com/images/flutter/3.png"),
Image.network(
"https://www.itying.com/images/flutter/3.png"),
Image.network(
"https://www.itying.com/images/flutter/3.png"),
],
accountName: Text("张三"),
accountEmail: Text("11111111@qq.com"),
),
)
],
),
const ListTile(
leading: CircleAvatar(
child: Icon(Icons.people),
),
title: Text("个人中心"),
),
const ListTile(
leading: CircleAvatar(
child: Icon(Icons.toll),
),
title: Text("设置"),
)
],
)),
endDrawer: const Drawer(
child: Text("右侧侧边栏"),
),
);
}
}

22、Scaffold属性 抽屉菜单Drawer的更多相关文章
- [UI]抽屉菜单DrawerLayout分析(一)
本文转载于:http://www.cnblogs.com/avenwu/archive/2014/04/16/3669367.html 侧拉菜单作为常见的导航交互控件,最开始在没有没有android官 ...
- android自定义viewgroup初步之一----抽屉菜单
转载请注明出处 http://blog.csdn.net/wingichoy/article/details/47832151 几天前在慕课网上看到鸿洋老师的 自定义卫星菜单,感觉很有意思,于是看完视 ...
- 可折叠的ToolBar+抽屉菜单NavigationView+浮动按钮FloatButton
使用Material Design风格的ToolBar和抽屉导航 先看个简单的运行效果 主要记录下布局的写法 1 用到的Google Design依赖和V7包依赖 compile 'com.andro ...
- Android抽屉菜单DrawerLayout的实现案例
(1)项目布局文件 activity_main.xml <android.support.v4.widget.DrawerLayout xmlns:android="http://sc ...
- [UI]抽屉菜单DrawerLayout分析(三)
在[UI]抽屉菜单DrawerLayout分析(一)和[UI]抽屉菜单DrawerLayout分析(二)中分别介绍了DrawerLayout得基本框架结构和ViewDragerHelper的作用以及手 ...
- wemall doraemon中Android app商城系统解决左侧抽屉菜单和viewpager不能兼容问题
完美解决左侧抽屉菜单和viewpager不能兼容左右滑动的问题,可进行参考. WeMall-Client/res/layout/wemall_main_ui.xml </RadioGroup&g ...
- Android导航抽屉-Navigation Drawer
Google今年七月份的时候更新了他们的Google+应用,采用了新的导航方式并抛弃了navigationdrawer.一时之间,又引发了一系列关于NavigationDrawer利弊的讨论,不过对于 ...
- android 5.X Toolbar+DrawerLayout实现抽屉菜单
前言 android5.X新增的一个控件Toolbar,这个控件比ActionBar更加自由,可控,因为曾经的ActionBar的灵活性比較差,所以google逐渐使用Toolbar替代Action ...
- Android Design Support Library(二)用NavigationView实现抽屉菜单界面
NavigationView在MD设计中非常重要,之前Google也提出了使用DrawerLayout来实现导航抽屉.这次,在Android Design Support Library中,Googl ...
- 安卓导航抽屉 Navigation Drawer 实现沉浸通知栏
在使用 Navigation Drawer Activity 模版的时候,遇到了通知栏无法完全沉浸的问题,尝试搜索一些现有的解决方法,但是或多或少都会存在一些问题,通过反复尝试找到找到了一种比较靠谱的 ...
随机推荐
- Educational Codeforces Round 148 [Rated for Div. 2]A~C
A #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 60; char c ...
- C++小练习:字符串分割的高性能实现
字符串分割是日常工作中比较常见的基础函数,通常大家会使用现成的基础库,基础库的性能是否是最佳的?本文基于一个周末小练习,研究如何最大限度的提升字符串分割的性能. 1.背景 字符串按照分隔符拆成多个子串 ...
- TerraMoursGPT V1.0 开发总结
TerraMoursGPT V1.0 开发总结 TerraMoursGPT V1.0 是之前gpt项目基于TerraMours后端框架的重构,实现用户登陆和基于SK的多语言模型聊天.基于chatgpt ...
- [Python急救站课程]等边三角形的绘制
等边三角形的绘制 from turtle import * penup() fd(-50) pendown() pensize(25) seth(60) fd(100) seth(-60) fd(10 ...
- [Python急救站课程]九九乘法表打印
打印九九乘法表 for i in range(1, 10): for j in range(1, i + 1): print("{}*{}={:2} ".format(j, i, ...
- 24. 从零用Rust编写正反向代理,细说HTTP行为中的几种定时器
wmproxy wmproxy已用Rust实现http/https代理, socks5代理, 反向代理, 静态文件服务器,四层TCP/UDP转发,内网穿透,后续将实现websocket代理等,会将实现 ...
- baby_web
点开页面获得提示 根据提示,访问index.php,但是会自己跳转到1.php 这时候抓包修改才ok才能定位到index.php
- Verilog HDL门级建模
Verilog HDL内部定义了12个基本门级元件可以直接用,用这些门级原件直接对逻辑图进行描述,称为门级建模. 每个门输入可能是逻辑0,逻辑1,不确定态x和高阻态z四个值之一. 1.多输入门 主要有 ...
- [OpenWrt]软路由H28K开启USB无线教程
0x01 背景 H28K软路由带了一个USB2.0的接口,官方说是支持USB无线的:于是就网购了USB转WIFI的设备(芯片:RTL8811CU),拿到手后开心的插上去,发现没有任何反应:在Q裙中询问 ...
- super学习
2022-10-02 16:27:38 super super代表的是"当前对象(this)"的父类型特征 概念 1.super是一个关键字,全部小写. 2.super和this对 ...
