57. 加入更多語法 - sealed class
sealed class Shape {
}
class Square implements Shape {
final double length;
Square(this.length);
}
class Circle implements Shape {
final double radius;
Circle(this.radius);
}
double calculateArea(Shape shape) => switch
(shape) {
Square(length: var l) => l * l,
Circle(radius: var r) => math.pi * r * r
};
60. 加入更多語法 - Control Flow
var json = {'user': ['Ray', 13]};
var name = json['user']![0];
var age = json['user']![1];
var json = { 'user': ['Ray', 13]};
var {'user': [ name, age]} = json;
Before
After
61. 加入更多語法 - Control Flow
var json = { 'user': ['Ray', 13]};
var { 'user': [ name, age]} = json;
62. 加入更多語法 - Control Flow
switch(json) {
case {'user': [String name, int age]}:
print('User $name is $age years old');
break;
default:
throw 'unknown message';
}
if (json is Map<String, dynamic> &&
json.length == 1 &&
json.containsKey('key')) {
var user = json['user'];
if (user is List<dynamic> &&
user.length == 2 &&
user[0] is String &&
user[1] is int) {
var name = user[0] as String;
var age = user[1] as int;
print('User $name is $age years old');
}
}
var json = { 'user': ['Ray', 13]};
Before
After
63. 加入更多語法 - Usable Switch
switch(charCode) {
case slash when nextCharCode == slash:
skipComment();
case slash || star || plus || minus:
opearator();
case >= digit0 && <= digit9:
number();
}
74. ●Custom asset transformers
●Efficient 2D scrolling widgets (e.g. tables and trees)
●Platform Views on macOS and Windows
●Drag and drop
●Wireless debugging on iOS
●Custom "flutter create" templates
Flutter Roadmap 2023 - Features