fromDynamic static method

JsonAppBarBuilder? fromDynamic(
  1. dynamic map, {
  2. JsonWidgetRegistry? registry,
})

Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "actions": <JsonWidgetData[]>,
  "actionsIconTheme": <IconThemeData>,
  "automaticallyImplyLeading": <bool>,
  "backgroundColor": <Color>,
  "bottom": <JsonWidgetData>,
  "bottomOpacity": <double>,
  "centerTitle": <bool>,
  "elevation": <double>,
  "excludeHeaderSemantics": <bool>,
  "flexibleSpace": <JsonWidgetData>,
  "foregroundColor": <Color>,
  "iconTheme": <IconThemeData>,
  "leading": <bool>,
  "leadingWidth": <double>,
  "primary": <bool>,
  "shadowColor": <Color>,
  "shape": <ShapeBorder>,
  "systemOverlayStyle": <SystemUiOverlayStyle>,
  "titleTextStyle": <TextStyle>,
  "toolbarTextStyle": <TextStyle>,
  "title": <JsonWidgetData>,
  "titleSpacing": <double>,
  "toolbarHeight": <double>,
  "toolbarOpacity": <double>
}

See also:

  • JsonWidgetData.fromDynamic
  • ThemeDecoder.decodeBrightness
  • ThemeDecoder.decodeColor
  • ThemeDecoder.decodeIconThemeData
  • ThemeDecoder.decodeShapeBorder

Implementation

static JsonAppBarBuilder? fromDynamic(
  dynamic map, {
  JsonWidgetRegistry? registry,
}) {
  JsonAppBarBuilder? result;

  if (map != null) {
    result = JsonAppBarBuilder(
      actions: JsonClass.fromDynamicList(
        map['actions'],
        (map) => JsonWidgetData.fromDynamic(
          map,
          registry: registry,
        )!,
      ),
      actionsIconTheme: ThemeDecoder.decodeIconThemeData(
        map['actionsIconTheme'],
        validate: false,
      ),
      automaticallyImplyLeading: map['automaticallyImplyLeading'] == null
          ? true
          : JsonClass.parseBool(map['automaticallyImplyLeading']),
      backgroundColor: ThemeDecoder.decodeColor(
        map['backgroundColor'],
        validate: false,
      ),
      bottom: JsonWidgetData.fromDynamic(
        map['bottom'],
        registry: registry,
      ),
      bottomOpacity: JsonClass.parseDouble(map['bottomOpacity'], 1.0)!,
      centerTitle: map['centerTitle'] == null
          ? null
          : JsonClass.parseBool(map['centerTitle']),
      elevation: JsonClass.parseDouble(map['elevation']),
      excludeHeaderSemantics:
          JsonClass.parseBool(map['excludeHeaderSemantics']),
      flexibleSpace: JsonWidgetData.fromDynamic(
        map['flexibleSpace'],
        registry: registry,
      ),
      iconTheme: ThemeDecoder.decodeIconThemeData(
        map['iconTheme'],
        validate: false,
      ),
      leading: JsonWidgetData.fromDynamic(
        map['leading'],
        registry: registry,
      ),
      leadingWidth: JsonClass.parseDouble(map['leadingWidth']),
      primary:
          map['primary'] == null ? true : JsonClass.parseBool(map['primary']),
      shadowColor: ThemeDecoder.decodeColor(
        map['shadowColor'],
        validate: false,
      ),
      shape: ThemeDecoder.decodeShapeBorder(
        map['shape'],
        validate: false,
      ),
      systemOverlayStyle: ThemeDecoder.decodeSystemUiOverlayStyle(
        map['systemOverlayStyle'],
        validate: false,
      ),
      titleTextStyle: ThemeDecoder.decodeTextStyle(
        map['titleTextStyle'],
        validate: false,
      ),
      toolbarTextStyle: ThemeDecoder.decodeTextStyle(
        map['toolbarTextStyle'],
        validate: false,
      ),
      title: JsonWidgetData.fromDynamic(
        map['title'],
        registry: registry,
      ),
      titleSpacing: JsonClass.parseDouble(
        map['titleSpacing'],
        NavigationToolbar.kMiddleSpacing,
      ),
      toolbarHeight: JsonClass.parseDouble(map['toolbarHeight']),
      toolbarOpacity: JsonClass.parseDouble(map['toolbarOpacity'], 1.0)!,
    );
  }

  return result;
}