close
The Wayback Machine - https://web.archive.org/web/20211013235752/https://github.com/lukepighetti/fluro/issues/227
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

Open
pinpong opened this issue Mar 16, 2021 · 12 comments
Open

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

pinpong opened this issue Mar 16, 2021 · 12 comments

Comments

@pinpong
Copy link
Contributor

@pinpong 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 pinpong commented Mar 16, 2021

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

@getpu
Copy link

@getpu 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 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 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 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 pinpong commented May 12, 2021

@treeder
Copy link

@treeder treeder commented May 12, 2021

Did you make a pull request?

@pinpong
Copy link
Contributor Author

@pinpong 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 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?

@Nikhilkashid21
Copy link

@Nikhilkashid21 Nikhilkashid21 commented Jun 30, 2021

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

>')

@anujsaxenadev
Copy link

@anujsaxenadev anujsaxenadev commented Jul 9, 2021

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 pinpong commented Jul 10, 2021

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

Successfully merging a pull request may close this issue.

None yet
8 participants