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

Implementing showDialog? #5

Closed
mistyn8 opened this issue Apr 23, 2020 · 7 comments
Closed

Implementing showDialog? #5

mistyn8 opened this issue Apr 23, 2020 · 7 comments

Comments

@mistyn8
Copy link

mistyn8 commented Apr 23, 2020

Can't seem to get this working...

Amends....
locator.icondig.dart (although it says not to amend as generated....)

g.registerLazySingleton<DialogService>(() => DialogService());

home_viewmodel.dart

import 'package:new_architecture/app/locator.dart';
import 'package:new_architecture/services/dialog_service.dart';

final DialogService _dialogService = locator<DialogService>();
 Future showD() async{
    await _dialogService.showDialog(
          title: 'A Dialog',
          description: 'General Dialogue',
        );
  }

home_view.dart

floatingActionButton: FloatingActionButton(
          onPressed: () {
            // Navigator.of(context).push(MaterialPageRoute(
            //   builder: (context) => StartupView(),
            // ));
            model.showD();
          },
        ),

but errors with

Restarted application in 1,911ms.
I/flutter (17729): HomeViewModel created
I/flutter (17729): HomeViewModel initialise
E/flutter (17729): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'dependOnInheritedWidgetOfExactType' was called on null.
E/flutter (17729): Receiver: null
E/flutter (17729): Tried calling: dependOnInheritedWidgetOfExactType<_InheritedTheme>()
�[38;5;244mE/flutter (17729): #0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:53:5)�[39;49m
�[38;5;244mE/flutter (17729): #1      Theme.of�[39;49m
�[38;5;248mE/flutter (17729): #2      Get.dialog�[39;49m
�[38;5;248mE/flutter (17729): #3      DialogService.showDialog�[39;49m
�[38;5;248mE/flutter (17729): #4      HomeViewModel.showD�[39;49m
�[38;5;248mE/flutter (17729): #5      HomeView.build.<anonymous closure>.<anonymous closure>�[39;49m
�[38;5;244mE/flutter (17729): #6      _InkResponseState._handleTap�[39;49m
�[38;5;244mE/flutter (17729): #7      _InkResponseState.build.<anonymous closure>�[39;49m
�[38;5;244mE/flutter (17729): #8      GestureRecognizer.invokeCallback�[39;49m
�[38;5;244mE/flutter (17729): #9      TapGestureRecognizer.handleTapUp�[39;49m
�[38;5;244mE/flutter (17729): #10     BaseTapGestureRecognizer._checkUp�[39;49m
�[38;5;244mE/flutter (17729): #11     BaseTapGestureRecognizer.handlePrimaryPointer�[39;49m
�[38;5;244mE/flutter (17729): #12     PrimaryPointerGestureRecognizer.handleEvent�[39;49m
�[38;5;244mE/flutter (17729): #13     PointerRouter._dispatch�[39;49m
�[38;5;244mE/flutter (17729): #14     PointerRouter._dispatchEventToRoutes.<anonymous closure>�[39;49m
�[38;5;244mE/flutter (17729): #15     _LinkedHashMapMixin.forEach  (dart:collection-patch/compact_hash.dart:379:8)�[39;49m
�[38;5;244mE/flutter (17729): #16     PointerRouter._dispatchEventToRoutes�[39;49m
�[38;5;244mE/flutter (17729): #17     PointerRouter.route�[39;49m
�[38;5;244mE/flutter (17729): #18     GestureBinding.handleEvent�[39;49m
�[38;5;244mE/flutter (17729): #19     GestureBinding.dispatchEvent�[39;49m
�[38;5;244mE/flutter (17729): #20     GestureBinding._handlePointerEvent�[39;49m
�[38;5;244mE/flutter (17729): #21     GestureBinding._flushPointerEventQueue�[39;49m
�[38;5;244mE/flutter (17729): #22     GestureBinding._handlePointerDataPacket�[39;49m
�[38;5;244mE/flutter (17729): #23     _rootRunUnary  (dart:async/zone.dart:1138:13)�[39;49m
�[38;5;244mE/flutter (17729): #24     _CustomZone.runUnary  (dart:async/zone.dart:1031:19)�[39;49m
�[38;5;244mE/flutter (17729): #25     _CustomZone.runUnaryGuarded  (dart:async/zone.dart:933:7)�[39;49m
�[38;5;244mE/flutter (17729): #26     _invoke1  (dart:ui/hooks.dart:273:10)�[39;49m
�[38;5;244mE/flutter (17729): #27     _dispatchPointerDataPacket  (dart:ui/hooks.dart:182:5)�[39;49m
E/flutter (17729):

Referring back to provider_architecture approach and the dialog_service there is different with a dialog_manager? So can't work out what might need amending...

Cheers.

PS also had to be on Stable flutter Channel for it to work with get package without changing get version.
dependencies:
get: ^1.17.3 // ^1.20.1-dev on beta/dev/master

@FilledStacks
Copy link
Contributor

The example is using injectable which you don't have to use. If you do you still have to run the builder to generate the service registration code.

Seems like you're mixing up some stuff here. provider_architecture is the exact same as this package there's just some extra functionality in here and name changes. So how ever you did it with Provider package you can do the same with this one. No need to use injectable if you don't want to.

@mistyn8
Copy link
Author

mistyn8 commented Apr 23, 2020

So I'm brand new to this... apart from watching the tutorials...
So starting with stacked and the example in there.

I assumed that the example was now the best practise starting point.. so was simply trying to add a dialog using the dialog service already in there.

got stuck.. so then as it was intimated there wasn't any changes other than naming referred back to the provider_architecture example... which is as you say not using injectable.. or get so got a little confused. :-)

@FilledStacks
Copy link
Contributor

No the example is definitely not a best practice of any kind. It's simply examples of how to use the widgets in the package. This is not a good place to start. I would say you should watch this video which is where the architecture comes from and where the package comes from. Then you can follow along with my Firebase series to understand how to use provider_architecture.

Get_it or injectable, or get has nothing to do with the provider_architecture or stacked. Those are extra libraries we use for other parts of the architecture like navigation and showing dialogs. If you don't know how to use the DialogService you can watch my video on it, the video is a bit out dated but you could figure out if you actually want to use it like that. I use get for the dialog service completely now.

I'd say if you go through my web series or my firebase series you'll see how the provider_architecture package is used. Then you install stacked and rename the classes since it's the same.

@mistyn8
Copy link
Author

mistyn8 commented Apr 23, 2020

confused even more now then.. so the example folder in stacked which includes a dialog_service.dart isn't usable?
ps just tried the build from injectable and it added the dialog_service in.. but still same error shows when clicking the button I'd added the showDialog too :-)

But ok I will revert to example(s) from provider_architecture that don't use get/injectable and just as you say refactor to stacked.
(though get and injectable look good!! for offsetting more CRUD)

thanks kindly for you words of wisdom. :-)

@FilledStacks
Copy link
Contributor

The dialog service is usable. The key for get hasn't been set in the material app. You can set it and run the builder and it should work fine. But it's not an example of how to build an entire app with it.

Also the examples are copied from provider_architecture so you'll see the same code apart from the added new functionality.

@mistyn8
Copy link
Author

mistyn8 commented Apr 23, 2020

You beat me to it,,, Was just about to post.. navigatorKey: Get.key, needed in MyApp after reading the get instructions... ;-) and a rebuild for injectable.

Are we talking about the same example here?

https://github.com/FilledStacks/stacked/tree/master/example/lib
vs
https://github.com/FilledStacks/provider_architecture/tree/master/example/lib

they aren't similar in a few ways, structure, no dialog_manager, services? enough to confuse me anyways...

Thanks again for entertaining and responding to my queries.

@FilledStacks
Copy link
Contributor

You're very welcome :) Happy to shed any light. The example folder structure is a bit different but I copied the view files as is with their viewmodels for the examples and just updated the naming.

I'm busy with the first videos written tutorial now. I'm hoping I can release it today. It's 8:40 AM here 26 April. I think I should be able to do the package updates, write a written tutorial, record and edit a video and upload it in 12 hours. Otherwise the video has to wait until next week :)

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

2 participants