Flutter_31_Drawer导航

  • Scaffold
    • drawer(左侧抽屉菜单)
    • endDrawer(右侧抽屉菜单)
  • UserAccountsDrawerHeader
    • 抽屉菜单头部组件
  • AboutListTitle
    • 关于弹窗
import 'package:flutter/material.dart';

void main() {
  //下一个组件
  runApp(MyApp());
}

//MaterialApp
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter",
      //下一个组件
      home: Home(),
      debugShowCheckedModeBanner: false,
    );
  }
}

//Scaffold
class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Drawer"),
        leading: Icon(Icons.menu),
        actions: [Icon(Icons.settings)],
        elevation: 0.0,
        centerTitle: true,
      ),
      //下一个组件
      body: HomePage(),
      drawer: DrawerList(),
      endDrawer:DrawerList() ,
    );
  }
}

//Container
class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        child: Center(
      child: Text("Hello Flutter", textDirection: TextDirection.ltr),
    ));
  }
}

class DrawerList extends StatelessWidget {
  const DrawerList({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        padding: EdgeInsets.all(0),
        children: [
          // Text("Drawer"),
          UserAccountsDrawerHeader(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage('images/Icon-512.png'),
                fit: BoxFit.cover,
              ),
            ),
            accountName: Text(
              "初六",
              style: TextStyle(color: Colors.black),
            ),
            accountEmail:
                Text("wwww@163.com", style: TextStyle(color: Colors.black)),
            currentAccountPicture: CircleAvatar(
              backgroundImage: AssetImage('images/Icon-512.png'),
            ),
          ),
          ListTile(leading: Icon(Icons.settings),
          title: Text('设置'),
          trailing: Icon(Icons.arrow_back),),
          ListTile(leading: Icon(Icons.account_balance),
          title: Text('余额'),
          trailing: Icon(Icons.arrow_back),),
          Divider(thickness: 2,),
          ListTile(leading: Icon(Icons.settings),
          title: Text('我的'),
          onTap: ()=>Navigator.pop(context),
          trailing: Icon(Icons.arrow_back_ios),),
          AboutListTile(
            child: Text("关于"),
            applicationName: '你的应用名称',
            applicationVersion: '1.0.0',
            icon: CircleAvatar(
              child: Text('aaa'),
            ),
            applicationLegalese: "应用法律条例",
            aboutBoxChildren: [
              Text("条例一:xxx"),
              Text("条例二:xxx"),
            ],
            applicationIcon: Image.asset('images/Icon-512.png',
            width: 50,
            height: 50,),
          )
        ],
      ),
    );
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值