toJson method
Serializes the Arguments instance to a JSON-compatible map.
Converts all build configuration parameters into a JSON-serializable
map structure that can be stored, transmitted, or used for configuration
persistence. This method provides the inverse operation of fromJson
for complete serialization support.
Returns
Returns a Map<String, dynamic> containing:
- All build configuration parameters as key-value pairs
- JSON-compatible data types (String, bool, List, etc.)
- Null values preserved for optional parameters
- Consistent key naming matching command-line arguments
Output Structure
The returned map structure includes:
binary-type- Output binary format specificationbuild-mode- Build optimization mode settingtarget- Main application entry-point fileflavor- Product flavor or build variantdart-defines- Dart compilation define valuesdart-defines-file- Dart defines configuration filebuild-name- Human-readable version namebuild-number- Numeric version identifierpub- Dependency resolution flagarguments- Custom build command argumentsoutput- Build artifacts output directory
Example
final args = Arguments(variables, binaryType: 'aab', buildMode: 'release');
final json = args.toJson();
// Result:
// {
// 'binary-type': 'aab',
// 'build-mode': 'release',
// 'target': null,
// 'flavor': null,
// 'pub': null,
// 'arguments': null,
// 'output': null
// }
Implementation
@override
Map<String, dynamic> toJson() => {
'binary-type': binaryType,
'build-mode': buildMode,
'target': target,
'flavor': flavor,
'dart-defines': dartDefines,
'dart-defines-file': dartDefinesFile,
'build-name': buildName,
'build-number': buildNumber,
'pub': pub,
'arguments': customArgs,
'output': output,
};