1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

auto_routeを使おうとしてビルドしたら、「 Error: The method 'AutoRouteInformationProvider.routerReportsNewRouteInformation' doesn't have the named parameter 'type' of overridden method 'RouteInformationProvider.routerReportsNewRouteInformation'.」というエラーがでたときの対処法

Last updated at Posted at 2021-11-04

はじめに

flutter webで動的にurlを生成し、さらにブラウザのバックボタンを有効にする方法としてauto_routeの勉強をしようとしていました。ところが、簡単なコードを書いてビルドしたところ

 Error: The method 'AutoRouteInformationProvider.routerReportsNewRouteInformation' doesn't have the named parameter 'type' of overridden method 'RouteInformationProvider.routerReportsNewRouteInformation'.

とエラーが表示されました。

環境

MacOS BigSur
Flutter 2.5.3
Dart 2.14.4
auto_route: ^2.2.0
(auto_routeは3.04を一回試したのですが、以下のようなエラーがMessageにでたのであきらめて、うまくいっている人のVer2.20を採用しました)

Running "flutter pub get" in auto_route_sample...               
Because auto_route_sample depends on auto_route_generator ^3.0.4 which doesn't match any versions, version solving failed.
pub get failed (1; Because auto_route_sample depends on auto_route_generator ^3.0.4 which doesn't match any versions, version solving failed.)
Process finished with exit code 1

解決策

以下のサイトを参考にしました。
https://github.com/flutter/flutter/pull/88122

flutter --version

でチャンネルを確認するとmasterだったので、stableに変更したら解決するようです。(betaもうまくいきませんでした。このパッケージのバグなようです)

変更方法は

flutter channel stable
flutter upgrade
flutter pub get

です。

ちなみにこれをしても私は以下のようなエラーが出たので、
(エラーの文章なくしちゃったので、↓のURLから引っ張ってきました。verは違った気がしますが、内容は同じです)
https://github.com/dnfield/flutter_svg/issues/161

The current Dart SDK version is 2.1.2-dev.0.0.flutter-0a7dcf17eb. Because test_app depends on flutter_svg >=0.13.0 which requires SDK version >=2.2.0 <3.0.0, version solving failed. 

pubspec.yaml内のenvironment:sdk:を以下のように変更して、devを消しました。

environment:
  sdk: ">=2.12.0 <3.0.0"

これでもう一回pub getしてビルドしたところうまくいきました。

2時間ほど、このエラーで私はさまよったので誰かの参考になったら嬉しいです!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?