feat: implement InjectGenerator

This commit is contained in:
Sergey Penkovsky
2025-05-23 14:08:08 +03:00
parent 1f6ee172a1
commit 9c42ba4cef
5 changed files with 55 additions and 26 deletions

View File

@@ -11,14 +11,22 @@ part 'app.inject.cherrypick.g.dart';
@injectable()
class MyApp extends StatelessWidget with _$MyApp {
final Scope scope;
final _appRouter = AppRouter();
@scope('authZone')
@inject()
late final String text;
@scope('authZone')
@named('timeout')
@inject()
late final int timeout;
@named('repo')
@inject()
late final PostRepository repository;
MyApp({super.key, required this.scope});
MyApp({super.key});
@override
Widget build(BuildContext context) {

View File

@@ -4,8 +4,6 @@ import 'package:postly/app.dart';
import 'di/app_module.dart';
void main() {
final scope = CherryPick.openRootScope();
scope.installModules([$AppModule()]);
runApp(MyApp(scope: scope));
CherryPick.openRootScope().installModules([$AppModule()]);
runApp(MyApp());
}