Flutter
项目使用Getx
插件时,使用vscode
便利生成文件。
使用方法:
在vscode
用户设置,用户-扩展-GetX Creater
,输入author
在文件夹右键,选择[getx] creater
,使用大驼峰法输入类名,如ThisIsTest
,回车。
结果文件目录例如:
demo
>this_is_test
>>this_is_test_logic.dart
>>this_is_test_state.dart
>>this_is_test_view.dart
this_is_test_logic.dart
的内容为:
import 'package:get/get.dart';
import this_is_test_state.dart';
/// @description:
/// @author ${author}
/// @date: 2021/05/18 11:30:50
class ThisIsTestLogic extends GetxController {
final state = ThisIsTestState();
}
this_is_test_state.dart
的内容为:
/// @description:
/// @author
/// @date: 2021/05/18 11:30:50
class ThisIsTestState {
ThisIsTestState() {
///Initialize variables
}
}
this_is_test_view.dart
的内容为:
import this_is_test_logic.dart';
import this_is_test_state.dart';
/// @description:
/// @author
/// @date: 2021/05/18 11:30:50
class ThisIsTestPage extends StatelessWidget {
final ThisIsTestLogic logic = Get.put(ThisIsTestLogic());
final ThisIsTestState state = Get.find<ThisIsTestLogic>().state;
ThisIsTestPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold();
}
}