avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
563 stars 303 forks source link

Unhandled Exception: Navigator operation requested with a context that does not include a Navigator #44

Closed mustela closed 5 years ago

mustela commented 5 years ago

Hey there! I'm using custom scheme and am testing on iOS Simulator which is: Version 11.0 (SimulatorApp-912.1 SimulatorKit-570.3 CoreSimulator-681.5.1)

Im trying to navigate to another view, but it is not working, this is the part of the code:

// Attach a second listener to the stream
    getUriLinksStream().listen((Uri uri) {
      print('got uri: ${uri?.path} ${uri?.queryParametersAll}');
      Navigator.push(
        context,
        MaterialPageRoute(builder: (context) => AcceptInvitation()),
      );

    }, onError: (err) {
      print('got err: $err');
    });

The full exception:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Navigator operation requested with a context that does not include a Navigator.
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.
#0      Navigator.of.<anonymous closure> (package:flutter/src/widgets/navigator.dart:1475:9)
#1      Navigator.of (package:flutter/src/widgets/navigator.dart:1482:6)
#2      Navigator.push (package:flutter/src/widgets/navigator.dart:1107:22)
#3      _BotAppState.initPlatformStateForUriUniLinks.<anonymous closure> (package:py/main.dart:58:17)
#4      _rootRunUnary (dart:async/zone.dart:1132:38)
#5      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#8      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
#9      _SinkTransformerStreamSubscription._add (dart:async/strea<…>

Any clue what Im doing wrong?

Thanks!

mustela commented 5 years ago

Forget about it, I moved the code to another widget and it's working now.

Faiyyaz commented 4 years ago

Hey @mustela how did you do that can you please give me some code or idea to follow because even i am having the exact same issue