stacked icon indicating copy to clipboard operation
stacked copied to clipboard

Issue running app on release mode in flutter web

Open javdhu opened this issue 5 years ago • 15 comments

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)

javdhu avatar Mar 10 '21 23:03 javdhu

What is cy referring too?

FilledStacks avatar Mar 11 '21 02:03 FilledStacks

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.

javdhu avatar Mar 11 '21 02:03 javdhu

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.

FilledStacks avatar Mar 11 '21 03:03 FilledStacks

I have the same problem. The stacked is not support on the web platform. image

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 .

hjue avatar Mar 22 '21 10:03 hjue

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 avatar Mar 30 '21 13:03 BrylleGomez

@BrylleGomez We will work on a fix for this soon.

FilledStacks avatar Apr 01 '21 12:04 FilledStacks

I changed the code viewModelBuilder: () => locator<LobbyPageModel>() to viewModelBuilder: () => locator.get<LobbyPageModel>() ,Everything works fine.

@BrylleGomez @FilledStacks

hjue avatar Apr 06 '21 02:04 hjue

Interesting. I'll keep that around to add into the docs.

FilledStacks avatar Apr 12 '21 16:04 FilledStacks

I changed the code viewModelBuilder: () => locator<LobbyPageModel>() to viewModelBuilder: () => locator.get<LobbyPageModel>() ,Everything works fine.

@BrylleGomez @FilledStacks

I can confirm that this fixes the issue.

javdhu avatar Apr 12 '21 18:04 javdhu

I changed the code viewModelBuilder: () => locator<LobbyPageModel>() to viewModelBuilder: () => 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); }, ), ), ), ], ), ); })

realhackg25 avatar Apr 16 '21 07:04 realhackg25

you can see that I used locator.get() but still I can not get the app to work in release mode, NOTE that in debug mode works fine @FilledStacks

realhackg25 avatar Apr 16 '21 07:04 realhackg25

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 */ }

realhackg25 avatar Apr 16 '21 07:04 realhackg25

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

richard457 avatar Apr 16 '21 17:04 richard457

@FilledStacks any support on this?

richard457 avatar Apr 18 '21 20:04 richard457

It's wired that on the master branch of flutter works fine!

richard457 avatar Apr 24 '21 05:04 richard457