buildScaffold method

  1. @protected
Widget buildScaffold(
  1. BuildParameters params
)

Implementation

@protected
Widget buildScaffold(BuildParameters params) {
  final props = params.spec.props;
  final widgets = params.spec.widgets;

  List<Widget>? persistentFooterButtons;
  if (widgets["persistentFooterButtons"] != null) {
    persistentFooterButtons = <Widget>[];
    for (Map childSpec in widgets["persistentFooterButtons"] as List<Map>) {
      persistentFooterButtons.add(builder.buildWidget(
          params.context, childSpec, params.state, params.parentContext));
    }
  }

  var appBar = builder.tryBuildWidget(
      params.context, widgets["appBar"], params.state, params.parentContext);
  if (appBar is! PreferredSizeWidget) {
    appBar = null;
  }
  final bottomSheet = builder.tryBuildWidget(params.context,
      widgets["bottomSheet"], params.state, params.parentContext);
  final bottomNavigationBar = builder.tryBuildWidget(params.context,
      widgets["bottomNavigationBar"], params.state, params.parentContext);
  final floatingActionButton = builder.tryBuildWidget(params.context,
      widgets["floatingActionButton"], params.state, params.parentContext);
  var body = builder.tryBuildWidget(
      params.context, widgets["body"], params.state, params.parentContext);
  final drawer = builder.tryBuildWidget(
      params.context, widgets["drawer"], params.state, params.parentContext);

  if (widgets["navigationRail"] != null) {
    final navigationRail = builder.buildWidget(params.context,
        widgets["navigationRail"], params.state, params.parentContext);
    body = Row(
      mainAxisSize: MainAxisSize.max,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        navigationRail,
        if (body != null) Expanded(child: body),
      ],
    );
  }

  Widget widget = Scaffold(
    key: properties.getKey(params.id),
    backgroundColor: tryParseColor(props["backgroundColor"]),
    body: body,
    bottomSheet: bottomSheet,
    bottomNavigationBar: bottomNavigationBar,
    floatingActionButton: floatingActionButton,
    persistentFooterButtons: persistentFooterButtons,
    drawer: drawer,
    extendBody: parseBool(props["extendBody"]),
    extendBodyBehindAppBar: parseBool(props["extendBodyBehindAppBar"]),
    resizeToAvoidBottomInset: tryParseBool(props["resizeToAvoidBottomInset"]),
    appBar: appBar != null ? appBar as PreferredSizeWidget : null,
    floatingActionButtonLocation:
        params.buildProp("floatingActionButtonLocation"),
  );

  if (props["tabController"] != null) {
    widget = DefaultTabController(
      length: parseInt(props["tabController"]["length"]),
      initialIndex: parseInt(props["tabController"]["initialIndex"]),
      child: widget,
    );
  }

  return widget;
}