fromJson method

  1. @override
BentoTheme fromJson(
  1. Map<String, Object?> json
)

Implementation

@override
BentoTheme fromJson(Map<String, Object?> json) {
  final entries = json.map((key, value) {
    if (value is Map<String, Object?>) {
      return MapEntry(
        key,
        value,
      );
    }
    return MapEntry(
      key,
      const <String, Object?>{},
    );
  });

  return BentoTheme(
    name: name,
    children: [
      ...entries.entries
          .where((e) =>
              e.key != 'extensions' &&
              e.value.isNotEmpty &&
              !e.value.containsKey('type'))
          .map(
            (e) => BentoThemeConverter(e.key).fromJson({
              ...e.value,
            }),
          ),
    ],
    tokens: [
      ...entries.entries
          .where((e) => e.value.isNotEmpty && e.value.containsKey('type'))
          .map(
            (e) => const DesignTokenConverter().fromJson(e),
          ),
    ],
  );
}