Flutter & Scaffold & multiple floatingActionButton

demo


  1. import 'package:flutter/material.dart';
  2. void main() => runApp(App());
  3. class App extends StatelessWidget {
  4. @override
  5. Widget build(BuildContext context) {
  6. return MaterialApp(
  7. // home: StateApp(),
  8. home: Scaffold(
  9. appBar: AppBar(
  10. title: Text("appbar"),
  11. backgroundColor: Colors.blueAccent[700],
  12. ),
  13. body: Center(
  14. child: StateApp(),
  15. ),
  16. ),
  17. );
  18. }
  19. }
  20. class StateApp extends StatefulWidget {
  21. StateApp();
  22. @override
  23. createState() => _StateAppState();
  24. }
  25. class _StateAppState extends State<StateApp> {
  26. int _counter = 0;
  27. // String _randomColor = "#ff00ff";
  28. Color _randomColor = Colors.lightGreen;
  29. void _clearCounter() => setState(() {
  30. // clear
  31. _counter = 0;
  32. _randomColor = Colors.lightGreen;
  33. });
  34. void _updateCounter() => setState(() {
  35. _counter++;
  36. _randomColor = (_counter % 2 == 0) ? Colors.redAccent : Colors.purple;
  37. // random color
  38. });
  39. // _updateCounter() {
  40. // setState(() {
  41. // _counter++;
  42. // });
  43. // }
  44. @override
  45. Widget build(BuildContext context) {
  46. return Scaffold(
  47. // backgroundColor: Colors.lightGreen,
  48. backgroundColor: _randomColor,
  49. body: Center(
  50. child: Column(
  51. children: <Widget>[
  52. Padding(
  53. padding: const EdgeInsets.all(23.0),
  54. child: Text(
  55. 'You have pushed the button this many times:',
  56. style: TextStyle(
  57. fontWeight: FontWeight.bold,
  58. fontSize: 18.0,
  59. ),
  60. ),
  61. ),
  62. Center(
  63. child: Text(
  64. '$_counter',
  65. style: TextStyle(
  66. fontWeight: FontWeight.bold,
  67. fontSize: 23.0,
  68. ),
  69. ),
  70. ),
  71. ],
  72. ),
  73. ),
  74. floatingActionButton: Padding(
  75. // padding: const EdgeInsets.all(8.0),
  76. padding: const EdgeInsets.only(
  77. top: 300.0,
  78. ),
  79. child: Column(
  80. children: <Widget>[
  81. // SpeedDial
  82. FloatingActionButton(
  83. onPressed: () async {
  84. // _counter++;
  85. print("clicked = $_counter");
  86. // setState(() {
  87. // _counter++;
  88. // });
  89. _updateCounter();
  90. },
  91. child: Icon(Icons.add),
  92. ),
  93. FloatingActionButton(
  94. onPressed: () async {
  95. print("clear = $_counter");
  96. _clearCounter();
  97. },
  98. child: Icon(Icons.remove),
  99. ),
  100. ],
  101. ),
  102. ),
  103. );
  104. }
  105. }

refs

https://gist.github.com/duhamelstuff/39a9c24ad1cd1ad376c34bc3aea2ef57#gistcomment-3348355

https://www.youtube.com/watch?v=1FmATI4rOBc

  1. cupertino_icons: ^0.1.3
  2. flutter_speed_dial: ^1.2.1

https://www.youtube.com/watch?v=p2xKPvNZeEA

https://medium.com/@RotBolt/test-cef30fcb5c54

https://stackoverflow.com/questions/50839282/how-to-add-multiple-floating-button-in-stack-widget-in-flutter



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


Flutter & Scaffold & multiple floatingActionButton的更多相关文章

  1. flutter系列之:flutter中可以建索引的栈布局IndexedStack

    目录 简介 IndexedStack简介 IndexedStack的使用 总结 简介 之前我们介绍了一个flutter的栈结构的layout组件叫做Stack,通过Stack我们可以将一些widget ...

  2. Flutter学习(一)之MaterialApp和Scaffold组件使用详解

    一,前言: MaterialApp和Scaffold是Flutter提供的两个Widget,其中: MaterialApp是一个方便的Widget,它封装了应用程序实现Material Design所 ...

  3. Flutter常用组件(Widget)解析-Scaffold

    实现一个应用基本的布局结构. 举个栗子: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); clas ...

  4. Flutter学习笔记(16)--Scaffold脚手架、AppBar组件、BottomNavigationBar组件

    如需转载,请注明出处:Flutter学习笔记(15)--MaterialApp应用组件及routes路由详解 今天的内容是Scaffold脚手架.AppBar组件.BottomNavigationBa ...

  5. Flutter学习笔记(20)--FloatingActionButton、PopupMenuButton、SimpleDialog、AlertDialog、SnackBar

    如需转载,请注明出处:Flutter学习笔记(20)--FloatingActionButton.PopupMenuButton.SimpleDialog.AlertDialog.SnackBar F ...

  6. flutter FloatingActionButton组件

    import 'package:flutter/material.dart'; class FloatingActionButtonDemo extends StatelessWidget { @ov ...

  7. Flutter——FloatingActionButton组件(浮动按钮组件)

    FloatingActionButton 简称 FAB ,可以实现浮动按钮,也可以实现类似闲鱼 app 的地步凸起导航.     属性名称 属性值 child 子视图,一般为 Icon,不推荐使用文字 ...

  8. Flutter中的浮动按钮FloatingActionButton 及融合底部工具栏

    FloatingActionButton 简称 FAB,从字面理解可以看出,它是“可交互的浮动按钮”,其实在Flutter默认生成的代码中就有这家伙,只是我们没有正式的接触. 一般来说,它是一个圆形, ...

  9. Flutter中的浮动按钮 FloatingActionButton

    FloatingActionButton 简称 FAB ,可以实现浮动按钮,也可以实现类似闲鱼 app 的底部凸起导航 . 常用属性 FloatingActionButton的常用属性,同flutte ...

随机推荐

  1. Socket的用法——NIO包下SocketChannel的用法 ———————————————— 版权声明:本文为CSDN博主「茶_小哥」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/ycgslh/article/details/79604074

    服务端代码实现如下,其中包括一个静态内部类Handler来作为处理器,处理不同的操作.注意在遍历选择键集合时,没处理完一个操作,要将该请求在集合中移除./*模拟服务端-nio-Socket实现*/pu ...

  2. Java 从Character和char的区别来学习自动拆箱装箱

    本文结构 1.Character和char 的区别: 2.自动拆箱装箱 1.Character和char 的区别: Character是类,char基本数据类型. 在java中有三个类负责对字符的操作 ...

  3. LOJ10013曲线

    题目描述 明明做作业的时候遇到了n  个二次函数s_i(x)=ax^2+bx+c ,他突发奇想设计了一个新的函数 f(x)=max{s_i(x)},i=1,2,...,n. 明明现在想求这个函数在 [ ...

  4. Spring Boot构建 RESTful 风格应用

    Spring Boot构建 RESTful 风格应用 1.Spring Boot构建 RESTful 风格应用 1.1 实战 1.1.1 创建工程 1.1.2 构建实体类 1.1.4 查询定制 1.1 ...

  5. Codeforces Round #649 (Div. 2) A. XXXXX

    题目链接:https://codeforces.com/contest/1364/problem/A 题意 找出大小为 $n$ 的数组 $a$ 的最长连续子数组,其元素和不被 $x$ 整除. 题解 如 ...

  6. 【bzoj 3232】圈地游戏(算法效率--01分数规划+图论--最小割)

    题目:DZY家的后院有一块地,由N行M列的方格组成,格子内种的菜有一定的价值,并且每一条单位长度的格线有一定的费用.DZY喜欢在地里散步.他总是从任意一个格点出发,沿着格线行走直到回到出发点,且在行走 ...

  7. 【poj 2115】C Looooops(数论--拓展欧几里德 求解同余方程 模版题)

    题意:有一个在k位无符号整数下的模型:for (variable = A; variable != B; variable += C)  statement; 问循环的次数,若"永不停息&q ...

  8. Codeforces #640 div4 F~G (构造二连弹)

    题意:求一个只由\(01\)组成的字符串,使得它所有长度为\(2\)的子串满足:每对子串的数字和为\(0,1,2\)的个数为\(a,b,c\). 题解:我们先考虑子串数字和为\(1\)的情况,构造出一 ...

  9. Educational DP Contest E - Knapsack 2 (01背包进阶版)

    题意:有\(n\)个物品,第\(i\)个物品价值\(v_{i}\),体积为\(w_{i}\),你有容量为\(W\)的背包,求能放物品的最大价值. 题解:经典01背包,但是物品的最大体积给到了\(10^ ...

  10. Codeforces Global Round 8 D. AND, OR and square sum (贪心,位运算)

    题意:有\(n\)个数,选择某一对数使二者分别\(or\)和\(and\)得到两个新值,求操作后所有数平方和的最大值. 题解:不难发现每次操作后,两个数的二进制表示下的\(1\)的个数总是不变的,所以 ...