0
0

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 1 year has passed since last update.

freezedで*.g.dartファイルが生成されない

Posted at

状況

freezedを使用していて、build_runner build → エラー発生 → 修正 を繰り返していました。
何度もビルドをしていたがために発生した事象だと思います。

エラー内容

生成しようとしたクラス

import 'package:freezed_annotation/freezed_annotation.dart';

part 'todo.freezed.dart'; // エラーあり ファイルが生成されていないのだから当然

part 'todo.g.dart'; // エラーあり ファイルが生成されていないのだから当然

@freezed
class TODO with _$TODO{
  const TODO._();
  const factory TODO({
    required String code,
    required String name,
  }) = _TODO;

  factory TODO.fromJson(Map<String, dynamic> json) =>
      _$TODOFromJson(json);
}

このクラスをfreezedで生成しようとしたら以下の[WARNING]が発生した。

TODO.g.dart must be included as a part directive in the input library with
part 'todo.g.dart';

Succeededは表示されているのに、todo.g.dartが生成されず、
todo.freezed.dartのみが生成されるという状況。

解決方法

以下を一度消して、もう一度書く。

part 'todo.g.dart';

まとめ

一回消して追加しただけなのに直った、、、。
わからない、、、。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?