2021年Flutter中的抽屉组件Drawer

1. 配置抽屉组件

1. drawer 左侧抽屉;

2. endDrawer 右侧抽屉;

代码示例:

import "package:flutter/material.dart";
 
 
class CategoryPage extends StatefulWidget {
    CategoryPage({Key key}) : super(key: key);
    _CategoryPageState createState() => _CategoryPageState();
}
 
class _CategoryPageState extends State<CategoryPage> {
    @override
    Widget build(BuildContext context) {
 
        return Scaffold(
            appBar: AppBar(
                title: Text("Flutter App"), 
            ),
            // 左侧抽屉
            drawer: Drawer(
                child: Text('左侧抽屉'), 
            ),
            // 右侧抽屉
            endDrawer: Drawer(
                child: Text('右侧抽屉'), 
            ), 
        );
    }
}

2. 抽屉头 DrawerHeader

常见的属性如下:

1. decoration 装饰;

2. child 子组件;

代码示例:

 

import "package:flutter/material.dart";
 
 
class CategoryPage extends StatefulWidget {
    CategoryPage({Key key}) : super(key: key);
    _CategoryPageState createState() => _CategoryPageState();
}
 
class _CategoryPageState extends State<CategoryPage> {
    @override
    Widget build(BuildContext context) {
 
        return Scaffold(
            appBar: AppBar(
                title: Text("Flutter App"), 
            ),
 
            // 左侧抽屉
            drawer:Drawer(
                child: Column(
                    children: <Widget>[
                        Row(
                            children:<Widget>[
                                Expanded(
                                    // 自定义抽屉头
                                    child:DrawerHeader(
                                        child:Text("我的抽屉"),
                                        // 装饰
                                        decoration: BoxDecoration(
                                            // 背景颜色
                                            color: Colors.yellow,
                                            // 图片
                                            image: DecorationImage(
                                                image: NetworkImage("https://www.itying.com/images/fl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值