zoukankan      html  css  js  c++  java
  • 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('右侧侧边栏'),
          ),
        );
      }
    }
  • 相关阅读:
    windows环境下生成ssh keys
    手写简易Ajax-结合Promise
    Microsoft 登陆微软账号一直加载不进去 解决方案整理
    win10如何开启卓越性能
    win10开启上帝模式
    解决网页禁止复制文字
    module 'sklearn' has no attribute 'svm'
    sklearn的SVM的decision_function_shape的ovo和ovr
    Can not squeeze dim[1], expected a dimension of 1
    python/numpy随机选取训练集/测试集索引
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/11510936.html
Copyright © 2011-2022 走看看