freezed icon indicating copy to clipboard operation
freezed copied to clipboard

Fail to generate class named Forecast

Open bounty1342 opened this issue 2 years ago • 6 comments

Describe the bug Fail to generate class named Forecast.

To Reproduce

import 'package:freezed_annotation/freezed_annotation.dart';

part 'forecast.freezed.dart';
part 'forecast.g.dart';

@freezed
class Forecast with _$Forecast {
  const factory Forecast({
    @Default(0) int type,
  }) = _Forecast;

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

Expected behavior Generate whiteout issue.

bounty1342 avatar Aug 02 '22 16:08 bounty1342

What is your error?

rrousselGit avatar Aug 02 '22 16:08 rrousselGit

Screenshot 2022-08-02 at 18 23 17

bounty1342 avatar Aug 02 '22 16:08 bounty1342

import 'package:freezed_annotation/freezed_annotation.dart';

part 'forecast.freezed.dart';
part 'forecast.g.dart';

@freezed
class beforetest with _$beforetest {
  const factory beforetest({
    @Default(0) int type,
  }) = _beforetest;

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

Produce the same behavior.

I think it's related to the name of the file !

bounty1342 avatar Aug 02 '22 16:08 bounty1342

import 'package:freezed_annotation/freezed_annotation.dart';

part 'beforetest.freezed.dart';
part 'beforetest.g.dart';

@freezed
class beforetest with _$beforetest {
  const factory beforetest({
    @Default(0) int type,
  }) = _beforetest;

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

No issues

bounty1342 avatar Aug 02 '22 16:08 bounty1342

Do you still have a problem if you restart the IDE? It sounds like an analysis issue

Alternatively maybe double-check that the file name matches your parts

rrousselGit avatar Aug 02 '22 16:08 rrousselGit

Do you still have a problem if you restart the IDE? It sounds like an analysis issue

yes

Alternatively maybe double-check that the file name matches your parts

Might be, renaming the file to something other than forecast did the trick.

Edit: you can close it then ;)

bounty1342 avatar Aug 02 '22 16:08 bounty1342

I had to run flutter clean to remove such errors. Also a guess that removing ~/.dartServer folder may also help.

sinxwal avatar Sep 22 '22 08:09 sinxwal