Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bottom Navigation Bar Issues #95

Open
akyjoe opened this issue Aug 7, 2020 · 0 comments
Open

Bottom Navigation Bar Issues #95

akyjoe opened this issue Aug 7, 2020 · 0 comments

Comments

@akyjoe
Copy link

akyjoe commented Aug 7, 2020

We were able to use Bottom navigation bar, by adding parent view "HomeView" in which we are calling all the child views. Views are working just fine.

Now the issue is about the DataService is been called each time, on swap of views. Below is our code for locator.dart

locator.registerLazySingleton(() => DialogService());
locator.registerLazySingleton(() => NavigationService());
locator.registerLazySingleton(() => AuthenticationService());
locator.registerLazySingleton(() => DataService()); 

locator.registerSingleton<ViewModel1>(ViewModel1());
locator.registerSingleton<ViewModel2>(ViewModel2());
locator.registerSingleton<ViewModel3>(ViewModel3());

In the view we have added initialiseSpecialViewModelsOnce: true viewModelBuilder: () => locator<ViewModel1>() as well.

When we execute:

flutter: Error while creating DataService
flutter: Stack trace:
 #0      defaultBinaryMessenger.<anonymous closure> (package:flutter/src/services/binary_messenger.dart:76:7)
#1      defaultBinaryMessenger (package:flutter/src/services/binary_messenger.dart:89:4)
#2      MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:140:62)
#3      MethodChannel.setMethodCallHandler (package:flutter/src/services/platform_channel.dart:375:5)
#4      new MethodChannelFirestore (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:27:13)
#5      FirestorePlatform.instance (package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart:63:19)
#6      new Firestore (package:cloud_firestore/src/firestore.dart:26:42)
#7      Firestore.instance (package:cloud_firestore/src/firestore.dart:29:36)
#8      new DataService (package:Vaccine/app/service/data.dart:14:67)
#9      setupLocator.<anonymous closure> (package:Vaccine/app/locator.dart:21:39)
#10     _ServiceFactory.getObject (package:get_it/get_it_impl.dart:128:40)
#11     _GetItImplementation.get (package:get_it/get_it_impl.dart:276:34)
#12     _GetItImplementation.call (package:get_it/get_it_impl.dart:288:12)
#13     new AuthenticationService (package:Vaccine/app/service/auth.dart:10:43)
#14     setupLocator.<anonymous closure> (package:Vaccine/app/locator.dart:19:39)
#15     _ServiceFactory.getObject (package:get_it/get_it_impl.dart:128:40)
#16     _GetItImplementation.get (package:get_it/get_it_impl.dart:276:34)
#17     _GetItImplementation.call (package:get_it/get_it_impl.dart:288:12)
#18     new ScheduleScreenModel (package:Vaccine/app/screenmodels/view_model_1.dart:14:63)
#19     setupLocator (package:Vaccine/app/locator.dart:24:50)
#20     main (package:Vaccine/main.dart:9:3)
#21     _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:241:25)
#22     _rootRun (dart:async/zone.dart:1184:13)
#23     _CustomZone.run (dart:async/zone.dart:1077:19)
#24     _runZoned (dart:async/zone.dart:1619:10)
#25     runZonedGuarded (dart:async/zone.dart:1608:12)
#26     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:233:5)
#27     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#28     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
flutter: Error while creating AuthenticationService
flutter: Stack trace:
 #0      defaultBinaryMessenger.<anonymous closure> (package:flutter/src/services/binary_messenger.dart:76:7)
#1      defaultBinaryMessenger (package:flutter/src/services/binary_messenger.dart:89:4)
#2      MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:140:62)
#3      MethodChannel.setMethodCallHandler (package:flutter/src/services/platform_channel.dart:375:5)
#4      new MethodChannelFirestore (package:cloud_firestore_platform_interface/src/method_channel/method_channel_firestore.dart:27:13)
#5      FirestorePlatform.instance (package:cloud_firestore_platform_interface/cloud_firestore_platform_interface.dart:63:19)
#6      new Firestore (package:cloud_firestore/src/firestore.dart:26:42)
#7      Firestore.instance (package:cloud_firestore/src/firestore.dart:29:36)
#8      new DataService (package:Vaccine/app/service/data.dart:14:67)
#9      setupLocator.<anonymous closure> (package:Vaccine/app/locator.dart:21:39)
#10     _ServiceFactory.getObject (package:get_it/get_it_impl.dart:128:40)
#11     _GetItImplementation.get (package:get_it/get_it_impl.dart:276:34)
#12     _GetItImplementation.call (package:get_it/get_it_impl.dart:288:12)
#13     new AuthenticationService (package:Vaccine/app/service/auth.dart:10:43)
#14     setupLocator.<anonymous closure> (package:Vaccine/app/locator.dart:19:39)
#15     _ServiceFactory.getObject (package:get_it/get_it_impl.dart:128:40)
#16     _GetItImplementation.get (package:get_it/get_it_impl.dart:276:34)
#17     _GetItImplementation.call (package:get_it/get_it_impl.dart:288:12)
#18     new ScheduleScreenModel (package:Vaccine/app/screenmodels/view_model_1.dart:14:63)
#19     setupLocator (package:Vaccine/app/locator.dart:24:50)
#20     main (package:Vaccine/main.dart:9:3)
#21     _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:241:25)
#22     _rootRun (dart:async/zone.dart:1184:13)
#23     _CustomZone.run (dart:async/zone.dart:1077:19)
#24     _runZoned (dart:async/zone.dart:1619:10)
#25     runZonedGuarded (dart:async/zone.dart:1608:12)
#26     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:233:5)
#27     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#28     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Code for view_mode_1.dart 14:63 is:

final AuthenticationService _authenticationService = locator<AuthenticationService>();
final DataService _dataService = locator<DataService>();

Kindly suggest how to rectify this?

Originally posted by @akyjoe in #86 (comment)

Other issue is, how can we switch BottomNavigationBar tabs programmatically or by tapping any button in current view?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant