如何从 Flutter Beamer 中的 2 个不同位置导航到同一页面

sul*_*der 7 navigation flutter

我的应用程序中有以下页面

  • 降落
  • 登录
  • 登记
  • 底部导航页面
  • 联系我们

我使用beamer 0.14.1进行导航

登陆页面有一个“联系我们”按钮,应该打开 contact_us 页面,并且在底部导航(在“更多”选项卡中)有一个“联系我们”按钮,目前我的投影仪导航如下所示

class StartingLocation extends BeamLocation {
  @override
  List<String> get pathBlueprints => ['/'];

  @override
  List<BeamPage> buildPages(BuildContext context, BeamState state) => [
        BeamPage(
          key: ValueKey('landing'),
          child: LandingPage(),
        ),
      ];
}
Run Code Online (Sandbox Code Playgroud)
class LandingLocation extends BeamLocation {
  @override
  List<String> get pathBlueprints => [
    '/login'
    '/registration'
    '/contactUs',
    ];

  @override
  List<BeamPage> buildPages(BuildContext context, BeamState state) => [
        ...StartingLocation().buildPages(context, state),
        if (state.uri.pathSegments.contains('login'))
          BeamPage(
            key: ValueKey('login'),
            child: LoginPage(),
          ),
        if (state.uri.pathSegments.contains('registration'))
          BeamPage(
            key: ValueKey('registration'),
            child: RegistrationPage(),
          ),
        if (state.uri.pathSegments.contains('contactUs'))
          BeamPage(
            key: ValueKey('contactUs'),
            child: ContactUsPage(),
          ),
      ];
}
Run Code Online (Sandbox Code Playgroud)
class NavigationLocation extends BeamLocation {
  @override
  List<String> get pathBlueprints => [
        '/navigation',
        '/navigation/notifications',
        '/navigation/profile',
    ];

  @override
  List<BeamPage> buildPages(BuildContext context, BeamState state) => [
        ...LandingLocation().buildPages(context, state),
        if (state.uri.pathSegments.contains('navigation'))
          BeamPage(
            key: ValueKey('navigation'),
            child: NavigationPage(),
          ),
        if (state.uri.pathSegments.contains('notifications'))
          BeamPage(
            key: ValueKey('notifications'),
            child: NotificationsPage(),
          ),
        if (state.uri.pathSegments.contains('profile'))
          BeamPage(
            key: ValueKey('profile'),
            child: ProfilePage(),
          ),
      ];
}
Run Code Online (Sandbox Code Playgroud)

在登陆页面中,我使用此代码打开“联系我们”页面onPressed: () => context.beamToNamed('/contactUs'),,它工作正常,但是当我在“更多”页面中使用相同的代码时,它会抛出此错误:

======== Exception caught by widgets library =======================================================
The following assertion was thrown building Builder:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3619 pos 18: '!keyReservation.contains(key)': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

The relevant error-causing widget was: 
  MaterialApp file:///Users/username/FlutterProjects/project_name/lib/main.dart:88:28
When the exception was thrown, this was the stack: 
#2      NavigatorState._debugCheckDuplicatedPageKeys.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3619:18)
#3      NavigatorState._debugCheckDuplicatedPageKeys (package:flutter/src/widgets/navigator.dart:3624:6)
#4      NavigatorState._updatePages.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3659:7)
#5      NavigatorState._updatePages (package:flutter/src/widgets/navigator.dart:3662:6)
#6      NavigatorState.didUpdateWidget (package:flutter/src/widgets/navigator.dart:3606:7)
...
====================================================================================================

Run Code Online (Sandbox Code Playgroud)