ProviderCodegenSnippet.fromJson constructor

ProviderCodegenSnippet.fromJson(
  1. Map<String, Object?> json
)

Decodes a provider snippet from the provider CLI JSON payload.

Implementation

factory ProviderCodegenSnippet.fromJson(Map<String, Object?> json) {
  final importsValue = json['imports'];
  return ProviderCodegenSnippet(
    imports: importsValue is List<Object?>
        ? importsValue.whereType<String>().toList(growable: false)
        : const <String>[],
    staticMethods: json['staticMethods'] is String
        ? json['staticMethods']! as String
        : '',
    topLevelCode: json['topLevelCode'] is String
        ? json['topLevelCode']! as String
        : '',
    emitDefaultMigrateMethod: json['emitDefaultMigrateMethod'] == true,
  );
}