Flutter 插件推荐
状态管理插件
可以在VSCode 插件市场搜你用的状态管理库,例如 你用的 Provider
---> Flutter Provider
代码注释高亮插件
Better Comments
代码注释加强能够高亮
Model Data 类生成
Dart Data Class Generator
自动生成 Model
类 方法 opyWith()
, toString()
, toJson()
fromJson()
, toMap()
, fromMap()
等
Dart Data Class Generator: Generate from class properties
快捷键
import 'dart:convert'; class Test { final String title; final bool status; final int num; Test({ required this.title, required this.status, required this.num, }); Test copyWith({ String? title, bool? status, int? num, }) { return Test( title: title ?? this.title, status: status ?? this.status, num: num ?? this.num, ); } Map<String, dynamic> toMap() { return { 'title': title, 'status': status, 'num': num, }; } factory Test.fromMap(Map<String, dynamic> map) { return Test( title: map['title'] ?? '', status: map['status'] ?? false, num: map['num']?.toInt() ?? 0, ); } String toJson() => json.encode(toMap()); factory Test.fromJson(String source) => Test.fromMap(json.decode(source)); @override String toString() => 'Test(title: $title, status: $status, num: $num)'; @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is Test && other.title == title && other.status == status && other.num == num; } @override int get hashCode => title.hashCode ^ status.hashCode ^ num.hashCode; }