美文网首页
Flutter AppBar组件

Flutter AppBar组件

作者: 喜剧收尾_XWX | 来源:发表于2020-07-28 12:52 被阅读0次
    import 'package:flutter/material.dart';
    
    void main() => runApp(Myapp());
    
    class Myapp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        // TODO: implement build
        return MaterialApp(
          title: 'MaterialApp',
          home: HomePage(),
        );
      }
    }
    
    class HomePage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        // TODO: implement build
    
        return Scaffold(
          appBar: AppBar(
            title: Text('MaterialApp'),
            //左侧图标
            leading: Icon(Icons.home),
            //右侧图标按钮
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.add),
                tooltip: '添加',
                onPressed: () {
                  print("添加");
                },
              ),
              IconButton(
                icon: Icon(Icons.search),
                tooltip: '搜索',
                onPressed: () {
                  print("搜索");
                },
              ),
            ],
          ),
          body: Center(
            child: Text('MaterialApp'),
          ),
          bottomNavigationBar: BottomAppBar(
            child: Container(
              height: 50,
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () {},
            tooltip: '增加',
            child: Icon(Icons.add),
          ),
          floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        );
      }
    }
    
    
    效果图

    相关文章

      网友评论

          本文标题:Flutter AppBar组件

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