FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
121 stars 18 forks source link

GoError: The parent route must be a page route to have a GoRouterState #2958

Open isegal opened 4 months ago

isegal commented 4 months ago

Has your issue been reported?

Current Behavior

The code that is generated for the Global Property -> "Link To Corrent Page does not work when invoked inside a component that is part of a bottom sheet.

The generated code is:

GoRouterState.of(context).uri.toString()

This causes the widget to crash due to the new Go Router breaking changes.

See: https://github.com/flutter/flutter/issues/131154

Manually patching the generated code to the following makes the problem go away:

GoRouter.of(context).getCurrentLocation()

Expected Behavior

It should not crash. The variable should return a link to current page.

Steps to Reproduce

  1. Enable deep linking
  2. Create a component
  3. Create a custom function that takes a string.
  4. Invoke the custom function, and provide the variable as Global Property -> "Link To Corrent Page
  5. Add a bottom sheet that opens the component
  6. Add a button that opens the bottom sheet

Reproducible from Blank

Bug Report Code (Required)

IT40hcnfz5Fgod9c1rrUK/lahmU5JlN9RI0Nke57aCgofePtOol3evXsUFBtZMumS2xiMUSmmT4d+d6NiISTG8ABNTidc4hE+qpUEQ6UWl6ha5OBBs2WbX98HZ5hCnXD4bbQsBB4GPB2c1oFw12MGeqQdDLYN7WxImdISq/LZO4=

Context

Before the GoRouter upgrade, there was no crash. Currently it makkes our app not acceptible for production release.

Visual documentation

Screenshot 2024-05-21 at 1 37 56 PM

Additional Info

Have the dev team take a look at the snippets I posted above. It might be a quick fix.

Environment

- FlutterFlow version: Latest
- Platform: all
- Browser name and version: N/A
- Operating system and version affected: all

General

Relative to the time the changes were made, data was lost within

When following my steps to reproduce, data loss happens

ignalauret commented 4 months ago

Hey @isegal thanks for your report. I can confirm that an error occurs when I replicate your steps. Now, I don't know if this is a wrong implementation, and there is another way to do it, or it's an actual bug. I will send this to our technical team so they can clarify the situation, they will keep you updated on this thread. Have a great day!

jazzedge24 commented 4 months ago

I can confirm the issue with an existing application which until the update worked correctly.

jazzedge24 commented 3 months ago

Any indication of when this "unknown" issue might be addressed?

isegal commented 2 weeks ago

@FlutterFlowEng we still see this issue, others have confirmed. Are there any concerns or anything preventing the team to apply the fix?

isegal commented 3 days ago

@FlutterFlowEng we have confirmed that the one-liner works in production.

The code that FF generates appears to be the wrong (old way) to get the URI and can grey-screen in some scenarios:

GoRouterState.of(context).uri.toString()

This is the correct way:

GoRouter.of(context).getCurrentLocation()

It looks like it is using FF-authored code that is intended for this purpose:

extension GoRouterLocationExtension on GoRouter {
  String getCurrentLocation() {
    final RouteMatch lastMatch = routerDelegate.currentConfiguration.last;
    final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
        ? lastMatch.matches
        : routerDelegate.currentConfiguration;
    return matchList.uri.toString();
  }
}

See https://github.com/flutter/flutter/issues/135854

I am hoping that the technical information provided will allow you to apply this fix without spending much effort. It is quite awkward and inefficient for us to locally patch FF-generated code every time.