-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Description
Hi, I found an uncertain problem!
Problem description:
I expect to use
Navigator.of(context).pop<String>to return a value of a certain type, but the result is always a value of dynamic type.
Code:
// First screen
Navigator.of(context).pushNamed<String>('login').then((String result){
print('login.result runtimeType: ${result.runtimeType}');
});
// Second screen
Navigator.of(context).pop<String>('success');A type error will occur in the above code:
E/flutter (16614): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'MaterialPageRoute<dynamic>' is not a subtype of type 'Route<String>' in type cast
E/flutter (16614): #0 NavigatorState._routeNamed (package:flutter/src/widgets/navigator.dart:3138:55)
E/flutter (16614): #1 NavigatorState.pushNamed (package:flutter/src/widgets/navigator.dart:3190:20)
E/flutter (16614): #2 _Transfer.build.<anonymous closure> (package:example/views/FirstScreen.dart:157:55)
E/flutter (16614): #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (16614): #4 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter (16614): #5 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (16614): #6 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:254:7)
E/flutter (16614): #7 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (16614): #8 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (16614): #9 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (16614): #10 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (16614): #11 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (16614): #12 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (16614): #13 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter (16614): #14 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (16614): #15 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (16614): #16 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter (16614): #17 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
E/flutter (16614): Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue