auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

Issue "Error: Required named parameter 'type' must be provided." when deploying Flutter in Netlify

Open RizaldiWiratama opened this issue 3 years ago • 29 comments

Hey @Milad-Akarie, this is a great package for managing route

Previously I managed to deploying flutter on netlify until yesterday it failed with error message:

"Error: Required named parameter 'type' must be provided. ?.routerReportsNewRouteInformation( "

this is deploy log on netlify image

Strange this error is not appear when i run flutter in my devices / local browser

this is my dependencies for auto route package

dependencies:
   auto_route: ^2.3.0
   ...

dependency_overrides:
  meta: ^1.7.0

dev_dependencies:
   auto_route_generator: ^2.3.0
   build_runner: ^2.0.5
   ...

and this is my AppRouter.dart

@MaterialAutoRouter(
  replaceInRouteName: 'Page,Route',
  routes: <AutoRoute>[


    ///After modify/add new route, run "flutter packages pub run build_runner watch" in terminal to generate new route
    ///or Run "flutter packages pub run build_runner watch --delete-conflicting-outputs" when conflicting output detected

    ///Login
    AutoRoute(page: LoginPage, path: "/login"),

    ///MainNavigationPage
    AutoRoute(page: MainNavigationPage, guards: [AuthGuard], path: "/",
        children: [
          ///Dashboard
          AutoRoute(page: DashboardPage, path: "dashboard", initial: true),

          ///ITSP
          AutoRoute(page: ItspCompanyPage, path: "itsp"),
          AutoRoute(page: ItspRkuPage, path: "itsp/:companyName/rku/"),
          AutoRoute(page: ItspRktPage, path: "itsp/:companyName/rku/:rkuYear/rkt/"),
          AutoRoute(page: ItspRktDetailPage, path: "itsp/:companyName/rku/:rkuYear/rkt/:rktYear/"),
          AutoRoute(page: ItspTallyAddPage, path: "itsp/:companyName/rku/:rkuYear/rkt/:rktYear/add"),
          AutoRoute(page: ItspTallyUpdatePage, path: "itsp/:companyName/rku/:rkuYear/rkt/:rktYear/update/:tallyId"),

          ///Logging
          AutoRoute(page: LoggingOverviewPage, path: "logging"),
          AutoRoute(page: LoggingListPage, path: "logging/list"),
          AutoRoute(page: LoggingAddPAge, path: "logging/list/add"),
          AutoRoute(page: LoggingOverviewDetailPage, path: "logging/:companyId"),

          ///Template Form & List
          AutoRoute(page: FormPage, path: "form"),
          AutoRoute(page: ListPage, path: "list"),

          ///Redirect to Initial Route (Dashboard) if route name is not detected
          RedirectRoute(path: '*', redirectTo: '')
        ]
    ),
  ],
)
class $AppRouter {}

is this error related with auto route package? do you have any suggestion about this error? thanks @Milad-Akarie

RizaldiWiratama avatar Aug 20 '21 02:08 RizaldiWiratama

After many attempts, I found the problem, the error appears when Netlify update the flutter

my assumption that the latest update of flutter (or a new branch) that got pulled has a conflict with package autoroute

so the workaround is deleting "git pull" (so Netlify not updating flutter) in Netlify build command and redeploy site.

Build Command (Failed) : if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --release

Build Command (Success) : if cd flutter; then cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --release

RizaldiWiratama avatar Aug 20 '21 04:08 RizaldiWiratama

Hello @RizaldiWiratama,

This is caused by flutter/flutter/pull/88122.

LefebvreIlyas avatar Aug 20 '21 09:08 LefebvreIlyas

thanks @LefebvreIlyas for the info, so a new update of Widget "Router" Flutter makes package autoroute fails to compile?

is any workaround for package autoroute for that case ? @Milad-Akarie

RizaldiWiratama avatar Aug 20 '21 22:08 RizaldiWiratama

You're welcome @RizaldiWiratama.

The break comes more precisely from the RouteInformationProvider class. The package code must be adapted to be compatible.

At the moment, this change is only effective on master if I'm not mistaken, so a solution would be to switch to the beta or dev branch, or even stable, if you don't use anything new that is not yet available there (flutter channel [branch_name]).

LefebvreIlyas avatar Aug 22 '21 10:08 LefebvreIlyas

Anyone know what would be the fix on the code side for autoroute so I can change it even if it's locally? I can't move away from master on my current project.

Thank you

jlubeck avatar Aug 27 '21 00:08 jlubeck

