buildSliverAppBar method
Implementation
@protected
Widget buildSliverAppBar(BuildParameters params) {
var leading = builder.tryBuildWidget(params.context,
params.widgets["leading"], params.state, params.parentContext);
leading ??= params.buildProp("leadingIcon");
var title = builder.tryBuildWidget(params.context,
params.widgets["titleWidget"], params.state, params.parentContext);
if (title == null && params.props["title"] != null) {
title = Text(properties.getText(params.props["title"], "appBar"));
}
var bottom = builder.tryBuildWidget(params.context,
params.widgets["bottom"], params.state, params.parentContext);
if (bottom is! PreferredSizeWidget) {
bottom = null;
}
final actions = <Widget>[];
if (params.widgets["actions"] != null) {
for (Map actionSpec in params.widgets["actions"] as List<Map>) {
actions.add(builder.buildWidget(
params.context, actionSpec, params.state, params.parentContext));
}
}
final flexible = FlexibleSpaceBar(
title: title,
centerTitle: tryParseBool(params.props["centerTitle"]),
titlePadding: params.buildProp("titlePadding"),
expandedTitleScale:
parseDouble(params.props["expandedTitleScale"], defaultValue: 1.5),
collapseMode: params.buildProp("collapseMode") ?? CollapseMode.parallax,
stretchModes: [
params.buildProp("stretchMode") ?? StretchMode.zoomBackground
],
background: builder.tryBuildWidget(params.context,
params.widgets["background"], params.state, params.parentContext),
);
final systemUiOverlayStyleProp = params.props["systemUiOverlayStyle"];
final systemUiOverlayStyle = systemUiOverlayStyleProp == null
? null
: systemUiOverlayStyleProp == "dark"
? SystemUiOverlayStyle.dark
: SystemUiOverlayStyle.light;
return SliverAppBar(
key: properties.getKey(params.id),
backgroundColor: tryParseColor(params.props["backgroundColor"]),
foregroundColor: tryParseColor(params.props["foregroundColor"]),
systemOverlayStyle: systemUiOverlayStyle,
//title: title,
//centerTitle: tryParseBool(params.props["centerTitle"]),
elevation: tryParseDouble(params.props["elevation"]),
scrolledUnderElevation:
tryParseDouble(params.props["scrolledUnderElevation"]),
leading: leading,
bottom: bottom != null ? bottom as PreferredSizeWidget : null,
//toolbarHeight: tryParseDouble(params.props["toolbarHeight"]),
actions: actions,
expandedHeight: tryParseDouble(params.props["expandedHeight"]),
collapsedHeight: tryParseDouble(params.props["collapsedHeight"]),
//onStretchTrigger: params.actions["onStretchTrigger"] != null ? widgetEvents.getFunction(params.context, params.actions["onStretchTrigger"], params.state) : null,
floating: parseBool(params.props["floating"]),
pinned: parseBool(params.props["pinned"]),
snap: parseBool(params.props["snap"]) &&
parseBool(params.props["floating"]),
stretch: parseBool(params.props["stretch"]),
flexibleSpace: flexible,
);
}