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({
    'appBar': appBar?.toJson(),
    'backgroundColor': ThemeEncoder.encodeColor(
      backgroundColor,
    ),
    'body': body?.toJson(),
    'bottomNavigationBar': bottomNavigationBar?.toJson(),
    'bottomSheet': bottomSheet?.toJson(),
    'drawer': drawer?.toJson(),
    'drawerDragStartBehavior':
        DragStartBehavior.start == drawerDragStartBehavior
            ? null
            : ThemeEncoder.encodeDragStartBehavior(
                drawerDragStartBehavior,
              ),
    'drawerEdgeDragWidth': drawerEdgeDragWidth,
    'drawerEnableOpenDragGesture': true == drawerEnableOpenDragGesture
        ? null
        : drawerEnableOpenDragGesture,
    'drawerScrimColor': ThemeEncoder.encodeColor(
      drawerScrimColor,
    ),
    'endDrawer': endDrawer?.toJson(),
    'endDrawerEnableOpenDragGesture': true == endDrawerEnableOpenDragGesture
        ? null
        : endDrawerEnableOpenDragGesture,
    'extendBody': false == extendBody ? null : extendBody,
    'extendBodyBehindAppBar':
        false == extendBodyBehindAppBar ? null : extendBodyBehindAppBar,
    'floatingActionButton': floatingActionButton?.toJson(),
    'floatingActionButtonAnimator':
        ThemeEncoder.encodeFloatingActionButtonAnimator(
      floatingActionButtonAnimator,
    ),
    'floatingActionButtonLocation':
        ThemeEncoder.encodeFloatingActionButtonLocation(
      floatingActionButtonLocation,
    ),
    'onDrawerChanged': onDrawerChanged,
    'onEndDrawerChanged': onEndDrawerChanged,
    'persistentFooterAlignment':
        AlignmentDirectional.centerEnd == persistentFooterAlignment
            ? null
            : ThemeEncoder.encodeAlignmentDirectional(
                persistentFooterAlignment,
              ),
    'persistentFooterButtons':
        JsonClass.maybeToJsonList(persistentFooterButtons),
    'primary': true == primary ? null : primary,
    'resizeToAvoidBottomInset': resizeToAvoidBottomInset,
    'restorationId': restorationId,
    ...args,
  });
}