Anyone know what would be the fix on the code side for autoroute so I can change it even if it's locally? I can't move away from master on my current project.

Thank you

Answering to myself, looks like just adding type: RouteInformationReportingType.navigate, on router/widgets/auto_router_delegate.dart does the trick. Not sure if it's going to break something else, but at least I can keep working for now

jlubeck avatar Aug 27 '21 00:08 jlubeck

I got the same error while using Snapcraft to package my flutter app. Changing to the stable worked for me.

Thanks

guyluz11 avatar Sep 09 '21 12:09 guyluz11

You're welcome @RizaldiWiratama.

The break comes more precisely from the RouteInformationProvider class. The package code must be adapted to be compatible.

At the moment, this change is only effective on master if I'm not mistaken, so a solution would be to switch to the beta or dev branch, or even stable, if you don't use anything new that is not yet available there (flutter channel [branch_name]).

Beta does not work either. Only stable does.

Ruzo avatar Sep 16 '21 15:09 Ruzo

Hey @jlubeck could you be more specific about :

Answering to myself, looks like just adding type: RouteInformationReportingType.navigate, on router/widgets/auto_router_delegate.dart does the trick. Not sure if it's going to break something else, but at least I can keep working for now

I've tried to add type: RouteInformationReportingType.navigate, like so :

static reportUrlChanged(BuildContext context, String url) {
    Router.of(context)
        .routeInformationProvider
        ?.routerReportsNewRouteInformation(
          RouteInformation(
            location: url,
          ),
          type: RouteInformationReportingType.navigate, // added line
        );
  }

But it didn't change anything in the error it produces.

romain-pattyn avatar Oct 06 '21 08:10 romain-pattyn

Hey @jlubeck could you be more specific about :

Answering to myself, looks like just adding type: RouteInformationReportingType.navigate, on router/widgets/auto_router_delegate.dart does the trick. Not sure if it's going to break something else, but at least I can keep working for now

I've tried to add type: RouteInformationReportingType.navigate, like so :

static reportUrlChanged(BuildContext context, String url) {
    Router.of(context)
        .routeInformationProvider
        ?.routerReportsNewRouteInformation(
          RouteInformation(
            location: url,
          ),
          type: RouteInformationReportingType.navigate, // added line
        );
  }

But it didn't change anything in the error it produces.

That's exactly what I did, not sure why it's not working for you :(

jlubeck avatar Oct 07 '21 16:10 jlubeck

You can use this fork for now https://github.com/biklas7/auto_route_library/tree/chore/update-flutter-beta it's been working for me with the latest flutter beta version.

biklas7 avatar Oct 21 '21 09:10 biklas7

The solution for me was to set up my netlify.toml to this:

[build] publish = "build/web"

command = "if cd flutter; then cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter channel stable && flutter/bin/flutter build web --release"

TesLake avatar Oct 25 '21 00:10 TesLake

Hey @jlubeck could you be more specific about :

Answering to myself, looks like just adding type: RouteInformationReportingType.navigate, on router/widgets/auto_router_delegate.dart does the trick. Not sure if it's going to break something else, but at least I can keep working for now

I've tried to add type: RouteInformationReportingType.navigate, like so :

static reportUrlChanged(BuildContext context, String url) {
    Router.of(context)
        .routeInformationProvider
        ?.routerReportsNewRouteInformation(
          RouteInformation(
            location: url,
          ),
          type: RouteInformationReportingType.navigate, // added line
        );
  }

But it didn't change anything in the error it produces.

Thank you guys, this help's me to solve the same problem, but in my case it was not enough

I also added a parameter: {required RouteInformationReportingType type} in the file: auto_route-3.0.4/lib/src/router/provider/auto_route_information_provider.dart

@override
void routerReportsNewRouteInformation(RouteInformation routeInformation,
    {required RouteInformationReportingType type ,bool isNavigation = true}) {  //required RouteInformationReportingType type  - added by  Anton Lobanov
  var replace = false;
  if (routeInformation is AutoRouteInformation) {
    replace = routeInformation.replace;
  }
  SystemNavigator.selectMultiEntryHistory();
  SystemNavigator.routeInformationUpdated(
    location: routeInformation.location!,
    state: routeInformation.state,
    replace: replace || !isNavigation,
  );
  _value = routeInformation;
}

now it's works properly.

a-givertzman avatar Oct 27 '21 12:10 a-givertzman

You can use this fork for now https://github.com/biklas7/auto_route_library/tree/chore/update-flutter-beta it's been working for me with the latest flutter beta version.

@biklas7 How to use this folk in pubspec Error on line 19, column 11: Invalid description in the "auto_route_generator" pubspec on the "auto_route" dependency: "../auto_route" is a relative path, but this isn't a local pubspec. ╷ 19 │ path: ../auto_route │ ^^^^^^^^^^^^^ ╵ pub get failed (65; ╵) exit code 65

I get the following error

InfiniteCoder06 avatar Nov 28 '21 13:11 InfiniteCoder06

@Hacker437 I use it like this:

dependencies:
  auto_route: ^3.1.3

dependency_overrides:
  auto_route:
    git:
      url: [email protected]:biklas7/auto_route_library.git
      ref: chore/update-flutter-beta
      path: auto_route

dev_dependencies:
  auto_route_generator: ^3.1.0

biklas7 avatar Nov 28 '21 13:11 biklas7

@Hacker437 I use it like this:

dependencies:
  auto_route: ^3.1.3

dependency_overrides:
  auto_route:
    git:
      url: [email protected]:biklas7/auto_route_library.git
      ref: chore/update-flutter-beta
      path: auto_route

dev_dependencies:
  auto_route_generator: ^3.1.0

Thank you

InfiniteCoder06 avatar Nov 28 '21 14:11 InfiniteCoder06

so, now it's also broken on stable channel (Flutter 2.8 released yesterday)

szymonmazanik avatar Dec 09 '21 10:12 szymonmazanik

@Hacker437 I use it like this:

dependencies:
  auto_route: ^3.1.3

dependency_overrides:
  auto_route:
    git:
      url: [email protected]:biklas7/auto_route_library.git
      ref: chore/update-flutter-beta
      path: auto_route

dev_dependencies:
  auto_route_generator: ^3.1.0

Interesting doesn't work for me.

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Any ideas how to fix that?

giiyms avatar Dec 09 '21 11:12 giiyms

Interesting doesn't work for me.

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Any ideas how to fix that?

The repo is public so it should work. Do you have git set up on your terminal? Maybe check this. 🤔

biklas7 avatar Dec 09 '21 11:12 biklas7

@Hacker437 I use it like this:

dependencies:
  auto_route: ^3.1.3

dependency_overrides:
  auto_route:
    git:
      url: [email protected]:biklas7/auto_route_library.git
      ref: chore/update-flutter-beta
      path: auto_route

dev_dependencies:
  auto_route_generator: ^3.1.0

Interesting doesn't work for me.

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Any ideas how to fix that?

If you're trying to fix the stable 2.8 issue, it's a new one. There is a pull request waiting to be merged so the contributor made available an override to his repo:

dependency_overrides:
  auto_route:
    git:
      url: https://github.com/Agondev/auto_route_library
      path: auto_route

Sorry, don't remember the thread id. Edit: Actually, it's #841

Ruzo avatar Dec 09 '21 14:12 Ruzo

Version 3.2.0 seems to solve this 🎉

biklas7 avatar Dec 15 '21 11:12 biklas7

Version 3.2.0 seems to solve this 🎉

I still fold the above case

n-anhtu0101 avatar Dec 20 '21 12:12 n-anhtu0101

Version 3.2.0 seems to solve this

it seems there are 5 downvotes on this claim ... and my team is one of them

Does anyone else have suggestions??

dgaedcke avatar Jan 11 '22 21:01 dgaedcke

@dgaedcke

Does anyone else have suggestions??

Didn't try but I saw someone said that it worked after updating flutter version.

I was having the same issues from autoroute updating my flutter version solved the problem for me.

You're welcome to try it out and share with us the results, and don't forget to mention your Flutter version.

guyluz11 avatar Jan 12 '22 07:01 guyluz11

Updating to latest version solved it for me to.

giiyms avatar Jan 12 '22 07:01 giiyms

I can confirm that using an M1 mac with a fresh set of tools, flutter 2.8.1, dart 1.15.1 and changing auto_route in your pubspec.yaml to exactly ^3.2.0 I'm able to build web, macos and ios successfully. thank you!

ehagerty avatar Jan 13 '22 18:01 ehagerty

Running ^3.2.0 with flutter 2.10.2 fixes the issue for me.

patonoide avatar Feb 23 '22 03:02 patonoide

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Jul 18 '22 08:07 github-actions[bot]

@github-actions

zs-dima avatar Jul 18 '22 09:07 zs-dima

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Sep 17 '22 08:09 github-actions[bot]