Instance Builder
Access Instance that registered by get_it inside UI widgets tree.// register instance
GetIt.instance.registerSingleton<LoginViewModel>(
LoginViewModel(),
// instanceName: 'my_instance', // optional, default is null
);
class LoginForm extends StatelessWidget {
const LoginForm({super.key});
@override
Widget build(BuildContext context) {
return InstanceBuilder<LoginViewModel>(
// instanceName: 'my_instance', // optional, default is null
builder: (LoginViewModel viewModel) {
/* access registered LoginViewModel in UI tree */
},
);
}
}