Issue running app on release mode in flutter web
Since upgrading to the latest version of stacked and using only stacked for routing and dependency injection I can't run the app on release mode in flutter web. I've added the error logs obtained from the web console. App works perfectly in debug mode.
main.dart.js:40167 Uncaught TypeError: Cannot read property 'cy' of null
at aNJ.a6L (main.dart.js:87425)
at aNJ.$1$3$instanceName$param1$param2 (main.dart.js:87427)
at aNJ.$3$instanceName$param1$param2 (main.dart.js:87430)
at aAv.$1$0 (main.dart.js:112800)
at Object.buV (main.dart.js:15228)
at main.dart.js:23709
at aZ6.a (main.dart.js:3939)
at aZ6.$2 (main.dart.js:39137)
at Object.n (main.dart.js:3925)
at Object.b_m (main.dart.js:23717)
What is cy referring too?
It's some variable in the generated dart code. Seems to be related to getIt, as it originates from the function that sets up the locators.
I have never used code_gen on web so I don't have any experience or insights there. Sorry about that, will get some soon when we build our web apps.
I have the same problem.
The stacked is not support on the web platform.

I replace the code
viewModelBuilder: () => locator<LobbyPageModel>(),withviewModelBuilder: () => LobbyPageModel(), , the problem is solved. It's related to getIt,but I do not what to do .
I am currently building a Flutter Web App with Stacked and faced this very same issue. Found the fix here (another currently open issue within this package at the time I am posting this comment). Hope it solves it for everyone. @hjue is somewhat right, it's related to an issue regarding the built-in locator in Stacked, and replacing it with the regular GetIt locator in app.locator.dart fixes it.
@BrylleGomez We will work on a fix for this soon.
I changed the code viewModelBuilder: () => locator<LobbyPageModel>() to viewModelBuilder: () => locator.get<LobbyPageModel>() ,Everything works fine.
@BrylleGomez @FilledStacks
Interesting. I'll keep that around to add into the docs.
I changed the code
viewModelBuilder: () => locator<LobbyPageModel>()toviewModelBuilder: () => locator.get<LobbyPageModel>(),Everything works fine.@BrylleGomez @FilledStacks
I can confirm that this fixes the issue.
I changed the code
viewModelBuilder: () => locator<LobbyPageModel>()toviewModelBuilder: () => locator.get<LobbyPageModel>(),Everything works fine.@BrylleGomez @FilledStacks
This is not solving the issue
ViewModelBuilder<LoginViewModel>.reactive( viewModelBuilder: () => locator.get<LoginViewModel>(), builder: (context, model, child) { return Container( margin: const EdgeInsets.only(top: 50), child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.only(left: 18.0, right: 18.0, top: 0), child: Container( decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(20.0)), child: SizedBox( width: double.infinity, height: 60, child: FlatButton( onPressed: () { _showModalBottomSheet(context); }, color: Colors.blue, child: Text( 'Create Account', style: Theme.of(context) .textTheme .headline6! .copyWith(color: Colors.white), ), ), ), ), ), Container( padding: const EdgeInsets.only(left: 18.0, right: 18.0, top: 20), decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0)), child: SizedBox( width: double.infinity, height: 60, child: OutlineButton( color: Colors.blue, child: Text( 'Sign in', style: Theme.of(context) .textTheme .headline6! .copyWith(color: Colors.blue), ), onPressed: () { _showModalBottomSheet(context); }, ), ), ), ], ), ); })
you can see that I used locator.get
And I also have this in my route defined LoginViewModel as dependency so it can be picked by locator @StackedApp(
routes: [
MaterialRoute(page: StartUpView, initial: true),
MaterialRoute(page: DashboardView),
MaterialRoute(page: SignUpFormView),
MaterialRoute(page: BusinessHomeView),
MaterialRoute(page: LoginView),
],
dependencies: [
LazySingleton(classType: NavigationService),
LazySingleton(classType: LoginViewModel)
],
)
class AppSetup {
/** Serves no purpose besides having an annotation attached to it */
}
Also, have the same issue had discussed with @jdaev about this issue in the email we realized that in the current stacked 2.0.4 the issue is not yet solved, your help is appreciated? @FilledStacks
@FilledStacks any support on this?
It's wired that on the master branch of flutter works fine!