AppBar constructor Null safety

AppBar(
  1. {Key? key,
  2. Widget? leading,
  3. bool automaticallyImplyLeading = true,
  4. Widget? title,
  5. List<Widget>? actions,
  6. Widget? flexibleSpace,
  7. PreferredSizeWidget? bottom,
  8. double? elevation,
  9. double? scrolledUnderElevation,
  10. ScrollNotificationPredicate notificationPredicate = defaultScrollNotificationPredicate,
  11. Color? shadowColor,
  12. Color? surfaceTintColor,
  13. ShapeBorder? shape,
  14. Color? backgroundColor,
  15. Color? foregroundColor,
  16. @Deprecated('This property is no longer used, please use systemOverlayStyle instead. ' 'This feature was deprecated after v2.4.0-0.0.pre.') Brightness? brightness,
  17. IconThemeData? iconTheme,
  18. IconThemeData? actionsIconTheme,
  19. @Deprecated('This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. ' 'This feature was deprecated after v2.4.0-0.0.pre.') TextTheme? textTheme,
  20. bool primary = true,
  21. bool? centerTitle,
  22. bool excludeHeaderSemantics = false,
  23. double? titleSpacing,
  24. double toolbarOpacity = 1.0,
  25. double bottomOpacity = 1.0,
  26. double? toolbarHeight,
  27. double? leadingWidth,
  28. @Deprecated('This property is obsolete and is false by default. ' 'This feature was deprecated after v2.4.0-0.0.pre.') bool? backwardsCompatibility,
  29. TextStyle? toolbarTextStyle,
  30. TextStyle? titleTextStyle,
  31. SystemUiOverlayStyle? systemOverlayStyle}
)

Creates a Material Design app bar.

The arguments primary, toolbarOpacity, bottomOpacity, backwardsCompatibility, and automaticallyImplyLeading must not be null. Additionally, if elevation is specified, it must be non-negative.

Typically used in the Scaffold.appBar property.

Implementation

AppBar({
  super.key,
  this.leading,
  this.automaticallyImplyLeading = true,
  this.title,
  this.actions,
  this.flexibleSpace,
  this.bottom,
  this.elevation,
  this.scrolledUnderElevation,
  this.notificationPredicate = defaultScrollNotificationPredicate,
  this.shadowColor,
  this.surfaceTintColor,
  this.shape,
  this.backgroundColor,
  this.foregroundColor,
  @Deprecated(
    'This property is no longer used, please use systemOverlayStyle instead. '
    'This feature was deprecated after v2.4.0-0.0.pre.',
  )
  this.brightness,
  this.iconTheme,
  this.actionsIconTheme,
  @Deprecated(
    'This property is no longer used, please use toolbarTextStyle and titleTextStyle instead. '
    'This feature was deprecated after v2.4.0-0.0.pre.',
  )
  this.textTheme,
  this.primary = true,
  this.centerTitle,
  this.excludeHeaderSemantics = false,
  this.titleSpacing,
  this.toolbarOpacity = 1.0,
  this.bottomOpacity = 1.0,
  this.toolbarHeight,
  this.leadingWidth,
  @Deprecated(
    'This property is obsolete and is false by default. '
    'This feature was deprecated after v2.4.0-0.0.pre.',
  )
  this.backwardsCompatibility,
  this.toolbarTextStyle,
  this.titleTextStyle,
  this.systemOverlayStyle,
}) : assert(automaticallyImplyLeading != null),
     assert(elevation == null || elevation >= 0.0),
     assert(notificationPredicate != null),
     assert(primary != null),
     assert(toolbarOpacity != null),
     assert(bottomOpacity != null),
     preferredSize = _PreferredAppBarSize(toolbarHeight, bottom?.preferredSize.height);