• 21Flutter Drawer侧边栏、以及侧边栏内容布局


    Tabs.dart

    import 'package:flutter/material.dart';
    import 'tabs/Home.dart';
    import 'tabs/Category.dart';
    import 'tabs/Setting.dart';
    
    class Tabs extends StatefulWidget {
      final index;
      Tabs({Key key, this.index = 1}) : super(key: key);
      _TabsState createState() => _TabsState(this.index);
    }
    
    class _TabsState extends State<Tabs> {
      int _currentIndex = 0;
      _TabsState(index) {
        this._currentIndex = index;
      }
      List _pageList = [HomePage(), CategoryPage(), SettingPage()];
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Flutter Demo'),
          ),
          bottomNavigationBar: BottomNavigationBar(
              currentIndex: this._currentIndex,
              onTap: (int index) {
                // print(index);
                setState(() {
                  this._currentIndex = index;
                });
              },
              iconSize: 36.0,
              type: BottomNavigationBarType.fixed,
              fixedColor: Colors.red,
              items: [
                BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('首页')),
                BottomNavigationBarItem(
                    icon: Icon(Icons.category), title: Text('分类')),
                BottomNavigationBarItem(
                    icon: Icon(Icons.settings), title: Text('设置')),
              ]),
          body: this._pageList[this._currentIndex],
          drawer: Drawer(
            child: Column(
              children: <Widget>[
                Row(
                  children: <Widget>[
                    // Expanded(
                    //   child: DrawerHeader(
                    //     child: Text('你好Flutter'),
                    //     decoration: BoxDecoration(
                    //       // color: Colors.yellow
                    //       image: DecorationImage(
                    //         image: NetworkImage('https://www.itying.com/images/flutter/2.png'),
                    //         fit:BoxFit.cover
                    //       ),
                    //     ),
                    //   )
                    // )
    
                    Expanded(
                      child: UserAccountsDrawerHeader(
                        accountName: Text('老师你好'),
                        accountEmail: Text('gztt@163.com'),
                        currentAccountPicture: CircleAvatar(
                          backgroundImage: NetworkImage(
                              'https://www.itying.com/images/flutter/3.png'),
                        ),
                        decoration: BoxDecoration(
                          // color: Colors.yellow
                          image: DecorationImage(
                              image: NetworkImage(
                                  'https://www.itying.com/images/flutter/2.png'),
                              fit: BoxFit.cover),
                        ),
                        otherAccountsPictures: <Widget>[
                          Image.network(
                              'https://www.itying.com/images/flutter/5.png'),
                          Image.network(
                              'https://www.itying.com/images/flutter/4.png')
                        ],
                      ),
                    )
                  ],
                ),
                ListTile(
                    leading: CircleAvatar(
                      child: Icon(Icons.home),
                    ),
                    title: Text('我的空间')),
                Divider(),
                ListTile(
                  leading: CircleAvatar(
                    child: Icon(Icons.home),
                  ),
                  title: Text('用户中心'),
                  onTap: () {
                    Navigator.of(context).pop();
                    Navigator.pushNamed(context, '/user');
                  }
                ),
                Divider(),
                ListTile(
                  leading: CircleAvatar(
                    child: Icon(Icons.home),
                  ),
                  title: Text('用户中心'),
                )
              ],
            ),
          ),
          endDrawer: Drawer(
            child: Text('右侧侧边栏'),
          ),
        );
      }
    }
  • 相关阅读:
    【AGC016E】Poor Turkeys
    【51nod 1597】有限背包计数问题
    RPA应用场景-营业收入核对
    RPA应用场景-报税机器人
    UiPath保存图片操作的介绍和使用
    UiPath图片操作截图的介绍和使用
    UiPath存在图像Image Exists的介绍和使用
    UiPath存在元素Element Exists的介绍和使用
    UiPath存在文本Text Exists的介绍和使用
    UiPath文本操作Get Visible Text的介绍和使用
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/11510936.html
Copyright © 2020-2023  润新知