toJson method

  1. @override
Map<String, dynamic> toJson()
override

Abstract function that concrete classes must implement. This must encode the internal data model to a JSON compatible representation.

While not required, it is suggested to call removeNull before returning.

Implementation

@override
Map<String, dynamic> toJson() {
  return JsonClass.removeNull({
    'actions': JsonClass.maybeToJsonList(actions),
    'actionsIconTheme': ThemeEncoder.encodeIconThemeData(
      actionsIconTheme,
    ),
    'automaticallyImplyLeading':
        true == automaticallyImplyLeading ? null : automaticallyImplyLeading,
    'backgroundColor': ThemeEncoder.encodeColor(
      backgroundColor,
    ),
    'bottom': bottom?.toJson(),
    'bottomOpacity': 1.0 == bottomOpacity ? null : bottomOpacity,
    'centerTitle': centerTitle,
    'clipBehavior': ThemeEncoder.encodeClip(
      clipBehavior,
    ),
    'elevation': elevation,
    'excludeHeaderSemantics':
        false == excludeHeaderSemantics ? null : excludeHeaderSemantics,
    'flexibleSpace': flexibleSpace?.toJson(),
    'forceMaterialTransparency':
        false == forceMaterialTransparency ? null : forceMaterialTransparency,
    'foregroundColor': ThemeEncoder.encodeColor(
      foregroundColor,
    ),
    'iconTheme': ThemeEncoder.encodeIconThemeData(
      iconTheme,
    ),
    'leading': leading?.toJson(),
    'leadingWidth': leadingWidth,
    'notificationPredicate':
        defaultScrollNotificationPredicate == notificationPredicate
            ? null
            : notificationPredicate,
    'primary': true == primary ? null : primary,
    'scrolledUnderElevation': scrolledUnderElevation,
    'shadowColor': ThemeEncoder.encodeColor(
      shadowColor,
    ),
    'shape': ThemeEncoder.encodeShapeBorder(
      shape,
    ),
    'surfaceTintColor': ThemeEncoder.encodeColor(
      surfaceTintColor,
    ),
    'systemOverlayStyle': ThemeEncoder.encodeSystemUiOverlayStyle(
      systemOverlayStyle,
    ),
    'title': title?.toJson(),
    'titleSpacing': titleSpacing,
    'titleTextStyle': ThemeEncoder.encodeTextStyle(
      titleTextStyle,
    ),
    'toolbarHeight': toolbarHeight,
    'toolbarOpacity': 1.0 == toolbarOpacity ? null : toolbarOpacity,
    'toolbarTextStyle': ThemeEncoder.encodeTextStyle(
      toolbarTextStyle,
    ),
    ...args,
  });
}