wiredashio / wiredash-sdk

Interactive user feedback tool for Flutter 🎉
https://pub.dev/packages/wiredash
Other
510 stars 65 forks source link

Using Feedback creates navigation error #364

Closed rlee1990 closed 5 days ago

rlee1990 commented 5 days ago

Describe the bug I am using DuckRouter. When I select the button to show the feedback window I get a navigator error. I also have the same issue using AutoRouter or go Router.

Stacktrace

The following assertion was thrown building HeroControllerScope:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3925 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.yml

The relevant error-causing widget was:
    MaterialApp MaterialApp:file:///Users/rickeylee/Desktop/test_chat/lib/main.dart:37:26

When the exception was thrown, this was the stack:
#2      NavigatorState._debugCheckDuplicatedPageKeys.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3925:18)
navigator.dart:3925
#3      NavigatorState._debugCheckDuplicatedPageKeys (package:flutter/src/widgets/navigator.dart:3930:6)
navigator.dart:3930
#4      NavigatorState._updatePages.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3993:7)
navigator.dart:3993
#5      NavigatorState._updatePages (package:flutter/src/widgets/navigator.dart:3996:6)
navigator.dart:3996
#6      NavigatorState.didUpdateWidget (package:flutter/src/widgets/navigator.dart:3911:7)
navigator.dart:3911
#7      StatefulElement.update (package:flutter/src/widgets/framework.dart:5789:55)
framework.dart:5789
#8      Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#9      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#10     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#11     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#12     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#14     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780:11)
framework.dart:5780
#15     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#16     StatefulElement.update (package:flutter/src/widgets/framework.dart:5803:5)
framework.dart:5803
#17     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#18     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#19     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#20     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#21     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#22     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#23     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#24     StatelessElement.update (package:flutter/src/widgets/framework.dart:5693:5)
framework.dart:5693
#25     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#26     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#27     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#28     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#29     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#30     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#31     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#32     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#33     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#34     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#35     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780:11)
framework.dart:5780
#36     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#37     StatefulElement.update (package:flutter/src/widgets/framework.dart:5803:5)
framework.dart:5803
#38     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#39     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#40     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#41     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#42     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#43     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#44     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#45     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#46     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#47     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#48     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#49     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#50     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#51     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#52     Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
framework.dart:5333
#53     ProxyElement.update (package:flutter/src/widgets/framework.dart:5946:5)
framework.dart:5946
#54     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#55     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)

Wiredash SDK Info version 2.2.2 iOS, Android, Web

Flutter SDK

[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0 24A335 darwin-arm64, locale en-US)
    • Flutter version 3.24.3 on channel stable at /Users/rickeylee/Desktop/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/rickeylee/Library/Android/sdk
    • Platform android-34-ext8, build-tools 34.0.0
    • ANDROID_HOME = /Users/rickeylee/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.94.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (7 available)
    • SM F926U (mobile)                              • RFCR802EMHY                          • android-arm64  • Android 13 (API 33)
    • iPhone 15 Pro Max (mobile)                     • 00008130-00125D660CFA001C            • ios            • iOS 18.0.1 22A3370
    • iPad Pro (12.9-inch) (5th generation) (mobile) • 00008101-000C1CE60E88801E            • ios            • iOS 18.0.1 22A3370
    • iPhone 16 Pro Max (mobile)                     • 32379A53-CA4D-4E45-B379-651D9A2AB8EC • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
    • macOS (desktop)                                • macos                                • darwin-arm64   • macOS 15.0 24A335 darwin-arm64
    • Mac Designed for iPad (desktop)                • mac-designed-for-ipad                • darwin         • macOS 15.0 24A335 darwin-arm64
    • Chrome (web)                                   • chrome                               • web-javascript • Google Chrome 129.0.6668.90

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Screenshots I created this simple repo that shows the issue. Repo

passsy commented 5 days ago

Thanks for this repro example, I already played around with it! I already know that the key key [<'/'>] ends up twice in Navigator.pages causing the crash. But I don't know why.

I'm unfamiliar with DuckRouter. I also don't see any active navigation code in your example. This leads me to belive it might be a bug in DuckRouter not handling nested navigation well.

I'm very familiar with GoRouter, could you push your go_router solution into a separate branch in the example?

rlee1990 commented 5 days ago

@passsy I will do that. Also the router.dart page is where my navigation code and also the navigate to the help page happens in the DrawerView page. I will let you know once the go router branch is up.

passsy commented 5 days ago

I was able to reduce your code to this tiny repro example. I can assure you that the bug is within duck_router, not in your code. I'll create an issue.

import 'package:duck_router/duck_router.dart';
import 'package:flutter/material.dart';
import 'package:wiredash/wiredash.dart';

void main() {
  runApp(const MyApp());
}

class HomeLocation extends Location {
  @override
  String get path => 'home';

  @override
  LocationBuilder? get builder => (context) => const Home();
}

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            Wiredash.of(context).show();
          },
          child: Text('Feedback'),
        ),
      ),
    );
  }
}

final router = DuckRouter(initialLocation: HomeLocation());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return Wiredash(
      projectId: '',
      secret: '',
      child: MaterialApp.router(
        title: 'Flutter Demo',
        routerConfig: router,
      ),
    );
  }
}
rlee1990 commented 5 days ago

Thanks @passsy I redid GoRouter and it is working. I will follow up with Duckrouter. I might have to use GoRouter. I was trying to avoid it

passsy commented 5 days ago

I'll close it because it is not actionable from the wiredash side.

Thanks again for reaching out!

JaspervanRiet commented 5 days ago

@rlee1990 This is fixed in duck_router 5.1.3 thanks to @passsy's detailed bug report!

rlee1990 commented 5 days ago

@JaspervanRiet Thank you