Flutter 语法

Flutter 常用特性

级联运算符 ..

cascade.dart
var paint = Paint()
  ..color = Colors.black
  ..strokeCap = StrokeCap.round
  ..strokeWidth = 5.0;

命名参数

named_params.dart
Scaffold(
  appBar: AppBar(title: Text('Title')),
  body: Center(child: Text('Hello')),
);

const 构造函数

const_widget.dart
const Padding(
  padding: EdgeInsets.all(8.0),
  child: Text('Content'),
)