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

type 'Null' is not a subtype of type 'Handler' #227

Closed
pinpong opened this issue Mar 16, 2021 · 13 comments
Closed

type 'Null' is not a subtype of type 'Handler' #227

pinpong opened this issue Mar 16, 2021 · 13 comments
Labels
good first issue This is a good issue for someone who wants their contributor's badge needs docs Should be included in the documentation or needs changes to the documentation.

Comments

@pinpong
Copy link
Contributor

pinpong commented Mar 16, 2021

Got this issue when compile null safety with flutter 2.0.2.

flutter: type 'Null' is not a subtype of type 'Handler'

flutter:

flutter: The relevant error-causing widget was:

flutter:   MaterialApp

flutter:

flutter: When the exception was thrown, this was the stack:

flutter: #0      FluroRouter.matchRoute (package:fluro/src/fluro_router.dart:143:13)

flutter: #1      FluroRouter.generator (package:fluro/src/fluro_router.dart:278:9)
@pinpong
Copy link
Contributor Author

pinpong commented Mar 16, 2021

Also the example needs to be updated and migrate to null safety.

@getpu
Copy link

getpu commented Mar 18, 2021

======== Exception caught by gesture ===============================================================
The following _TypeError was thrown while handling a gesture:
type 'Null' is not a subtype of type 'Handler'

When the exception was thrown, this was the stack:
#0 FluroRouter.matchRoute (package:fluro/src/fluro_router.dart:143:13)

I also in version 2.0.3, how to repair...

@agarzas
Copy link

agarzas commented Apr 15, 2021

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _TypeError was thrown building IconTheme(color: Color(0xdd000000)):
type 'Null' is not a subtype of type 'Handler'

The relevant error-causing widget was:
  MaterialApp file:///Users/agarzas/Development/app/lib/main.dart:93:20

When the exception was thrown, this was the stack:
#0      FluroRouter.matchRoute (package:fluro/src/fluro_router.dart:143:13)
#1      FluroRouter.generator (package:fluro/src/fluro_router.dart:278:9)
#2      _WidgetsAppState._onGenerateRoute (package:flutter/src/widgets/app.dart:1212:37)
#3      NavigatorState._routeNamed (package:flutter/src/widgets/navigator.dart:4133:46)
#4      Navigator.defaultGenerateInitialRoutes (package:flutter/src/widgets/navigator.dart:2783:28)
#5      NavigatorState.restoreState (package:flutter/src/widgets/navigator.dart:3418:41)
#6      RestorationMixin._doRestore (package:flutter/src/widgets/restoration.dart:982:5)
#7      RestorationMixin.didChangeDependencies (package:flutter/src/widgets/restoration.dart:968:7)
#8      NavigatorState.didChangeDependencies (package:flutter/src/widgets/navigator.dart:3464:11)
#9      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4653:11)
#10     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4469:5)
...     Normal element mounting (92 frames)
#102    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3541:14)
#103    Element.updateChild (package:flutter/src/widgets/framework.dart:3303:20)
#104    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4520:16)
#105    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)
#106    Element.rebuild (package:flutter/src/widgets/framework.dart:4189:5)
#107    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2694:33)
#108    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:873:21)
#109    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:319:5)
#110    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#111    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1082:9)
#112    SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:865:7)
(elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)

same here, fluro: ^2.0.3

Flutter 2.0.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b1395592de (2 weeks ago) • 2021-04-01 14:25:01 -0700
Engine • revision 2dce47073a
Tools • Dart 2.12.2

@luffyjie
Copy link

luffyjie commented Apr 27, 2021

I use dev null-safety channel use 2.0.3 latest version meet the same error. Where is the bad way I used? I can't find from my codes.
-----update--
I solved this issue.
when I in main.dart I create final router = FluroRouter() than I pass this instance to Routes.configureRouters() I get the issue.
but just I try final router = FluroRouter.appRouter; it works now.
So it tell us we should use FluroRouter.appRouter not to create instance ourselves.
try it.

@treeder
Copy link

treeder commented May 12, 2021

Finally figured this out, it's the notFoundHandler, had to add this:

    router.notFoundHandler = Handler(
        handlerFunc: (BuildContext? context, Map<String, dynamic> params) {
      return NotFoundPage();
    });

@pinpong
Copy link
Contributor Author

pinpong commented May 12, 2021

@treeder
Copy link

treeder commented May 12, 2021

Did you make a pull request?

@pinpong
Copy link
Contributor Author

pinpong commented May 12, 2021

Not using fluor anymore an i think this is not the only issue with null safety refactoring.

@treeder
Copy link

treeder commented May 12, 2021

Seems to be fine otherwise, but might be some things I haven't run into.

What are you using now?

@lukepighetti lukepighetti added good first issue This is a good issue for someone who wants their contributor's badge needs docs Should be included in the documentation or needs changes to the documentation. labels Jun 11, 2021
@Nikhilkashid21
Copy link

Exception has occurred.
_TypeError (type 'Null' is not a subtype of type 'FutureOr<List

>')

@anujsaxenadev
Copy link

I had the same issue with Fluro when implementing Flutter Add2App. This issue was happening to me in runtime. I spent several hours trying to find the solution to this issue.

Here are my findings -
When I was opening the flutter app it is opening the home route (“/") first. I haven’t defined this route with some handler that’s why this issue was there.

The issue was occurring on the “mathRoute” function in FluroRouter Code on this line -

Handler handler = (route != null ? route.handler : notFoundHandler);

here I was getting
route = “/“
and route.handler = null

so because the Handler is a not nullable type this error was appearing.

So It is just like working with a web URL so, whatever be my “initial route” say “/about”, it will open the home route(“/“) first then the "about" route

If you want to know more you can check the “defaultGenerateInitialRoutes” function in the navigator class. Nice documentation is there to explain all of this.

To solve this for now I ended up setting my initial route as the home route(“/“).

@pinpong
Copy link
Contributor Author

pinpong commented Jul 10, 2021

pinpong@e228f61

@csparedes
Copy link

Hey guys
I have the new issue, related with Flurorouter

static final notFound = Handler(handlerFunc: ((context, parameters) { return const NotFoundPage(); }));
This is in other document:
router.notFoundHandler = MyFluroHandlers.notFound;

Flutter 3.0.5 used to work, but now I've tried it on a new project, but it doesn't work.

I really love Flutter, but I'm considering quitting it.

Any ideas to save this fabulous plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is a good issue for someone who wants their contributor's badge needs docs Should be included in the documentation or needs changes to the documentation.
Projects
None yet
Development

No branches or pull requests

9 participants