Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.0: Error running FreezedGenerator: ... but freezed has nothing to generate" #40

Closed
jonasbark opened this issue Feb 14, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@jonasbark
Copy link

jonasbark commented Feb 14, 2020

File:

import 'package:freezed_annotation/freezed_annotation.dart';
part 'second_state.freezed.dart';
part 'second_state.g.dart';

@freezed
abstract class SecondState with _$SecondState {
  const factory SecondState({
    @JsonKey(ignore: true, nullable: true) String dateTime,
    @JsonKey(ignore: true, nullable: true) String uuid,
  }) = _SecondState;

  const factory SecondState.fromJson(Map<String, dynamic> json) => _$SecondStateFromJson(json);
}

Error:

[SEVERE] freezed:freezed on lib/state/second_state/second_state.dart:
Error running FreezedGenerator
Marked SecondState with @freezed, but freezed has nothing to generate
package:example/state/second_state/second_state.dart:6:16
  ╷
6 │ abstract class SecondState with _$SecondState {
  │                ^^^^^^^^^^^
  ╵

Did I forget something? All other state files fail as well (so it's not the fact that both fields have ignore: true at JsonKey)

@rrousselGit
Copy link
Owner

That's a regression.

It happens because the constructor is defined on multiple lines. If you format it in a single line, that should work for now.

I'll fix it asap

@rrousselGit rrousselGit added the bug Something isn't working label Feb 14, 2020
@rrousselGit
Copy link
Owner

The fix is released as part of 0.5.0

@alekline
Copy link

alekline commented Apr 17, 2020

Thank you for the hard work put into this.

A similar problem is still happening in version 0.10.6 - If you have comments in between the variables, and these comments have parenthesis, you MUST close the parenthesis or freezed won't be able to generate the files:

@freezed
abstract class MyClass with _$MyClass {
  const factory MyClass({
    @required String myStr1,
    @required bool myBool1,

    /// These comments Cause problems only when I (don't close the parenthesis
    // It doesn't matter if you have two or three bar comments, or single quotes, as long as you (close the parenthesis, you'll be fine)
    @required String mySpecialStr,
  }) = _MyClass;

}

So I guess good grammar is always a must :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants