Fatima Hossny
Fatima Hossny

Reputation: 1297

The method 'dependOnInheritedWidgetOfExactType' was called on null fluro

I'm trying to initialize fluro navigation for my app, but I always get this issue The method 'dependOnInheritedWidgetOfExactType' was called on null. and this The relevant error-causing widget was: I/flutter ( 4553): MaterialApp here is my main :

void main() {
  Application.router = Router();
  Application.configureRoutes();
  runApp(App());
}

and my my App widget :

class App extends StatefulWidget {
  @override
  _AppState createState() => _AppState();
}

    class _AppState extends State<App> {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'myApp',
          debugShowCheckedModeBanner: true,
          theme: ThemeData(
              primarySwatch: Colors.blue,
              primaryTextTheme: TextTheme(body1: TextStyle(letterSpacing: 0.9))),
          onGenerateRoute: Application.router.generator,
        );
      }
    }

and use these classes to configure fluro:

class Application {
  static Router router;

  static void configureRoutes() {
    router.notFoundHandler = Handler(
        handlerFunc: (BuildContext context, Map<String, List<dynamic>> params) {
      print("ROUTE WAS NOT FOUND !!!");
      return Container(
        child: Center(
          child: Text("ROUTE WAS NOT FOUND !!!"),
        ),
      );
    });
    router.define(Routes.root,
        handler: Handlers.rootHandler, transitionType: TransitionType.native);
  }
}

and this for routes :

class Routes {
  static String root = "/";
}

and this for handlers:

class Handlers {
  static Handler rootHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<dynamic>> params) {
      return Container(color: Colors.blue,);
    },
  );
}

I have no idea where this comes from I tried to add key for MaterialApp but in vain.

any help is very appreciated.

Upvotes: 2

Views: 5025

Answers (2)

EdYuTo
EdYuTo

Reputation: 6874

I just came across this issue, but in my case, I really needed to use the transitionType because I wanted it as transitionType: TransitionType.nativeModal.

My solution to make it work was simply to downgrade fluro to version 1.5.1.

Upvotes: 1

user13133214
user13133214

Reputation: 21

I also ran into this issue. According to https://github.com/theyakka/fluro/issues/154

transitionType: TransitionType.native

This part seems to be the cause. In my case, it works if I removed this part.

Upvotes: 2

Related Questions