diff --git a/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs b/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs index 7d1d33a549..340d99100e 100644 --- a/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs +++ b/frb_codegen/src/library/codegen/generator/api_dart/spec_generator/class/ty/enumeration_complex.rs @@ -36,6 +36,9 @@ impl EnumRefApiDartGenerator<'_> { }; let maybe_implements_exception = generate_dart_maybe_implements_exception(self.mir.is_exception); + let json_serde = format!( + "factory {name}.fromJson(Map json) => _${name}FromJson(json);", + ); Some(ApiDartGeneratedClass { namespace: src.name.namespace.clone(), @@ -47,6 +50,8 @@ impl EnumRefApiDartGenerator<'_> { {variants} + {json_serde} + {extra_body} }}", ), diff --git a/frb_codegen/src/library/codegen/generator/api_dart/text_generator.rs b/frb_codegen/src/library/codegen/generator/api_dart/text_generator.rs index 2d917ce141..ea8c99c32d 100644 --- a/frb_codegen/src/library/codegen/generator/api_dart/text_generator.rs +++ b/frb_codegen/src/library/codegen/generator/api_dart/text_generator.rs @@ -92,7 +92,10 @@ fn generate_end_api_text( import: "import 'package:freezed_annotation/freezed_annotation.dart' hide protected;" .into(), part: format!( - "part '{name}.freezed.dart';", + " + part '{name}.freezed.dart'; + part '{name}.g.dart'; + ", name = dart_output_path.file_stem().unwrap().to_str().unwrap() ), ..Default::default()