flutter: artemisをpokemon apiで動かしてみる
artemisの現在の最新版6.18.4をReadmeの通り入れてbuild_runnerしてみると
$ flutter pub run build_runner build Failed to build build_runner:build_runner: ../../development/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:258:50: Error: The property 'displayString' is defined in multiple extensions for 'TargetKind' and neither is more specific. - 'TargetKind' is from 'package:meta/meta_meta.dart' ('../../development/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart'). Try using an explicit extension application of the wanted extension or hiding unwanted extensions from scope. var kindNames = kinds.map((kind) => kind.displayString).toList() ^^^^^^^^^^^^^ ../../development/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:1950:14: Context: This is one of the extension members. String get displayString { ^^^^^^^^^^^^^ ../../development/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.7.0/lib/meta_meta.dart:91:14: Context: This is one of the extension members. String get displayString { ^^^^^^^^^^^^^ ../../development/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.41.2/lib/src/error/best_practices_verifier.dart:260:36: Error: The getter 'commaSeparatedWithOr' isn't defined for the class 'List<dynamic>'. - 'List' is from 'dart:core'. Try correcting the name to the name of an existing getter, or defining a getter or field named 'commaSeparatedWithOr'. var validKinds = kindNames.commaSeparatedWithOr; ^^^^^^^^^^^^^^^^^^^^ pub finished with exit code 1
https://github.com/dart-lang/sdk/issues/46687
7系に上げてみることに
そうするとbuild時に下記のエラー
: Error: Required named parameter 'response' must be provided. ../…/src/link.dart:128 yield Response( ^ : Context: Found this candidate, but the arguments don't match. ../…/src/response.dart:23 const Response({ ^^^^^^^^ : Error: Required named parameter 'response' must be provided. ../…/src/response_parser.dart:10 Response parseResponse(Map<String, dynamic> body) => Response( ^ : Context: Found this candidate, but the arguments don't match. ../…/src/response.dart:23 const Response({ ^^^^^^^^
このエラーはどういうことかというと
https://github.com/gql-dart/gql/blob/master/links/gql_exec/lib/src/response.dart#L27
上のパラメータの部分。
一番上のエラーはgql_http_linkのmasterだと直ってる。
https://github.com/gql-dart/gql/blob/master/links/gql_http_link/lib/src/link.dart#L131
ということで、 gql_http_link: ^0.4.2-alpha を追加
これでやっとbuild_runnerが成功
そして実行してみるとpokemon apiのURLが変わってるようなので、betaブランチのexampleのmain.dartを 持ってくるとやっと動きました。
https://github.com/comigor/artemis/blob/beta/example/pokemon/lib/main.dart
そして、ポケモンの画像をGridViewで表示してみました
書いたソースはこちら
https://github.com/na8esin/flutter_artemis_practice/tree/main/lib