简体   繁体   English

Flutter || 在 AppBar 下方添加文字

[英]Flutter || Add text below AppBar

There is an application page that is responsible for displaying devices.有一个应用程序页面负责显示设备。 There is a code that returns AppBar, Body, Drawer.有一段代码返回AppBar、Body、Drawer。 Question: how do I put the description "List of devices" between AppBar and Body (as in the photo)问题:如何在 AppBar 和 Body 之间放置描述“设备列表”(如图所示)

输出样本

      @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        automaticallyImplyLeading: true,
        backgroundColor: Colors.black,
        title: const Text('IT', style: TextStyle(fontSize: 45,
                                   fontWeight: FontWeight.w800,
                                    color: Colors.white)),
        centerTitle: true,
        actions: [
          IconButton(
            icon: const Icon(Icons.filter_alt,
                             size: 30.0,),
            color: Colors.white,
            onPressed: () {
              showDialog<Filter>(context: context, builder: (_) {
                return FilterDialog(onApplyFilters: _filter,);
              });
            },
          ),
        ],
      ),

      body: PhonesList(phones: filteredPhones),

      drawer: Drawer(.....),
            
    );

you use appbar bottom... and customization您使用 appbar 底部...和自定义

 bottom: PreferredSize(
             child: Container(
               color: Colors.white,
               child: row(

                ),
             ),
         preferredSize: Size.fromHeight(kToolbarHeight)
      ),

use a column widget below appbar or introduce a column widget on Body.使用 appbar 下方的列小部件或在 Body 上引入列小部件。

Column(
          children:<Widget>[
            Container(
              decoration:BoxDecoration(
                borderRadius:BorderRadius.circular(10),
                color:Colors.green
              ),
              child: Column(
                children:<Widget>[
                     Text("iphone 11 ",style: TextStyle(color:Colors.white,fontSize:25),),
                        Text("ios 15")
                ])
            ),
            Container(
              decoration:BoxDecoration(
                borderRadius:BorderRadius.circular(10),
                color:Colors.green
              ),
              child: Column(
                children:<Widget>[
                     Text("iphone 13 ",style: TextStyle(color:Colors.white,fontSize:25),),
                        Text("ios 13")
                ])
            ),
           
          ]
        ),

Use bottom property of AppBar and add text inside it使用 AppBar 的bottom属性并在其中添加文本

Text will be shown at the bottom of AppBar文本将显示在 AppBar 的底部

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM