1. Flutter 的一些概念

  • 有/无状态
  • 懒加载

2. 一些特点

Dart

  • 函数可以不加返回类型
  • 函数参数可以不声明类型
  • dart 运算符: ~/ ,取整 ,例:7~/2=3

Flutter

  • flutter 会强制根widget铺满整个屏幕
  • pubspec.yaml 文件中 flutter 部分有 uses-material-design: true 这条,它能让你使用预置的 Material iconshttps://design.google.com/icons/)。
  • Flutter 在 Release 下是 AOT 模式。

    3. 问答

  1. 为啥这里需要const

    1. home: Scaffold(
    2. appBar: AppBar(
    3. title: const Text('fuck flutter'),
    4. ),
    5. body: const Center(
    6. child: Text('fuck flutter'),
    7. ),
    8. ),
  2. extend 后跟的with关键字,dart的继承原理

  3. SingleTickerProviderStateMixin 类
  4. 为什么TabBar 的 ‘isScrollable: true’ 会影响tab的长度?

截屏2022-01-22 下午4.19.15.png

4. 基础界面(UI)

4.1 基础控件/元素

4.1.1 元素
  1. Text
    1. string
    2. textStyle
  2. RichText 可以单独编辑某个单词的样式
  3. TextSpan
  4. TextField 文本框
  5. TextFromField
  6. Icon
  7. IconButton
  8. FloatingActionButton
  9. FlatButton(1.22后废弃,改为textbutton)
  10. PopupMenuButton
  11. OutlineButton(1.22后废弃,改为OutlinedButtonTheme)
  12. RaisedButton(1.22后废弃,改为ElevatedButton)
  13. ButtonBar
  14. BoxDecoration box装饰
    1. 圆角 borderRadius (BorderRadius)
    2. 渐变色背景 gradient (LinearGradient)
    3. 阴影boxShadow(BoxShadow)
  15. InputDecoration
    1. labelText
    2. labelStyle
    3. border
  16. Image (assets/network/原生/cache)
  17. AssetBundle


动画

  1. AnimatedContainer
  2. AnimatedCrossFade
  3. AnimatedOpacity 动画透明度调整

4.1.2 控件
  1. AppBar
  2. TabBar
  3. BottomAppBar

4.2 布局

  1. Scaffold 包含基本布局,appbar,悬浮按钮,左右页面等
    1. appBar / bottomNavigatorBar
  2. Container
  3. Center
  4. Column
  5. SafeArea
  6. PreferredSize
  7. PageView
  8. SingleChildScrollView

4.3 位置

  1. EdgeInsets.all(16.0)
  2. Offset

4.4 样式(style)

  1. Size.fromHeight(75.0)
  2. Radius.circular(100.0)
  3. 圆角 borderRadius

5. 要实现的界面功能

  1. 九宫格输入
    1. Row + SizedBox 解决
  2. 点击提交自动聚焦到第一个没有按要求填写的输入框
  3. C++ 进行文件存储
  4. C++ 后端
  5. vue中使用 protobuf

6. 错误记录

error

  1. The parameter ‘’ can’t have a value of ‘null’ because of its type, but the implicit default value is ‘null’.

新版要求严格,参数要加 ? 或者 required

  1. Don’t put any logic in createState.

warring

  1. Prefer declaring const constructors on @immutable classes.

7. android studio 开发 flutter 技巧

  1. alt+enter wrap with new widget