2
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.

[flutter] Error in BuiltValueGenerator for abstract class GGetUserReq implements Built<GGetUserReq, dynamic>, OperationRequest<dynamic, GGetUserVars>.

Posted at

エラー

flutter でbuild error。

$ flutter pub run build_runner build --delete-conflicting-outputs

...

Bad state: No element
[INFO] 2.7s elapsed, 4/5 actions completed.
[SEVERE] built_value_generator:built_value on lib/graphql/queries/user.req.gql.dart:
Error in BuiltValueGenerator for abstract class GGetUserReq implements Built<GGetUserReq, dynamic>, OperationRequest<dynamic, GGetUserVars>.
Please make the following changes to use BuiltValue:

1. Make field optimisticResponse have non-dynamic type. If you are already specifying a type, please make sure the type is correctly imported.
[INFO] Running build completed, took 3.0s

原因

graphqlファイルで、存在しないカラム名(fcsToken)を指定していた。
built_value_generatorでエラーが出ていて、エラーわかりにくい、、

user.graphqls
query GetUser {
    currentUser {
        id
        firebaseUID
        // ↓ここタイポ
        fcsToken
        name
        iconUrl
        createdAt
        updatedAt
    }
}

タイポを修正した。

user.graphqls
query GetUser {
    currentUser {
        id
        firebaseUID
        // ↓ここ直した
        fcmToken
        name
        iconUrl
        createdAt
        updatedAt
    }
}

再度、build_runnerを実行して解決。

$ flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 427ms

[INFO] Initializing inputs
[INFO] FlutterGen Loading ... pubspec.yaml
[INFO] Reading cached asset graph...
[INFO] Generated: /Users/hayashikengo/ghq/github.com/hkengo/kakeibo_mobile/lib/gen/assets.gen.dart
[INFO] FlutterGen finished.
[INFO] Reading cached asset graph completed, took 246ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 730ms

[INFO] Running build...
[INFO] 2.1s elapsed, 4/6 actions completed.
[INFO] Running build completed, took 2.8s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 51ms

[INFO] Succeeded after 2.9s with 9 outputs (11 actions)
2
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
2
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?