buildByMaterial method

  1. @override
Widget buildByMaterial(
  1. BuildContext context
)

build on material mode

Implementation

@override
Widget buildByMaterial(BuildContext context) {
  final Widget? _title = valueOf('title', title) ?? valueOf('middle', middle);
  Widget? _leading = valueOf('leading', leading);
  final EdgeInsetsDirectional? _padding = valueOf(
    'padding',
    padding,
  );
  if (_padding != null && _leading != null) {
    _leading = Padding(
      padding: EdgeInsets.only(left: _padding.start),
      child: _leading,
    );
  }
  // If actions is null and trailing is not null, set trailing = [ trailing ];
  List<Widget>? _actions = valueOf('actions', actions);
  final Widget? _trailing = valueOf('trailing', trailing);
  if (_actions == null && _trailing != null) {
    _actions = <Widget>[_trailing];
  }

  final BaseThemeData baseTheme = BaseTheme.of(context);
  final ThemeData theme =
      MediaQuery.of(context).platformBrightness == Brightness.light
          ? (baseTheme.materialTheme ?? Theme.of(context))
          : (baseTheme.materialDarkTheme ??
              Theme.of(context).copyWith(
                brightness: Brightness.dark,
              ));

  // Material 3 Color Scheme Integration
  final ColorScheme colorScheme = theme.colorScheme;
  final Color? _backgroundColor =
      valueOf('backgroundColor', backgroundColor) ??
          (theme.useMaterial3 ? colorScheme.surface : null);

  // Material 3 Semantic Shadow Color
  final Color? _shadowColor = valueOf('shadowColor', shadowColor) ??
      (theme.useMaterial3 ? colorScheme.shadow : null);

  // Material 3 Foreground Color from Color Scheme
  final Color? _foregroundColor =
      valueOf('foregroundColor', foregroundColor) ??
          (theme.useMaterial3 ? colorScheme.onSurface : null);

  // Material 3 Enhanced Elevation
  final double? _elevation =
      valueOf('elevation', elevation) ?? (theme.useMaterial3 ? 3.0 : 4.0);

  final double? _height = valueOf('height', height) ??
      baseTheme.valueOf('appBarHeight', baseTheme.appBarHeight);
  final bool centerTitle = this.centerTitle ??
      theme.appBarTheme.centerTitle ??
      theme.platform == TargetPlatform.iOS;

  return AppBar(
    leading: _leading,
    automaticallyImplyLeading: valueOf(
      'automaticallyImplyLeading',
      automaticallyImplyLeading,
    ),
    title: _title,
    actions: _actions,
    flexibleSpace: valueOf('flexibleSpace', flexibleSpace),
    bottom: valueOf('bottom', bottom),
    elevation: _elevation,
    shadowColor: _shadowColor,
    shape: valueOf('shape', shape),
    backgroundColor: _backgroundColor,
    foregroundColor: _foregroundColor,
    iconTheme: valueOf('iconTheme', iconTheme),
    actionsIconTheme: valueOf('actionsIconTheme', actionsIconTheme),
    textTheme: valueOf('textTheme', textTheme),
    primary: valueOf('primary', primary),
    centerTitle: centerTitle,
    excludeHeaderSemantics:
        valueOf('excludeHeaderSemantics', excludeHeaderSemantics),
    titleSpacing: valueOf('titleSpacing', titleSpacing),
    toolbarOpacity: valueOf('toolbarOpacity', toolbarOpacity),
    bottomOpacity: valueOf('bottomOpacity', bottomOpacity),
    toolbarHeight: _height,
    toolbarTextStyle: valueOf('toolbarTextStyle', toolbarTextStyle),
    titleTextStyle: valueOf('titleTextStyle', titleTextStyle),
    systemOverlayStyle: valueOf('systemOverlayStyle', systemOverlayStyle),
  );
}