JsonFactoryBuilder class
A custom Builder that generates the centralized JsonFactory implementation.
This builder creates a single, optimized factory class that handles JSON parsing for all models in your project. It supports both manual JSON serialization and code generated by json_serializable.
Features:
- Unified JSON parsing through JsonFactory.fromJson
- Full support for generics (List
- Strong type checking at compile time
- Clear error messages for common issues
- Zero runtime setup required
- Automatic null safety handling
Configuration:
- output_path: Where to generate the factory (default: "lib/generated")
- output_file_name: Name of output file (default: "json_factory")
Best Practices:
- Keep the generated file under source control
- Run generation after adding new models
- Use with json_serializable for complex models
- Check generated code for type safety
Constructors
- JsonFactoryBuilder(BuilderOptions options)
Properties
-
buildExtensions
→ Map<
String, List< String> > -
Mapping from input file extension to output file extensions.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- options → BuilderOptions
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildStep buildStep) → Future< void> -
Generates the outputs for a given
BuildStep. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited