flutterのfreezedを使って、immutableなモデルを作ろうとしているのですが、下記のようなモデルを定義したのに、flutter pub run build_runner build --delete-conflicting-outputs
実行時にfreezed.dartやg.dartが出力されません。
dart
1import 'package:freezed_annotation/freezed_annotation.dart'; 2 3part 'articles_state.freezed.dart'; 4part 'articles_state.g.dart'; 5 6 7abstract class ArticlesState with _$ArticlesState { 8 const factory ArticlesState({ 9 ([]) dynamic articles, 10 (true) bool hasNext, 11 ('') String keyword, 12 }) = _ArticlesState; 13 14 factory ArticlesState.fromJson(Map<String, dynamic> json) => 15 _$ArticlesStateFromJson(json); 16} 17
コマンド実行時には何もエラーは出ていません
flutter pub run build_runner build --delete-conflicting-outputs [INFO] Generating build script... [INFO] Generating build script completed, took 196ms [INFO] Initializing inputs [INFO] Reading cached asset graph... [INFO] Reading cached asset graph completed, took 64ms [INFO] Checking for updates since last build... [INFO] Checking for updates since last build completed, took 299ms [INFO] Running build... [WARNING] freezed:freezed on lib/models/article_state.dart: Your current `analyzer` version may not fully support your current SDK version. Analyzer language version: 2.14.0 SDK language version: 2.19.0 Please update to the latest `analyzer` version (4.3.0) by running `flutter packages upgrade`. If you are not getting the latest version by running the above command, you can try adding a constraint like the following to your pubspec to start diagnosing why you can't get the latest version: dev_dependencies: analyzer: ^4.3.0 [WARNING] freezed:freezed on lib/models/qiita_user.dart: The class QiitaUser was declared as abstract, but it is not need anymore. Read here: https://github.com/rrousselGit/freezed/tree/master/packages/freezed#the-abstract-keyword [WARNING] freezed:freezed on lib/models/qiita_article.dart: The class QiitaArticle was declared as abstract, but it is not need anymore. Read here: https://github.com/rrousselGit/freezed/tree/master/packages/freezed#the-abstract-keyword [WARNING] freezed:freezed on lib/models/article_state.dart: The class ArticlesState was declared as abstract, but it is not need anymore. Read here: https://github.com/rrousselGit/freezed/tree/master/packages/freezed#the-abstract-keyword [WARNING] freezed:freezed on lib/models/article_state.dart: article_state.freezed.dart must be included as a part directive in the input library with: part 'article_state.freezed.dart'; [INFO] Running build completed, took 1.0s [INFO] Caching finalized dependency graph... [INFO] Caching finalized dependency graph completed, took 20ms [INFO] Succeeded after 1.1s with 4 outputs (7 actions) CA-20018506:flutter_api s16864$ flutter pub run build_runner build --delete-conflicting-outputs [INFO] Generating build script... [INFO] Generating build script completed, took 190ms [INFO] Initializing inputs [INFO] Reading cached asset graph... [INFO] Reading cached asset graph completed, took 176ms [INFO] Checking for updates since last build... [INFO] Checking for updates since last build completed, took 288ms [INFO] Running build... [WARNING] freezed:freezed on lib/models/qiita_user.dart: The class QiitaUser was declared as abstract, but it is not need anymore. Read here: https://github.com/rrousselGit/freezed/tree/master/packages/freezed#the-abstract-keyword [WARNING] freezed:freezed on lib/models/qiita_article.dart: The class QiitaArticle was declared as abstract, but it is not need anymore. Read here: https://github.com/rrousselGit/freezed/tree/master/packages/freezed#the-abstract-keyword [WARNING] freezed:freezed on lib/models/qiita_article.dart: Your current `analyzer` version may not fully support your current SDK version. Analyzer language version: 2.14.0 SDK language version: 2.19.0 Please update to the latest `analyzer` version (4.3.0) by running `flutter packages upgrade`. If you are not getting the latest version by running the above command, you can try adding a constraint like the following to your pubspec to start diagnosing why you can't get the latest version: dev_dependencies: analyzer: ^4.3.0 [INFO] Running build completed, took 923ms [INFO] Caching finalized dependency graph... [INFO] Caching finalized dependency graph completed, took 18ms [INFO] Succeeded after 945ms with 4 outputs (4 actions)
pubspec.yaml
yml
1dependencies: 2 flutter: 3 sdk: flutter 4 5 flutter_hooks: ^0.16.0 6 hooks_riverpod: ^0.13.0 7 8 state_notifier: ^0.7.0 9 10 dio: ^4.0.0-beta4 11 12 json_serializable: ^4.0.2 13 freezed_annotation: ^0.14.2 14 15 shared_preferences: ^2.0.3 16 17 intl: ^0.17.0 18 19 webview_flutter: ^2.0.8 20 21 cupertino_icons: ^1.0.2 22 23dev_dependencies: 24 flutter_test: 25 sdk: flutter 26 27 build_runner: ^1.11.1 28 freezed: ^0.14.0
どのように対応すればいいのでしょうか??
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。