質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

Q&A

1回答

2915閲覧

freezedで自動生成ファイルが出力されない。

waiwai9090

総合スコア2

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

0グッド

0クリップ

投稿2022/07/25 12:35

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

どのように対応すればいいのでしょうか??

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

解決するかはわかりませんが、
Please update to the latest analyzer version (4.3.0) by running
flutter packages upgrade.

とあるので

flutter packages upgrade

をターミナルで実行してみるのはどうでしょう。

投稿2022/08/06 15:02

moriman

総合スコア615

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問