GithubHelp home page GithubHelp logo

Comments (13)

huycozy avatar huycozy commented on June 10, 2024

Hi @ishchhabra
Perhaps this is similar to #137037 even though the case is not really the same (you can also check it to see if it assembles your case). To confirm this, could you clarify:

  • Does the issue occur if you start link A directly but not via link B?

from flutter.

ishchhabra avatar ishchhabra commented on June 10, 2024

@huycozy While the two seem similar, they are not exactly the same. The issue you mentioned talks about the builder being triggered twice, whereas this issue talks about even the redirect (which is mentioned as the workaround in that issue) being triggered twice. No, the issue does not occur if I start the link A directly - in that case, the redirect is only triggered once.

from flutter.

huycozy avatar huycozy commented on June 10, 2024

Your sample code has a minor issue (typo?) on /applinks route path, it should be /applink to sync with path data on AndroidManifest; otherwise no routes for location error will occur.

Once I updated it, I got another error below:

I/flutter (15789): /applinks route trigerred

════════ Exception caught by foundation library ════════════════════════════════
The following assertion was thrown while dispatching notifications for GoRouteInformationProvider:
A redirect-only route must redirect to location different from itself.
 The offending route: GoRoute#a104f(name: null, path: "/applink", Redirect Only)
'package:go_router/src/parser.dart':
Failed assertion: line 114 pos 18: '!matchList.last.route.redirectOnly'

Then I continued updating the route declaration as:

final _router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => const MyHomePage(title: 'Flutter Demo Home Page'),
    ),
    GoRoute(
      path: '/applink',
      builder: (context, state) => const MyHomePage(title: 'App Link'),
    ),
  ],
  redirect: (context, state) {
    if (state.matchedLocation == '/applink') {
      print("/applinks route trigerred");
      return '/applink';
    }
    return null;
  },
);

Now I can see the log applinks route trigerred is printed twice from the output console. But the issue also occurs if I trigger direct link with:

adb shell am start -a android.intent.action.VIEW "http://10.0.2.2:8020/applink"

With this result, this is similar to #137037, right? Please retry with this updated sample code and confirm. If your sample code needs to persist as the original, please update it to pass the error above. Thanks!

from flutter.

ishchhabra avatar ishchhabra commented on June 10, 2024

My bad, while trying to extract the minimal code from the application where I encountered this, I made some mistakes. I have updated the code. It is similar to the route declaration you mentioned above, but rather than using the global redirect, I added redirect only to the specific route. I also tried the route declaration you mentioned, but in both the cases, i did not see the console print twice on adb shell am start -a android.intent.action.VIEW "http://10.0.2.2:8020/applink" but only on adb shell am start -a android.intent.action.VIEW "http://10.0.2.2:8020". Are there OS or any other differences that could be relevant here as well?

from flutter.

huycozy avatar huycozy commented on June 10, 2024

Well, I pulled your latest change on your sample repo and ran it. I see the console printed only one time as expected (in both cases). I checked this on Android 11 emulator as yours (I see it from your flutter doctor ouput).

Demo
Screen.Recording.2024-05-08.at.12.36.40.mp4

Please take a look at my demo to see if there are any different steps.

from flutter.

ishchhabra avatar ishchhabra commented on June 10, 2024

That is weird. With the code on the sample repo, following is what I see:

windows_recording.mp4

from flutter.

huycozy avatar huycozy commented on June 10, 2024

The only different step I can observe between my and your demo is that: you triggered deep link when app was in foreground whilst I did it when app in background. I tried the same steps as yours but only one log is printed (expected).

Could you check go_router version which is fetched on your end? You can find it on pubspec.lock file. If you can try checking this without go_router package to narrow the scope of investigation, it would be appreciated.

from flutter.

ishchhabra avatar ishchhabra commented on June 10, 2024
  go_router:
    dependency: "direct main"
    description:
      name: go_router
      sha256: "9e0f7d1a3e7dc5010903e330fbc5497872c4c3cf6626381d69083cc1d5113c1e"
      url: "https://pub.dev"
    source: hosted
    version: "14.0.2"

The go_router version being pulled in 14.0.2. Could you elaborate on how I would check this without the go_router package? I'm not sure where the handler code (print statement) would go in case I'm not using go_router.

from flutter.

huycozy avatar huycozy commented on June 10, 2024

Thanks for the update. I see it's already the latest package version (same to me). You can test it without using go_router package like this:

Snippet code of route without using go_router
return MaterialApp(
  title: 'Flutter Demo',
  theme: ThemeData(
    colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
    useMaterial3: true,
  ),
  // routerConfig: _router,
  onGenerateRoute: (settings) {
    if (settings.name == '/applink') {
      print("/applink route triggered");
      return MaterialPageRoute(builder: (context) {
        return const MyHomePage(title: 'applink');
      });
    }
    return MaterialPageRoute(builder: (context) {
      return const MyHomePage(title: 'Flutter Demo Home Page');
    });
  },
);

from flutter.

ishchhabra avatar ishchhabra commented on June 10, 2024

Just tried with the code snippet you provided. The bug also exists without using go_router

from flutter.

huycozy avatar huycozy commented on June 10, 2024

Strangely, it only prints once with that same code (without go_router) on my end. I wonder if there is problem with device/emulator. Could you try on another one?

Also, what is your Python version? (I'm using Python 3.11.7). Could you check if Python server sends twice?

from flutter.

mako-yolo avatar mako-yolo commented on June 10, 2024

I have exactly the same issue.

from flutter.

github-actions avatar github-actions commented on June 10, 2024

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

from flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.