zoukankan      html  css  js  c++  java
  • Flutter——FloatingActionButton组件(浮动按钮组件)

    FloatingActionButton 简称 FAB ,可以实现浮动按钮,也可以实现类似闲鱼 app 的地步凸起导航。
     
     
    属性名称 属性值
    child
    子视图,一般为 Icon,不推荐使用文字
    tooltip
    FAB 被长按时显示,也是无障碍功能
    backgroundColor
    背景颜色
    elevation
    未点击的时候的阴影
    hignlightElevation
    点击时阴影值,默认 12.0
    onPressed
    点击事件回调
    shape
    可以定义 FAB 的形状等
    mini
    是否是 mini 类型默认 false

    FloatingActionButton实现闲鱼APP底部凸起按钮:

    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MaterialApp(
        title: "FloatingActionButton",
        home: MyApp(),
      ));
    }
    
    class MyApp extends StatefulWidget {
      @override
      _MyAppState createState() => _MyAppState();
    }
    
    class _MyAppState extends State<MyApp> {
      int _currentIndex = 0;
      List _pageList = [
        Page("闲鱼页面"),
        Page("鱼塘页面"),
        Page("发布页面"),
        Page("消息"),
        Page("我的")
      ];
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: _pageList[_currentIndex],
          bottomNavigationBar: BottomNavigationBar(
            currentIndex: _currentIndex,
            type: BottomNavigationBarType.fixed,
            fixedColor: Colors.yellow,
            onTap: (int index) {
              setState(() {
                this._currentIndex = index;
              });
            },
            items: [
              BottomNavigationBarItem(
                  icon: Icon(Icons.home),
                  title: Text("闲鱼", style: TextStyle(color: Colors.black54))),
              BottomNavigationBarItem(
                  icon: Icon(Icons.category),
                  title: Text("鱼塘", style: TextStyle(color: Colors.black54))),
              BottomNavigationBarItem(
                  icon: Icon(Icons.settings),
                  title: Text("发布", style: TextStyle(color: Colors.black54))),
              BottomNavigationBarItem(
                  icon: Icon(Icons.message),
                  title: Text("消息", style: TextStyle(color: Colors.black54))),
              BottomNavigationBarItem(
                  icon: Icon(Icons.settings),
                  title: Text("我的", style: TextStyle(color: Colors.black54))),
            ],
          ),
          floatingActionButton: Container(
            margin: EdgeInsets.only(top: 5),
            child: FloatingActionButton(
              child: Icon(Icons.add, color: Colors.black54),
              backgroundColor: Colors.yellow,
              onPressed: () {
                setState(() {
                  this._currentIndex = 2;
                });
              },
            ),
          ),
          floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        );
      }
    }
    
    class Page extends StatelessWidget {
      String text;
    
      Page(this.text);
    
      @override
      Widget build(BuildContext context) {
        return Center(
          child: Text(text),
        );
      }
    }
  • 相关阅读:
    Snort 2.9.4.0 发布,入侵检测系统
    Tails 0.15 发布,基于Debian的Linux发行
    httpkit 1.2 发布
    cmogstored 0.9.0 发布,mogstored 的 C 实现
    JSwat 2012.1 发布,Java 调试工具
    诺基亚 Lumia 920T 今日发布 处理器升级
    如何在你的网站中嵌入 RunJS 的代码 (gist)?
    Linux 上的 Darwin/OS X 仿真器 Darling
    Zarafa 7.0.11/7.1.2 发布
    Silverlight实例教程 – Datagrid,Dataform数据验证和ValidationSummary
  • 原文地址:https://www.cnblogs.com/chichung/p/12017807.html
Copyright © 2011-2022 走看看