content property
Store the content that will be written to the file in a String or Future
Implementation
@override
String get content => '''$import
abstract class BasePage<C extends BaseController<T>, T extends BaseState>
extends StatefulWidget implements AutoRouteWrapper {
const BasePage({
Key? key,
}) : super(key: key);
Widget builder(BuildContext context);
void onInitState(BuildContext context) {}
C buildController() {
return getIt<C>();
}
@override
Widget wrappedRoute(BuildContext context) {
return StateNotifierProvider<C, T>(
create: (_) => buildController(),
builder: (_, __) => this,
);
}
@override
State<BasePage> createState() => _BasePageState<C, T>();
}
class _BasePageState<C extends BaseController, T extends BaseState>
extends State<BaseScreen> {
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
context.read<C>().loadData().then((e) {
if (e != null) {
getIt<ErrorDialog>().show(context, e.title, e.message);
}
});
});
widget.onInitState(context);
super.initState();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Selector<T, ScreenStatus>(
selector: (context, state) => state.screenStatus,
builder: (_, viewState, __) {
if (viewState == ScreenStatus.uninitialized) {
return const UninitializedWidget();
} else {
return Stack(
children: [
Scaffold(
backgroundColor: Colors.black38,
body: widget.builder(context),
),
Selector<T, bool>(
builder: (_, processing, __) {
if (processing) {
getIt<LoadingDialog>().show(context);
} else {
getIt<LoadingDialog>().hide();
}
return const SizedBox();
},
selector: (_, state) => state.processing)
],
);
}
},
),
);
}
}
''';