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
When creating State, if it is a specific type and written in a single line, it will result in an error. #929
Comments
The errors you're seeing aren't produced by Freezed by Dart itself. Without a reproducible example, there's nothing I can do to help. |
Thank you for your message. In sending the issue, I created a new flutter project and tried to reproduce the issue, and got the same error. Just to be sure, I will share the details of my environment where this error occurred. environment
reproduction procedure
Sorry to take up your time. |
Tested with import 'package:freezed_annotation/freezed_annotation.dart';
part 'temp_state.freezed.dart';
const map = <Map<String, dynamic>>[]; // <-------- Define the default value
@freezed
class TempState with _$TempState {
const factory TempState({
@Default(map) List<Map<String, dynamic>> xxx, // <------- One single line of code
}) = _TempState;
} and in the generated file ...
/// @nodoc
mixin _$TempState {
List<Map<String, dynamic>> get xxx => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TempStateCopyWith<TempState> get copyWith =>
throw _privateConstructorUsedError;
}
... If the annotation is replaced with: ...
/// @nodoc
mixin _$TempState {
Map<String, dynamic>>[]) List<Map<String, dynamic>> get xxx => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TempStateCopyWith<TempState> get copyWith => throw _privateConstructorUsedError;
}
... So to me this looks like an error with the source code generator where it renders |
Describe the bug
If you create a value of type
List<Map<String, dynamic>>
in State, and write it as shown in the attached image 1, there will be no errors when you executeflutter pub run build_runner build
in two lines. However, if you executeflutter pub run build_runner build
in one line, you will get the error message:"The name 'Map' isn't a type, so it can't be used as a type argument. Try correcting the name to an existing type or defining a type named 'Map'."
In this particular type, an error occurs only when it is written in a single line.
To Reproduce
no error
error
Expected behavior
I believe it is desirable for the code to not produce any errors, regardless of whether it is written in one line or two lines.
As this is my first issue to submit to the this project, I apologize if I have provided any incorrect information.
I would appreciate it if you could reply whenever you have time.
The text was updated successfully, but these errors were encountered: