美文网首页
Flutter 3.6 Drawer (抽屉组件) 侧边栏

Flutter 3.6 Drawer (抽屉组件) 侧边栏

作者: 贝灬小晖 | 来源:发表于2020-03-11 18:23 被阅读0次

    1.Divider() 组件 中间一根线

    2.抽屉组件

    //左边栏,右边栏
     drawer: Drawer(
            child: ListView(
              children: <Widget>[
    //抽屉头
                DrawerHeader(
                  child: Text("data"),
                )
              ],
            ),
          ),
    //右抽屉
          endDrawer: Drawer(
                    child: Text('你好'),
    
          ),
    
    import 'package:flutter/material.dart';
    
    class SetController extends StatefulWidget {
      @override
      _SetControllerState createState() => _SetControllerState();
    }
    
    class _SetControllerState extends State<SetController> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text("设置"),
          ),
          drawer: Drawer(
            child: ListView(
              children: <Widget>[
                //头
                UserAccountsDrawerHeader(
                  accountName: Text("123"),
    
                              ),
                //头
                DrawerHeader(
                  child: Text("data"),
                ),
                ListTile(
                  title: Text("gogogo"),
                  onTap: (){
                    Navigator.of(context).pop();//关闭侧边栏
                    
                  },
                )
    
    
              ],
            ),
          ),
          endDrawer: Drawer(
                    child: Text('你好'),
    
          ),
        );
      }
    }
    
    监听跳转 onTap事件 进行跳转

    相关文章

      网友评论

          本文标题:Flutter 3.6 Drawer (抽屉组件) 侧边栏

          本文链接:https://www.haomeiwen.com/subject/avshjhtx.html