一対一生放送開発Flutterサイドバー機能を実現


サイドバー機能を実現するにはdrawerコンポーネントが使用され、このプロジェクトは手を練習するために使用され、コードは比較的冗長です.
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 = 0}) : super(key: key);

  @override
  _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('  '),
      ),
      body: this._pageList[this._currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        //        
        currentIndex: this._currentIndex,
        //           
        onTap: (int index) {
          setState(() {
            this._currentIndex = index;
          });
        },
        // iconSize: 30.0, //icon   
        fixedColor: Colors.red, //     
        type: BottomNavigationBarType.fixed, //    tabs       
        //        +  
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("  ")),
          BottomNavigationBarItem(
              icon: Icon(Icons.category), title: Text("  ")),
          BottomNavigationBarItem(
              icon: Icon(Icons.settings), title: Text("  ")),
        ],
      ),
      //        
      drawer: Drawer(
        child: Column(
          children: <Widget>[
            Row(
              children: <Widget>[
                Expanded(
                    child: UserAccountsDrawerHeader(
                  accountName: Text("   RQ"),
                  accountEmail: Text("[email protected]"),
                  currentAccountPicture: CircleAvatar(
                    backgroundImage: NetworkImage(
                        "http://sucai.suoluomei.cn/sucai_zs/images/20200226173152-1.jpg"),
                  ),
                  decoration: BoxDecoration(
                      image: DecorationImage(
                    image: NetworkImage(
                        "http://sucai.suoluomei.cn/sucai_zs/images/20200226173152-1.jpg"),
                    fit: BoxFit.cover,
                  )),
                ))
              ],
            ),
            ListTile(
              leading: CircleAvatar(
                child: Icon(Icons.home),
              ),
              title: Text("    "),
              onTap: () {
                Navigator.of(context).pop(); //     
                Navigator.pushNamed(context, '/NavBar'); //     
              },
            ),
            Divider(),
            ListTile(
              leading: CircleAvatar(
                child: Icon(Icons.people),
              ),
              title: Text("    "),
            ),
            Divider(),
            ListTile(
              leading: CircleAvatar(
                child: Icon(Icons.settings),
              ),
              title: Text("    "),
            ),
          ],
        ),
      ),
    );
  }
}