I don't know if i got the concept right for flutter and get_it as service locator. I wanna have MyApp in the service locator.
I have my main class
import 'di.dart' as di;
void main() {
WidgetsFlutterBinding.ensureInitialized();
di.init();
runApp(di.serviceLocator<MyApp>());
}
The di part should "assemble" the rest by itself. So in the di.dart i have
serviceLocator.registerLazySingleton<MyApp>(() => MyApp(widgets: serviceLocator()));
serviceLocator.registerLazySingleton<?whattoinserthere?>(() => [widget1, widget2, widget3, ...];
The MyApp class looks like
class MyApp extends StatelessWidget {
final List<StatelessWidget>? widgets;
const MyApp({super.key, this.widgets});
}
Since i wanna add widgets step by step while the application grows, i introduced a constructor param which is a list oft StatelessWidget ... when a new widget should be added, i wanna just add it to the list of widgets that is getting injected to the myApp widget
how to define this list in the di.dart, so that get_it can resolve it? The problem i see is, that List? is not a specific interface that is used as usually and therefore getting resolved to a concrete implementation.
What do i miss?