Unverified Commit c14ab91f authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Reland "migrate some material files to nullsafety (#67078)" (#67318)

parent aa90dbe7
This diff is collapsed.
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -46,54 +44,54 @@ class AppBarTheme with Diagnosticable { ...@@ -46,54 +44,54 @@ class AppBarTheme with Diagnosticable {
/// Default value for [AppBar.brightness]. /// Default value for [AppBar.brightness].
/// ///
/// If null, [AppBar] uses [ThemeData.primaryColorBrightness]. /// If null, [AppBar] uses [ThemeData.primaryColorBrightness].
final Brightness brightness; final Brightness? brightness;
/// Default value for [AppBar.backgroundColor]. /// Default value for [AppBar.backgroundColor].
/// ///
/// If null, [AppBar] uses [ThemeData.primaryColor]. /// If null, [AppBar] uses [ThemeData.primaryColor].
final Color color; final Color? color;
/// Default value for [AppBar.elevation]. /// Default value for [AppBar.elevation].
/// ///
/// If null, [AppBar] uses a default value of 4.0. /// If null, [AppBar] uses a default value of 4.0.
final double elevation; final double? elevation;
/// Default value for [AppBar.shadowColor]. /// Default value for [AppBar.shadowColor].
/// ///
/// If null, [AppBar] uses a default value of fully opaque black. /// If null, [AppBar] uses a default value of fully opaque black.
final Color shadowColor; final Color? shadowColor;
/// Default value for [AppBar.iconTheme]. /// Default value for [AppBar.iconTheme].
/// ///
/// If null, [AppBar] uses [ThemeData.primaryIconTheme]. /// If null, [AppBar] uses [ThemeData.primaryIconTheme].
final IconThemeData iconTheme; final IconThemeData? iconTheme;
/// Default value for [AppBar.actionsIconTheme]. /// Default value for [AppBar.actionsIconTheme].
/// ///
/// If null, [AppBar] uses [ThemeData.primaryIconTheme]. /// If null, [AppBar] uses [ThemeData.primaryIconTheme].
final IconThemeData actionsIconTheme; final IconThemeData? actionsIconTheme;
/// Default value for [AppBar.textTheme]. /// Default value for [AppBar.textTheme].
/// ///
/// If null, [AppBar] uses [ThemeData.primaryTextTheme]. /// If null, [AppBar] uses [ThemeData.primaryTextTheme].
final TextTheme textTheme; final TextTheme? textTheme;
/// Default value for [AppBar.centerTitle]. /// Default value for [AppBar.centerTitle].
/// ///
/// If null, the value is adapted to current [TargetPlatform]. /// If null, the value is adapted to current [TargetPlatform].
final bool centerTitle; final bool? centerTitle;
/// Creates a copy of this object with the given fields replaced with the /// Creates a copy of this object with the given fields replaced with the
/// new values. /// new values.
AppBarTheme copyWith({ AppBarTheme copyWith({
IconThemeData actionsIconTheme, IconThemeData? actionsIconTheme,
Brightness brightness, Brightness? brightness,
Color color, Color? color,
double elevation, double? elevation,
Color shadowColor, Color? shadowColor,
IconThemeData iconTheme, IconThemeData? iconTheme,
TextTheme textTheme, TextTheme? textTheme,
bool centerTitle, bool? centerTitle,
}) { }) {
return AppBarTheme( return AppBarTheme(
brightness: brightness ?? this.brightness, brightness: brightness ?? this.brightness,
...@@ -109,7 +107,7 @@ class AppBarTheme with Diagnosticable { ...@@ -109,7 +107,7 @@ class AppBarTheme with Diagnosticable {
/// The [ThemeData.appBarTheme] property of the ambient [Theme]. /// The [ThemeData.appBarTheme] property of the ambient [Theme].
static AppBarTheme of(BuildContext context) { static AppBarTheme of(BuildContext context) {
return Theme.of(context).appBarTheme; return Theme.of(context)!.appBarTheme;
} }
/// Linearly interpolate between two AppBar themes. /// Linearly interpolate between two AppBar themes.
...@@ -117,7 +115,7 @@ class AppBarTheme with Diagnosticable { ...@@ -117,7 +115,7 @@ class AppBarTheme with Diagnosticable {
/// The argument `t` must not be null. /// The argument `t` must not be null.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static AppBarTheme lerp(AppBarTheme a, AppBarTheme b, double t) { static AppBarTheme lerp(AppBarTheme? a, AppBarTheme? b, double t) {
assert(t != null); assert(t != null);
return AppBarTheme( return AppBarTheme(
brightness: t < 0.5 ? a?.brightness : b?.brightness, brightness: t < 0.5 ? a?.brightness : b?.brightness,
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'debug.dart'; import 'debug.dart';
...@@ -27,7 +25,7 @@ import 'theme.dart'; ...@@ -27,7 +25,7 @@ import 'theme.dart';
class BackButtonIcon extends StatelessWidget { class BackButtonIcon extends StatelessWidget {
/// Creates an icon that shows the appropriate "back" image for /// Creates an icon that shows the appropriate "back" image for
/// the current platform (as obtained from the [Theme]). /// the current platform (as obtained from the [Theme]).
const BackButtonIcon({ Key key }) : super(key: key); const BackButtonIcon({ Key? key }) : super(key: key);
/// Returns the appropriate "back" icon for the given `platform`. /// Returns the appropriate "back" icon for the given `platform`.
static IconData _getIconData(TargetPlatform platform) { static IconData _getIconData(TargetPlatform platform) {
...@@ -41,12 +39,10 @@ class BackButtonIcon extends StatelessWidget { ...@@ -41,12 +39,10 @@ class BackButtonIcon extends StatelessWidget {
case TargetPlatform.macOS: case TargetPlatform.macOS:
return Icons.arrow_back_ios; return Icons.arrow_back_ios;
} }
assert(false);
return null;
} }
@override @override
Widget build(BuildContext context) => Icon(_getIconData(Theme.of(context).platform)); Widget build(BuildContext context) => Icon(_getIconData(Theme.of(context)!.platform));
} }
/// A material design back button. /// A material design back button.
...@@ -78,13 +74,13 @@ class BackButtonIcon extends StatelessWidget { ...@@ -78,13 +74,13 @@ class BackButtonIcon extends StatelessWidget {
class BackButton extends StatelessWidget { class BackButton extends StatelessWidget {
/// Creates an [IconButton] with the appropriate "back" icon for the current /// Creates an [IconButton] with the appropriate "back" icon for the current
/// target platform. /// target platform.
const BackButton({ Key key, this.color, this.onPressed }) : super(key: key); const BackButton({ Key? key, this.color, this.onPressed }) : super(key: key);
/// The color to use for the icon. /// The color to use for the icon.
/// ///
/// Defaults to the [IconThemeData.color] specified in the ambient [IconTheme], /// Defaults to the [IconThemeData.color] specified in the ambient [IconTheme],
/// which usually matches the ambient [Theme]'s [ThemeData.iconTheme]. /// which usually matches the ambient [Theme]'s [ThemeData.iconTheme].
final Color color; final Color? color;
/// An override callback to perform instead of the default behavior which is /// An override callback to perform instead of the default behavior which is
/// to pop the [Navigator]. /// to pop the [Navigator].
...@@ -94,7 +90,7 @@ class BackButton extends StatelessWidget { ...@@ -94,7 +90,7 @@ class BackButton extends StatelessWidget {
/// situations. /// situations.
/// ///
/// Defaults to null. /// Defaults to null.
final VoidCallback onPressed; final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -102,10 +98,10 @@ class BackButton extends StatelessWidget { ...@@ -102,10 +98,10 @@ class BackButton extends StatelessWidget {
return IconButton( return IconButton(
icon: const BackButtonIcon(), icon: const BackButtonIcon(),
color: color, color: color,
tooltip: MaterialLocalizations.of(context).backButtonTooltip, tooltip: MaterialLocalizations.of(context)!.backButtonTooltip,
onPressed: () { onPressed: () {
if (onPressed != null) { if (onPressed != null) {
onPressed(); onPressed!();
} else { } else {
Navigator.maybePop(context); Navigator.maybePop(context);
} }
...@@ -132,13 +128,13 @@ class BackButton extends StatelessWidget { ...@@ -132,13 +128,13 @@ class BackButton extends StatelessWidget {
/// * [IconButton], to create other material design icon buttons. /// * [IconButton], to create other material design icon buttons.
class CloseButton extends StatelessWidget { class CloseButton extends StatelessWidget {
/// Creates a Material Design close button. /// Creates a Material Design close button.
const CloseButton({ Key key, this.color, this.onPressed }) : super(key: key); const CloseButton({ Key? key, this.color, this.onPressed }) : super(key: key);
/// The color to use for the icon. /// The color to use for the icon.
/// ///
/// Defaults to the [IconThemeData.color] specified in the ambient [IconTheme], /// Defaults to the [IconThemeData.color] specified in the ambient [IconTheme],
/// which usually matches the ambient [Theme]'s [ThemeData.iconTheme]. /// which usually matches the ambient [Theme]'s [ThemeData.iconTheme].
final Color color; final Color? color;
/// An override callback to perform instead of the default behavior which is /// An override callback to perform instead of the default behavior which is
/// to pop the [Navigator]. /// to pop the [Navigator].
...@@ -148,7 +144,7 @@ class CloseButton extends StatelessWidget { ...@@ -148,7 +144,7 @@ class CloseButton extends StatelessWidget {
/// situations. /// situations.
/// ///
/// Defaults to null. /// Defaults to null.
final VoidCallback onPressed; final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -156,10 +152,10 @@ class CloseButton extends StatelessWidget { ...@@ -156,10 +152,10 @@ class CloseButton extends StatelessWidget {
return IconButton( return IconButton(
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
color: color, color: color,
tooltip: MaterialLocalizations.of(context).closeButtonTooltip, tooltip: MaterialLocalizations.of(context)!.closeButtonTooltip,
onPressed: () { onPressed: () {
if (onPressed != null) { if (onPressed != null) {
onPressed(); onPressed!();
} else { } else {
Navigator.maybePop(context); Navigator.maybePop(context);
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'banner_theme.dart'; import 'banner_theme.dart';
...@@ -35,10 +33,10 @@ class MaterialBanner extends StatelessWidget { ...@@ -35,10 +33,10 @@ class MaterialBanner extends StatelessWidget {
/// The [actions], [content], and [forceActionsBelow] must be non-null. /// The [actions], [content], and [forceActionsBelow] must be non-null.
/// The [actions.length] must be greater than 0. /// The [actions.length] must be greater than 0.
const MaterialBanner({ const MaterialBanner({
Key key, Key? key,
@required this.content, required this.content,
this.contentTextStyle, this.contentTextStyle,
@required this.actions, required this.actions,
this.leading, this.leading,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,
...@@ -58,7 +56,7 @@ class MaterialBanner extends StatelessWidget { ...@@ -58,7 +56,7 @@ class MaterialBanner extends StatelessWidget {
/// ///
/// If `null`, [MaterialBannerThemeData.contentTextStyle] is used. If that is /// If `null`, [MaterialBannerThemeData.contentTextStyle] is used. If that is
/// also `null`, [TextTheme.bodyText2] of [ThemeData.textTheme] is used. /// also `null`, [TextTheme.bodyText2] of [ThemeData.textTheme] is used.
final TextStyle contentTextStyle; final TextStyle? contentTextStyle;
/// The set of actions that are displayed at the bottom or trailing side of /// The set of actions that are displayed at the bottom or trailing side of
/// the [MaterialBanner]. /// the [MaterialBanner].
...@@ -69,13 +67,13 @@ class MaterialBanner extends StatelessWidget { ...@@ -69,13 +67,13 @@ class MaterialBanner extends StatelessWidget {
/// The (optional) leading widget of the [MaterialBanner]. /// The (optional) leading widget of the [MaterialBanner].
/// ///
/// Typically an [Icon] widget. /// Typically an [Icon] widget.
final Widget leading; final Widget? leading;
/// The color of the surface of this [MaterialBanner]. /// The color of the surface of this [MaterialBanner].
/// ///
/// If `null`, [MaterialBannerThemeData.backgroundColor] is used. If that is /// If `null`, [MaterialBannerThemeData.backgroundColor] is used. If that is
/// also `null`, [ColorScheme.surface] of [ThemeData.colorScheme] is used. /// also `null`, [ColorScheme.surface] of [ThemeData.colorScheme] is used.
final Color backgroundColor; final Color? backgroundColor;
/// The amount of space by which to inset the [content]. /// The amount of space by which to inset the [content].
/// ///
...@@ -84,12 +82,12 @@ class MaterialBanner extends StatelessWidget { ...@@ -84,12 +82,12 @@ class MaterialBanner extends StatelessWidget {
/// ///
/// If the [actions] are trailing the [content], this defaults to /// If the [actions] are trailing the [content], this defaults to
/// `EdgeInsetsDirectional.only(start: 16.0, top: 2.0)`. /// `EdgeInsetsDirectional.only(start: 16.0, top: 2.0)`.
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
/// The amount of space by which to inset the [leading] widget. /// The amount of space by which to inset the [leading] widget.
/// ///
/// This defaults to `EdgeInsetsDirectional.only(end: 16.0)`. /// This defaults to `EdgeInsetsDirectional.only(end: 16.0)`.
final EdgeInsetsGeometry leadingPadding; final EdgeInsetsGeometry? leadingPadding;
/// An override to force the [actions] to be below the [content] regardless of /// An override to force the [actions] to be below the [content] regardless of
/// how many there are. /// how many there are.
...@@ -104,7 +102,7 @@ class MaterialBanner extends StatelessWidget { ...@@ -104,7 +102,7 @@ class MaterialBanner extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(actions.isNotEmpty); assert(actions.isNotEmpty);
final ThemeData theme = Theme.of(context); final ThemeData? theme = Theme.of(context);
final MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context); final MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context);
final bool isSingleRow = actions.length == 1 && !forceActionsBelow; final bool isSingleRow = actions.length == 1 && !forceActionsBelow;
...@@ -127,10 +125,10 @@ class MaterialBanner extends StatelessWidget { ...@@ -127,10 +125,10 @@ class MaterialBanner extends StatelessWidget {
final Color backgroundColor = this.backgroundColor final Color backgroundColor = this.backgroundColor
?? bannerTheme.backgroundColor ?? bannerTheme.backgroundColor
?? theme.colorScheme.surface; ?? theme!.colorScheme.surface;
final TextStyle textStyle = contentTextStyle final TextStyle? textStyle = contentTextStyle
?? bannerTheme.contentTextStyle ?? bannerTheme.contentTextStyle
?? theme.textTheme.bodyText2; ?? theme!.textTheme.bodyText2;
return Container( return Container(
color: backgroundColor, color: backgroundColor,
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -38,25 +36,25 @@ class MaterialBannerThemeData with Diagnosticable { ...@@ -38,25 +36,25 @@ class MaterialBannerThemeData with Diagnosticable {
}); });
/// The background color of a [MaterialBanner]. /// The background color of a [MaterialBanner].
final Color backgroundColor; final Color? backgroundColor;
/// Used to configure the [DefaultTextStyle] for the [MaterialBanner.content] /// Used to configure the [DefaultTextStyle] for the [MaterialBanner.content]
/// widget. /// widget.
final TextStyle contentTextStyle; final TextStyle? contentTextStyle;
/// The amount of space by which to inset [MaterialBanner.content]. /// The amount of space by which to inset [MaterialBanner.content].
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
/// The amount of space by which to inset [MaterialBanner.leading]. /// The amount of space by which to inset [MaterialBanner.leading].
final EdgeInsetsGeometry leadingPadding; final EdgeInsetsGeometry? leadingPadding;
/// Creates a copy of this object with the given fields replaced with the /// Creates a copy of this object with the given fields replaced with the
/// new values. /// new values.
MaterialBannerThemeData copyWith({ MaterialBannerThemeData copyWith({
Color backgroundColor, Color? backgroundColor,
TextStyle contentTextStyle, TextStyle? contentTextStyle,
EdgeInsetsGeometry padding, EdgeInsetsGeometry? padding,
EdgeInsetsGeometry leadingPadding, EdgeInsetsGeometry? leadingPadding,
}) { }) {
return MaterialBannerThemeData( return MaterialBannerThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColor: backgroundColor ?? this.backgroundColor,
...@@ -71,7 +69,7 @@ class MaterialBannerThemeData with Diagnosticable { ...@@ -71,7 +69,7 @@ class MaterialBannerThemeData with Diagnosticable {
/// The argument `t` must not be null. /// The argument `t` must not be null.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static MaterialBannerThemeData lerp(MaterialBannerThemeData a, MaterialBannerThemeData b, double t) { static MaterialBannerThemeData lerp(MaterialBannerThemeData? a, MaterialBannerThemeData? b, double t) {
assert(t != null); assert(t != null);
return MaterialBannerThemeData( return MaterialBannerThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
...@@ -123,13 +121,13 @@ class MaterialBannerTheme extends InheritedTheme { ...@@ -123,13 +121,13 @@ class MaterialBannerTheme extends InheritedTheme {
/// Creates a banner theme that controls the configurations for /// Creates a banner theme that controls the configurations for
/// [MaterialBanner]s in its widget subtree. /// [MaterialBanner]s in its widget subtree.
const MaterialBannerTheme({ const MaterialBannerTheme({
Key key, Key? key,
this.data, this.data,
Widget child, required Widget child,
}) : super(key: key, child: child); }) : super(key: key, child: child);
/// The properties for descendant [MaterialBanner] widgets. /// The properties for descendant [MaterialBanner] widgets.
final MaterialBannerThemeData data; final MaterialBannerThemeData? data;
/// The closest instance of this class's [data] value that encloses the given /// The closest instance of this class's [data] value that encloses the given
/// context. /// context.
...@@ -143,13 +141,13 @@ class MaterialBannerTheme extends InheritedTheme { ...@@ -143,13 +141,13 @@ class MaterialBannerTheme extends InheritedTheme {
/// MaterialBannerThemeData theme = MaterialBannerTheme.of(context); /// MaterialBannerThemeData theme = MaterialBannerTheme.of(context);
/// ``` /// ```
static MaterialBannerThemeData of(BuildContext context) { static MaterialBannerThemeData of(BuildContext context) {
final MaterialBannerTheme bannerTheme = context.dependOnInheritedWidgetOfExactType<MaterialBannerTheme>(); final MaterialBannerTheme? bannerTheme = context.dependOnInheritedWidgetOfExactType<MaterialBannerTheme>();
return bannerTheme?.data ?? Theme.of(context).bannerTheme; return bannerTheme?.data ?? Theme.of(context)!.bannerTheme;
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final MaterialBannerTheme ancestorTheme = context.findAncestorWidgetOfExactType<MaterialBannerTheme>(); final MaterialBannerTheme? ancestorTheme = context.findAncestorWidgetOfExactType<MaterialBannerTheme>();
return identical(this, ancestorTheme) ? child : MaterialBannerTheme(data: data, child: child); return identical(this, ancestorTheme) ? child : MaterialBannerTheme(data: data, child: child);
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -50,7 +48,7 @@ class BottomAppBar extends StatefulWidget { ...@@ -50,7 +48,7 @@ class BottomAppBar extends StatefulWidget {
/// If the corresponding [BottomAppBarTheme] property is null, then the default /// If the corresponding [BottomAppBarTheme] property is null, then the default
/// specified in the property's documentation will be used. /// specified in the property's documentation will be used.
const BottomAppBar({ const BottomAppBar({
Key key, Key? key,
this.color, this.color,
this.elevation, this.elevation,
this.shape, this.shape,
...@@ -68,14 +66,14 @@ class BottomAppBar extends StatefulWidget { ...@@ -68,14 +66,14 @@ class BottomAppBar extends StatefulWidget {
/// ///
/// Typically this the child will be a [Row], with the first child /// Typically this the child will be a [Row], with the first child
/// being an [IconButton] with the [Icons.menu] icon. /// being an [IconButton] with the [Icons.menu] icon.
final Widget child; final Widget? child;
/// The bottom app bar's background color. /// The bottom app bar's background color.
/// ///
/// If this property is null then [BottomAppBarTheme.color] of /// If this property is null then [BottomAppBarTheme.color] of
/// [ThemeData.bottomAppBarTheme] is used. If that's null then /// [ThemeData.bottomAppBarTheme] is used. If that's null then
/// [ThemeData.bottomAppBarColor] is used. /// [ThemeData.bottomAppBarColor] is used.
final Color color; final Color? color;
/// The z-coordinate at which to place this bottom app bar relative to its /// The z-coordinate at which to place this bottom app bar relative to its
/// parent. /// parent.
...@@ -86,14 +84,14 @@ class BottomAppBar extends StatefulWidget { ...@@ -86,14 +84,14 @@ class BottomAppBar extends StatefulWidget {
/// If this property is null then [BottomAppBarTheme.elevation] of /// If this property is null then [BottomAppBarTheme.elevation] of
/// [ThemeData.bottomAppBarTheme] is used. If that's null, the default value /// [ThemeData.bottomAppBarTheme] is used. If that's null, the default value
/// is 8. /// is 8.
final double elevation; final double? elevation;
/// The notch that is made for the floating action button. /// The notch that is made for the floating action button.
/// ///
/// If this property is null then [BottomAppBarTheme.shape] of /// If this property is null then [BottomAppBarTheme.shape] of
/// [ThemeData.bottomAppBarTheme] is used. If that's null then the shape will /// [ThemeData.bottomAppBarTheme] is used. If that's null then the shape will
/// be rectangular with no notch. /// be rectangular with no notch.
final NotchedShape shape; final NotchedShape? shape;
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
/// ///
...@@ -111,7 +109,7 @@ class BottomAppBar extends StatefulWidget { ...@@ -111,7 +109,7 @@ class BottomAppBar extends StatefulWidget {
} }
class _BottomAppBarState extends State<BottomAppBar> { class _BottomAppBarState extends State<BottomAppBar> {
ValueListenable<ScaffoldGeometry> geometryListenable; late ValueListenable<ScaffoldGeometry> geometryListenable;
static const double _defaultElevation = 8.0; static const double _defaultElevation = 8.0;
@override @override
...@@ -123,7 +121,7 @@ class _BottomAppBarState extends State<BottomAppBar> { ...@@ -123,7 +121,7 @@ class _BottomAppBarState extends State<BottomAppBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final BottomAppBarTheme babTheme = BottomAppBarTheme.of(context); final BottomAppBarTheme babTheme = BottomAppBarTheme.of(context);
final NotchedShape notchedShape = widget.shape ?? babTheme.shape; final NotchedShape? notchedShape = widget.shape ?? babTheme.shape;
final CustomClipper<Path> clipper = notchedShape != null final CustomClipper<Path> clipper = notchedShape != null
? _BottomAppBarClipper( ? _BottomAppBarClipper(
geometry: geometryListenable, geometry: geometryListenable,
...@@ -132,7 +130,7 @@ class _BottomAppBarState extends State<BottomAppBar> { ...@@ -132,7 +130,7 @@ class _BottomAppBarState extends State<BottomAppBar> {
) )
: const ShapeBorderClipper(shape: RoundedRectangleBorder()); : const ShapeBorderClipper(shape: RoundedRectangleBorder());
final double elevation = widget.elevation ?? babTheme.elevation ?? _defaultElevation; final double elevation = widget.elevation ?? babTheme.elevation ?? _defaultElevation;
final Color color = widget.color ?? babTheme.color ?? Theme.of(context).bottomAppBarColor; final Color color = widget.color ?? babTheme.color ?? Theme.of(context)!.bottomAppBarColor;
final Color effectiveColor = ElevationOverlay.applyOverlay(context, color, elevation); final Color effectiveColor = ElevationOverlay.applyOverlay(context, color, elevation);
return PhysicalShape( return PhysicalShape(
clipper: clipper, clipper: clipper,
...@@ -143,7 +141,7 @@ class _BottomAppBarState extends State<BottomAppBar> { ...@@ -143,7 +141,7 @@ class _BottomAppBarState extends State<BottomAppBar> {
type: MaterialType.transparency, type: MaterialType.transparency,
child: widget.child == null child: widget.child == null
? null ? null
: SafeArea(child: widget.child), : SafeArea(child: widget.child!),
), ),
); );
} }
...@@ -151,9 +149,9 @@ class _BottomAppBarState extends State<BottomAppBar> { ...@@ -151,9 +149,9 @@ class _BottomAppBarState extends State<BottomAppBar> {
class _BottomAppBarClipper extends CustomClipper<Path> { class _BottomAppBarClipper extends CustomClipper<Path> {
const _BottomAppBarClipper({ const _BottomAppBarClipper({
@required this.geometry, required this.geometry,
@required this.shape, required this.shape,
@required this.notchMargin, required this.notchMargin,
}) : assert(geometry != null), }) : assert(geometry != null),
assert(shape != null), assert(shape != null),
assert(notchMargin != null), assert(notchMargin != null),
...@@ -168,9 +166,9 @@ class _BottomAppBarClipper extends CustomClipper<Path> { ...@@ -168,9 +166,9 @@ class _BottomAppBarClipper extends CustomClipper<Path> {
// button is the floating action button's bounding rectangle in the // button is the floating action button's bounding rectangle in the
// coordinate system whose origin is at the appBar's top left corner, // coordinate system whose origin is at the appBar's top left corner,
// or null if there is no floating action button. // or null if there is no floating action button.
final Rect button = geometry.value.floatingActionButtonArea?.translate( final Rect? button = geometry.value.floatingActionButtonArea?.translate(
0.0, 0.0,
geometry.value.bottomNavigationBarTop * -1.0, geometry.value.bottomNavigationBarTop! * -1.0,
); );
return shape.getOuterPath(Offset.zero & size, button?.inflate(notchMargin)); return shape.getOuterPath(Offset.zero & size, button?.inflate(notchMargin));
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -39,20 +37,20 @@ class BottomAppBarTheme with Diagnosticable { ...@@ -39,20 +37,20 @@ class BottomAppBarTheme with Diagnosticable {
/// Default value for [BottomAppBar.color]. /// Default value for [BottomAppBar.color].
/// ///
/// If null, [BottomAppBar] uses [ThemeData.bottomAppBarColor]. /// If null, [BottomAppBar] uses [ThemeData.bottomAppBarColor].
final Color color; final Color? color;
/// Default value for [BottomAppBar.elevation]. /// Default value for [BottomAppBar.elevation].
final double elevation; final double? elevation;
/// Default value for [BottomAppBar.shape]. /// Default value for [BottomAppBar.shape].
final NotchedShape shape; final NotchedShape? shape;
/// Creates a copy of this object but with the given fields replaced with the /// Creates a copy of this object but with the given fields replaced with the
/// new values. /// new values.
BottomAppBarTheme copyWith({ BottomAppBarTheme copyWith({
Color color, Color? color,
double elevation, double? elevation,
NotchedShape shape, NotchedShape? shape,
}) { }) {
return BottomAppBarTheme( return BottomAppBarTheme(
color: color ?? this.color, color: color ?? this.color,
...@@ -63,7 +61,7 @@ class BottomAppBarTheme with Diagnosticable { ...@@ -63,7 +61,7 @@ class BottomAppBarTheme with Diagnosticable {
/// The [ThemeData.bottomAppBarTheme] property of the ambient [Theme]. /// The [ThemeData.bottomAppBarTheme] property of the ambient [Theme].
static BottomAppBarTheme of(BuildContext context) { static BottomAppBarTheme of(BuildContext context) {
return Theme.of(context).bottomAppBarTheme; return Theme.of(context)!.bottomAppBarTheme;
} }
/// Linearly interpolate between two BAB themes. /// Linearly interpolate between two BAB themes.
...@@ -71,7 +69,7 @@ class BottomAppBarTheme with Diagnosticable { ...@@ -71,7 +69,7 @@ class BottomAppBarTheme with Diagnosticable {
/// The argument `t` must not be null. /// The argument `t` must not be null.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static BottomAppBarTheme lerp(BottomAppBarTheme a, BottomAppBarTheme b, double t) { static BottomAppBarTheme lerp(BottomAppBarTheme? a, BottomAppBarTheme? b, double t) {
assert(t != null); assert(t != null);
return BottomAppBarTheme( return BottomAppBarTheme(
color: Color.lerp(a?.color, b?.color, t), color: Color.lerp(a?.color, b?.color, t),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -50,78 +48,78 @@ class BottomNavigationBarThemeData with Diagnosticable { ...@@ -50,78 +48,78 @@ class BottomNavigationBarThemeData with Diagnosticable {
/// The color of the [BottomNavigationBar] itself. /// The color of the [BottomNavigationBar] itself.
/// ///
/// See [BottomNavigationBar.backgroundColor]. /// See [BottomNavigationBar.backgroundColor].
final Color backgroundColor; final Color? backgroundColor;
/// The z-coordinate of the [BottomNavigationBar]. /// The z-coordinate of the [BottomNavigationBar].
/// ///
/// See [BottomNavigationBar.elevation]. /// See [BottomNavigationBar.elevation].
final double elevation; final double? elevation;
/// The size, opacity, and color of the icon in the currently selected /// The size, opacity, and color of the icon in the currently selected
/// [BottomNavigationBarItem.icon]. /// [BottomNavigationBarItem.icon].
/// ///
/// See [BottomNavigationBar.selectedIconTheme]. /// See [BottomNavigationBar.selectedIconTheme].
final IconThemeData selectedIconTheme; final IconThemeData? selectedIconTheme;
/// The size, opacity, and color of the icon in the currently unselected /// The size, opacity, and color of the icon in the currently unselected
/// [BottomNavigationBarItem.icon]s. /// [BottomNavigationBarItem.icon]s.
/// ///
/// See [BottomNavigationBar.unselectedIconTheme]. /// See [BottomNavigationBar.unselectedIconTheme].
final IconThemeData unselectedIconTheme; final IconThemeData? unselectedIconTheme;
/// The color of the selected [BottomNavigationBarItem.icon] and /// The color of the selected [BottomNavigationBarItem.icon] and
/// [BottomNavigationBarItem.title]. /// [BottomNavigationBarItem.title].
/// ///
/// See [BottomNavigationBar.selectedItemColor]. /// See [BottomNavigationBar.selectedItemColor].
final Color selectedItemColor; final Color? selectedItemColor;
/// The color of the unselected [BottomNavigationBarItem.icon] and /// The color of the unselected [BottomNavigationBarItem.icon] and
/// [BottomNavigationBarItem.title]s. /// [BottomNavigationBarItem.title]s.
/// ///
/// See [BottomNavigationBar.unselectedItemColor]. /// See [BottomNavigationBar.unselectedItemColor].
final Color unselectedItemColor; final Color? unselectedItemColor;
/// The [TextStyle] of the [BottomNavigationBarItem] labels when they are /// The [TextStyle] of the [BottomNavigationBarItem] labels when they are
/// selected. /// selected.
/// ///
/// See [BottomNavigationBar.selectedLabelStyle]. /// See [BottomNavigationBar.selectedLabelStyle].
final TextStyle selectedLabelStyle; final TextStyle? selectedLabelStyle;
/// The [TextStyle] of the [BottomNavigationBarItem] labels when they are not /// The [TextStyle] of the [BottomNavigationBarItem] labels when they are not
/// selected. /// selected.
/// ///
/// See [BottomNavigationBar.unselectedLabelStyle]. /// See [BottomNavigationBar.unselectedLabelStyle].
final TextStyle unselectedLabelStyle; final TextStyle? unselectedLabelStyle;
/// Whether the labels are shown for the unselected [BottomNavigationBarItem]s. /// Whether the labels are shown for the unselected [BottomNavigationBarItem]s.
/// ///
/// See [BottomNavigationBar.showSelectedLabels]. /// See [BottomNavigationBar.showSelectedLabels].
final bool showSelectedLabels; final bool? showSelectedLabels;
/// Whether the labels are shown for the selected [BottomNavigationBarItem]. /// Whether the labels are shown for the selected [BottomNavigationBarItem].
/// ///
/// See [BottomNavigationBar.showUnselectedLabels]. /// See [BottomNavigationBar.showUnselectedLabels].
final bool showUnselectedLabels; final bool? showUnselectedLabels;
/// Defines the layout and behavior of a [BottomNavigationBar]. /// Defines the layout and behavior of a [BottomNavigationBar].
/// ///
/// See [BottomNavigationBar.type]. /// See [BottomNavigationBar.type].
final BottomNavigationBarType type; final BottomNavigationBarType? type;
/// Creates a copy of this object but with the given fields replaced with the /// Creates a copy of this object but with the given fields replaced with the
/// new values. /// new values.
BottomNavigationBarThemeData copyWith({ BottomNavigationBarThemeData copyWith({
Color backgroundColor, Color? backgroundColor,
double elevation, double? elevation,
IconThemeData selectedIconTheme, IconThemeData? selectedIconTheme,
IconThemeData unselectedIconTheme, IconThemeData? unselectedIconTheme,
Color selectedItemColor, Color? selectedItemColor,
Color unselectedItemColor, Color? unselectedItemColor,
TextStyle selectedLabelStyle, TextStyle? selectedLabelStyle,
TextStyle unselectedLabelStyle, TextStyle? unselectedLabelStyle,
bool showSelectedLabels, bool? showSelectedLabels,
bool showUnselectedLabels, bool? showUnselectedLabels,
BottomNavigationBarType type, BottomNavigationBarType? type,
}) { }) {
return BottomNavigationBarThemeData( return BottomNavigationBarThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColor: backgroundColor ?? this.backgroundColor,
...@@ -143,7 +141,7 @@ class BottomNavigationBarThemeData with Diagnosticable { ...@@ -143,7 +141,7 @@ class BottomNavigationBarThemeData with Diagnosticable {
/// The argument `t` must not be null. /// The argument `t` must not be null.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static BottomNavigationBarThemeData lerp(BottomNavigationBarThemeData a, BottomNavigationBarThemeData b, double t) { static BottomNavigationBarThemeData lerp(BottomNavigationBarThemeData? a, BottomNavigationBarThemeData? b, double t) {
assert(t != null); assert(t != null);
return BottomNavigationBarThemeData( return BottomNavigationBarThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
...@@ -235,9 +233,9 @@ class BottomNavigationBarTheme extends InheritedWidget { ...@@ -235,9 +233,9 @@ class BottomNavigationBarTheme extends InheritedWidget {
/// ///
/// The [data] must not be null. /// The [data] must not be null.
const BottomNavigationBarTheme({ const BottomNavigationBarTheme({
Key key, Key? key,
@required this.data, required this.data,
Widget child, required Widget child,
}) : assert(data != null), super(key: key, child: child); }) : assert(data != null), super(key: key, child: child);
/// The properties used for all descendant [BottomNavigationBar] widgets. /// The properties used for all descendant [BottomNavigationBar] widgets.
...@@ -254,8 +252,8 @@ class BottomNavigationBarTheme extends InheritedWidget { ...@@ -254,8 +252,8 @@ class BottomNavigationBarTheme extends InheritedWidget {
/// BottomNavigationBarThemeData theme = BottomNavigationBarTheme.of(context); /// BottomNavigationBarThemeData theme = BottomNavigationBarTheme.of(context);
/// ``` /// ```
static BottomNavigationBarThemeData of(BuildContext context) { static BottomNavigationBarThemeData of(BuildContext context) {
final BottomNavigationBarTheme bottomNavTheme = context.dependOnInheritedWidgetOfExactType<BottomNavigationBarTheme>(); final BottomNavigationBarTheme? bottomNavTheme = context.dependOnInheritedWidgetOfExactType<BottomNavigationBarTheme>();
return bottomNavTheme?.data ?? Theme.of(context).bottomNavigationBarTheme; return bottomNavTheme?.data ?? Theme.of(context)!.bottomNavigationBarTheme;
} }
@override @override
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -51,8 +49,8 @@ class RawMaterialButton extends StatefulWidget { ...@@ -51,8 +49,8 @@ class RawMaterialButton extends StatefulWidget {
/// [elevation], [focusElevation], [hoverElevation], [highlightElevation], and /// [elevation], [focusElevation], [hoverElevation], [highlightElevation], and
/// [disabledElevation] must be non-negative. /// [disabledElevation] must be non-negative.
const RawMaterialButton({ const RawMaterialButton({
Key key, Key? key,
@required this.onPressed, required this.onPressed,
this.onLongPress, this.onLongPress,
this.onHighlightChanged, this.onHighlightChanged,
this.mouseCursor, this.mouseCursor,
...@@ -75,7 +73,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -75,7 +73,7 @@ class RawMaterialButton extends StatefulWidget {
this.clipBehavior = Clip.none, this.clipBehavior = Clip.none,
this.focusNode, this.focusNode,
this.autofocus = false, this.autofocus = false,
MaterialTapTargetSize materialTapTargetSize, MaterialTapTargetSize? materialTapTargetSize,
this.child, this.child,
this.enableFeedback = true, this.enableFeedback = true,
}) : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded, }) : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded,
...@@ -99,7 +97,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -99,7 +97,7 @@ class RawMaterialButton extends StatefulWidget {
/// See also: /// See also:
/// ///
/// * [enabled], which is true if the button is enabled. /// * [enabled], which is true if the button is enabled.
final VoidCallback onPressed; final VoidCallback? onPressed;
/// Called when the button is long-pressed. /// Called when the button is long-pressed.
/// ///
...@@ -108,7 +106,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -108,7 +106,7 @@ class RawMaterialButton extends StatefulWidget {
/// See also: /// See also:
/// ///
/// * [enabled], which is true if the button is enabled. /// * [enabled], which is true if the button is enabled.
final VoidCallback onLongPress; final VoidCallback? onLongPress;
/// Called by the underlying [InkWell] widget's [InkWell.onHighlightChanged] /// Called by the underlying [InkWell] widget's [InkWell.onHighlightChanged]
/// callback. /// callback.
...@@ -116,7 +114,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -116,7 +114,7 @@ class RawMaterialButton extends StatefulWidget {
/// If [onPressed] changes from null to non-null while a gesture is ongoing, /// If [onPressed] changes from null to non-null while a gesture is ongoing,
/// this can fire during the build phase (in which case calling /// this can fire during the build phase (in which case calling
/// [State.setState] is not allowed). /// [State.setState] is not allowed).
final ValueChanged<bool> onHighlightChanged; final ValueChanged<bool>? onHighlightChanged;
/// {@template flutter.material.button.mouseCursor} /// {@template flutter.material.button.mouseCursor}
/// The cursor for a mouse pointer when it enters or is hovering over the /// The cursor for a mouse pointer when it enters or is hovering over the
...@@ -132,7 +130,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -132,7 +130,7 @@ class RawMaterialButton extends StatefulWidget {
/// ///
/// If this property is null, [MaterialStateMouseCursor.clickable] will be used. /// If this property is null, [MaterialStateMouseCursor.clickable] will be used.
/// {@endtemplate} /// {@endtemplate}
final MouseCursor mouseCursor; final MouseCursor? mouseCursor;
/// Defines the default text style, with [Material.textStyle], for the /// Defines the default text style, with [Material.textStyle], for the
/// button's [child]. /// button's [child].
...@@ -144,22 +142,22 @@ class RawMaterialButton extends StatefulWidget { ...@@ -144,22 +142,22 @@ class RawMaterialButton extends StatefulWidget {
/// * [MaterialState.hovered]. /// * [MaterialState.hovered].
/// * [MaterialState.focused]. /// * [MaterialState.focused].
/// * [MaterialState.disabled]. /// * [MaterialState.disabled].
final TextStyle textStyle; final TextStyle? textStyle;
/// The color of the button's [Material]. /// The color of the button's [Material].
final Color fillColor; final Color? fillColor;
/// The color for the button's [Material] when it has the input focus. /// The color for the button's [Material] when it has the input focus.
final Color focusColor; final Color? focusColor;
/// The color for the button's [Material] when a pointer is hovering over it. /// The color for the button's [Material] when a pointer is hovering over it.
final Color hoverColor; final Color? hoverColor;
/// The highlight color for the button's [InkWell]. /// The highlight color for the button's [InkWell].
final Color highlightColor; final Color? highlightColor;
/// The splash color for the button's [InkWell]. /// The splash color for the button's [InkWell].
final Color splashColor; final Color? splashColor;
/// The elevation for the button's [Material] when the button /// The elevation for the button's [Material] when the button
/// is [enabled] but not pressed. /// is [enabled] but not pressed.
...@@ -275,7 +273,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -275,7 +273,7 @@ class RawMaterialButton extends StatefulWidget {
final Duration animationDuration; final Duration animationDuration;
/// Typically the button's label. /// Typically the button's label.
final Widget child; final Widget? child;
/// Whether the button is enabled or disabled. /// Whether the button is enabled or disabled.
/// ///
...@@ -293,7 +291,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -293,7 +291,7 @@ class RawMaterialButton extends StatefulWidget {
final MaterialTapTargetSize materialTapTargetSize; final MaterialTapTargetSize materialTapTargetSize;
/// {@macro flutter.widgets.Focus.focusNode} /// {@macro flutter.widgets.Focus.focusNode}
final FocusNode focusNode; final FocusNode? focusNode;
/// {@macro flutter.widgets.Focus.autofocus} /// {@macro flutter.widgets.Focus.autofocus}
final bool autofocus; final bool autofocus;
...@@ -334,7 +332,7 @@ class _RawMaterialButtonState extends State<RawMaterialButton> { ...@@ -334,7 +332,7 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
setState(() { setState(() {
_updateState(MaterialState.pressed, value); _updateState(MaterialState.pressed, value);
if (widget.onHighlightChanged != null) { if (widget.onHighlightChanged != null) {
widget.onHighlightChanged(value); widget.onHighlightChanged!(value);
} }
}); });
} }
...@@ -395,11 +393,11 @@ class _RawMaterialButtonState extends State<RawMaterialButton> { ...@@ -395,11 +393,11 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Color effectiveTextColor = MaterialStateProperty.resolveAs<Color>(widget.textStyle?.color, _states); final Color? effectiveTextColor = MaterialStateProperty.resolveAs<Color>(widget.textStyle?.color, _states);
final ShapeBorder effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder>(widget.shape, _states); final ShapeBorder? effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder>(widget.shape, _states);
final Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment; final Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment;
final BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints); final BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints);
final MouseCursor effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>( final MouseCursor? effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>(
widget.mouseCursor ?? MaterialStateMouseCursor.clickable, widget.mouseCursor ?? MaterialStateMouseCursor.clickable,
_states, _states,
); );
...@@ -487,9 +485,9 @@ class _RawMaterialButtonState extends State<RawMaterialButton> { ...@@ -487,9 +485,9 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
/// "tap target", but not its material or its ink splashes. /// "tap target", but not its material or its ink splashes.
class _InputPadding extends SingleChildRenderObjectWidget { class _InputPadding extends SingleChildRenderObjectWidget {
const _InputPadding({ const _InputPadding({
Key key, Key? key,
Widget child, Widget? child,
this.minSize, required this.minSize,
}) : super(key: key, child: child); }) : super(key: key, child: child);
final Size minSize; final Size minSize;
...@@ -506,7 +504,7 @@ class _InputPadding extends SingleChildRenderObjectWidget { ...@@ -506,7 +504,7 @@ class _InputPadding extends SingleChildRenderObjectWidget {
} }
class _RenderInputPadding extends RenderShiftedBox { class _RenderInputPadding extends RenderShiftedBox {
_RenderInputPadding(this._minSize, [RenderBox child]) : super(child); _RenderInputPadding(this._minSize, [RenderBox? child]) : super(child);
Size get minSize => _minSize; Size get minSize => _minSize;
Size _minSize; Size _minSize;
...@@ -520,58 +518,57 @@ class _RenderInputPadding extends RenderShiftedBox { ...@@ -520,58 +518,57 @@ class _RenderInputPadding extends RenderShiftedBox {
@override @override
double computeMinIntrinsicWidth(double height) { double computeMinIntrinsicWidth(double height) {
if (child != null) if (child != null)
return math.max(child.getMinIntrinsicWidth(height), minSize.width); return math.max(child!.getMinIntrinsicWidth(height), minSize.width);
return 0.0; return 0.0;
} }
@override @override
double computeMinIntrinsicHeight(double width) { double computeMinIntrinsicHeight(double width) {
if (child != null) if (child != null)
return math.max(child.getMinIntrinsicHeight(width), minSize.height); return math.max(child!.getMinIntrinsicHeight(width), minSize.height);
return 0.0; return 0.0;
} }
@override @override
double computeMaxIntrinsicWidth(double height) { double computeMaxIntrinsicWidth(double height) {
if (child != null) if (child != null)
return math.max(child.getMaxIntrinsicWidth(height), minSize.width); return math.max(child!.getMaxIntrinsicWidth(height), minSize.width);
return 0.0; return 0.0;
} }
@override @override
double computeMaxIntrinsicHeight(double width) { double computeMaxIntrinsicHeight(double width) {
if (child != null) if (child != null)
return math.max(child.getMaxIntrinsicHeight(width), minSize.height); return math.max(child!.getMaxIntrinsicHeight(width), minSize.height);
return 0.0; return 0.0;
} }
@override @override
void performLayout() { void performLayout() {
final BoxConstraints constraints = this.constraints;
if (child != null) { if (child != null) {
child.layout(constraints, parentUsesSize: true); child!.layout(constraints, parentUsesSize: true);
final double height = math.max(child.size.width, minSize.width); final double height = math.max(child!.size.width, minSize.width);
final double width = math.max(child.size.height, minSize.height); final double width = math.max(child!.size.height, minSize.height);
size = constraints.constrain(Size(height, width)); size = constraints.constrain(Size(height, width));
final BoxParentData childParentData = child.parentData as BoxParentData; final BoxParentData childParentData = child!.parentData as BoxParentData;
childParentData.offset = Alignment.center.alongOffset(size - child.size as Offset); childParentData.offset = Alignment.center.alongOffset(size - child!.size as Offset);
} else { } else {
size = Size.zero; size = Size.zero;
} }
} }
@override @override
bool hitTest(BoxHitTestResult result, { Offset position }) { bool hitTest(BoxHitTestResult result, { required Offset position }) {
if (super.hitTest(result, position: position)) { if (super.hitTest(result, position: position)) {
return true; return true;
} }
final Offset center = child.size.center(Offset.zero); final Offset center = child!.size.center(Offset.zero);
return result.addWithRawTransform( return result.addWithRawTransform(
transform: MatrixUtils.forceToPoint(center), transform: MatrixUtils.forceToPoint(center),
position: center, position: center,
hitTest: (BoxHitTestResult result, Offset position) { hitTest: (BoxHitTestResult result, Offset? position) {
assert(position == center); assert(position == center);
return child.hitTest(result, position: center); return child!.hitTest(result, position: center);
}, },
); );
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -56,7 +54,7 @@ class ButtonBar extends StatelessWidget { ...@@ -56,7 +54,7 @@ class ButtonBar extends StatelessWidget {
/// Both [buttonMinWidth] and [buttonHeight] must be non-negative if they /// Both [buttonMinWidth] and [buttonHeight] must be non-negative if they
/// are not null. /// are not null.
const ButtonBar({ const ButtonBar({
Key key, Key? key,
this.alignment, this.alignment,
this.mainAxisSize, this.mainAxisSize,
this.buttonTextTheme, this.buttonTextTheme,
...@@ -77,13 +75,13 @@ class ButtonBar extends StatelessWidget { ...@@ -77,13 +75,13 @@ class ButtonBar extends StatelessWidget {
/// ///
/// If null then it will use [ButtonBarThemeData.alignment]. If that is null, /// If null then it will use [ButtonBarThemeData.alignment]. If that is null,
/// it will default to [MainAxisAlignment.end]. /// it will default to [MainAxisAlignment.end].
final MainAxisAlignment alignment; final MainAxisAlignment? alignment;
/// How much horizontal space is available. See [Row.mainAxisSize]. /// How much horizontal space is available. See [Row.mainAxisSize].
/// ///
/// If null then it will use the surrounding [ButtonBarThemeData.mainAxisSize]. /// If null then it will use the surrounding [ButtonBarThemeData.mainAxisSize].
/// If that is null, it will default to [MainAxisSize.max]. /// If that is null, it will default to [MainAxisSize.max].
final MainAxisSize mainAxisSize; final MainAxisSize? mainAxisSize;
/// Overrides the surrounding [ButtonBarThemeData.buttonTextTheme] to define a /// Overrides the surrounding [ButtonBarThemeData.buttonTextTheme] to define a
/// button's base colors, size, internal padding and shape. /// button's base colors, size, internal padding and shape.
...@@ -91,21 +89,21 @@ class ButtonBar extends StatelessWidget { ...@@ -91,21 +89,21 @@ class ButtonBar extends StatelessWidget {
/// If null then it will use the surrounding /// If null then it will use the surrounding
/// [ButtonBarThemeData.buttonTextTheme]. If that is null, it will default to /// [ButtonBarThemeData.buttonTextTheme]. If that is null, it will default to
/// [ButtonTextTheme.primary]. /// [ButtonTextTheme.primary].
final ButtonTextTheme buttonTextTheme; final ButtonTextTheme? buttonTextTheme;
/// Overrides the surrounding [ButtonThemeData.minWidth] to define a button's /// Overrides the surrounding [ButtonThemeData.minWidth] to define a button's
/// minimum width. /// minimum width.
/// ///
/// If null then it will use the surrounding [ButtonBarThemeData.buttonMinWidth]. /// If null then it will use the surrounding [ButtonBarThemeData.buttonMinWidth].
/// If that is null, it will default to 64.0 logical pixels. /// If that is null, it will default to 64.0 logical pixels.
final double buttonMinWidth; final double? buttonMinWidth;
/// Overrides the surrounding [ButtonThemeData.height] to define a button's /// Overrides the surrounding [ButtonThemeData.height] to define a button's
/// minimum height. /// minimum height.
/// ///
/// If null then it will use the surrounding [ButtonBarThemeData.buttonHeight]. /// If null then it will use the surrounding [ButtonBarThemeData.buttonHeight].
/// If that is null, it will default to 36.0 logical pixels. /// If that is null, it will default to 36.0 logical pixels.
final double buttonHeight; final double? buttonHeight;
/// Overrides the surrounding [ButtonThemeData.padding] to define the padding /// Overrides the surrounding [ButtonThemeData.padding] to define the padding
/// for a button's child (typically the button's label). /// for a button's child (typically the button's label).
...@@ -113,14 +111,14 @@ class ButtonBar extends StatelessWidget { ...@@ -113,14 +111,14 @@ class ButtonBar extends StatelessWidget {
/// If null then it will use the surrounding [ButtonBarThemeData.buttonPadding]. /// If null then it will use the surrounding [ButtonBarThemeData.buttonPadding].
/// If that is null, it will default to 8.0 logical pixels on the left /// If that is null, it will default to 8.0 logical pixels on the left
/// and right. /// and right.
final EdgeInsetsGeometry buttonPadding; final EdgeInsetsGeometry? buttonPadding;
/// Overrides the surrounding [ButtonThemeData.alignedDropdown] to define whether /// Overrides the surrounding [ButtonThemeData.alignedDropdown] to define whether
/// a [DropdownButton] menu's width will match the button's width. /// a [DropdownButton] menu's width will match the button's width.
/// ///
/// If null then it will use the surrounding [ButtonBarThemeData.buttonAlignedDropdown]. /// If null then it will use the surrounding [ButtonBarThemeData.buttonAlignedDropdown].
/// If that is null, it will default to false. /// If that is null, it will default to false.
final bool buttonAlignedDropdown; final bool? buttonAlignedDropdown;
/// Defines whether a [ButtonBar] should size itself with a minimum size /// Defines whether a [ButtonBar] should size itself with a minimum size
/// constraint or with padding. /// constraint or with padding.
...@@ -129,7 +127,7 @@ class ButtonBar extends StatelessWidget { ...@@ -129,7 +127,7 @@ class ButtonBar extends StatelessWidget {
/// ///
/// If null then it will use the surrounding [ButtonBarThemeData.layoutBehavior]. /// If null then it will use the surrounding [ButtonBarThemeData.layoutBehavior].
/// If that is null, it will default [ButtonBarLayoutBehavior.padded]. /// If that is null, it will default [ButtonBarLayoutBehavior.padded].
final ButtonBarLayoutBehavior layoutBehavior; final ButtonBarLayoutBehavior? layoutBehavior;
/// Defines the vertical direction of a [ButtonBar]'s children if it /// Defines the vertical direction of a [ButtonBar]'s children if it
/// overflows. /// overflows.
...@@ -145,7 +143,7 @@ class ButtonBar extends StatelessWidget { ...@@ -145,7 +143,7 @@ class ButtonBar extends StatelessWidget {
/// If null then it will use the surrounding /// If null then it will use the surrounding
/// [ButtonBarThemeData.overflowDirection]. If that is null, it will /// [ButtonBarThemeData.overflowDirection]. If that is null, it will
/// default to [VerticalDirection.down]. /// default to [VerticalDirection.down].
final VerticalDirection overflowDirection; final VerticalDirection? overflowDirection;
/// The spacing between buttons when the button bar overflows. /// The spacing between buttons when the button bar overflows.
/// ///
...@@ -161,7 +159,7 @@ class ButtonBar extends StatelessWidget { ...@@ -161,7 +159,7 @@ class ButtonBar extends StatelessWidget {
/// ///
/// If null then no spacing will be added in between buttons in /// If null then no spacing will be added in between buttons in
/// an overflow state. /// an overflow state.
final double overflowButtonSpacing; final double? overflowButtonSpacing;
/// The buttons to arrange horizontally. /// The buttons to arrange horizontally.
/// ///
...@@ -216,8 +214,6 @@ class ButtonBar extends StatelessWidget { ...@@ -216,8 +214,6 @@ class ButtonBar extends StatelessWidget {
child: child, child: child,
); );
} }
assert(false);
return null;
} }
} }
...@@ -239,14 +235,14 @@ class _ButtonBarRow extends Flex { ...@@ -239,14 +235,14 @@ class _ButtonBarRow extends Flex {
/// Creates a button bar that attempts to display in a row, but displays in /// Creates a button bar that attempts to display in a row, but displays in
/// a column if there is insufficient horizontal space. /// a column if there is insufficient horizontal space.
_ButtonBarRow({ _ButtonBarRow({
List<Widget> children, required List<Widget> children,
Axis direction = Axis.horizontal, Axis direction = Axis.horizontal,
MainAxisSize mainAxisSize = MainAxisSize.max, MainAxisSize mainAxisSize = MainAxisSize.max,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
TextDirection textDirection, TextDirection? textDirection,
VerticalDirection overflowDirection = VerticalDirection.down, VerticalDirection overflowDirection = VerticalDirection.down,
TextBaseline textBaseline, TextBaseline? textBaseline,
this.overflowButtonSpacing, this.overflowButtonSpacing,
}) : super( }) : super(
children: children, children: children,
...@@ -259,7 +255,7 @@ class _ButtonBarRow extends Flex { ...@@ -259,7 +255,7 @@ class _ButtonBarRow extends Flex {
textBaseline: textBaseline, textBaseline: textBaseline,
); );
final double overflowButtonSpacing; final double? overflowButtonSpacing;
@override @override
_RenderButtonBarRow createRenderObject(BuildContext context) { _RenderButtonBarRow createRenderObject(BuildContext context) {
...@@ -268,7 +264,7 @@ class _ButtonBarRow extends Flex { ...@@ -268,7 +264,7 @@ class _ButtonBarRow extends Flex {
mainAxisAlignment: mainAxisAlignment, mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize, mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment, crossAxisAlignment: crossAxisAlignment,
textDirection: getEffectiveTextDirection(context), textDirection: getEffectiveTextDirection(context)!,
verticalDirection: verticalDirection, verticalDirection: verticalDirection,
textBaseline: textBaseline, textBaseline: textBaseline,
overflowButtonSpacing: overflowButtonSpacing, overflowButtonSpacing: overflowButtonSpacing,
...@@ -307,14 +303,14 @@ class _RenderButtonBarRow extends RenderFlex { ...@@ -307,14 +303,14 @@ class _RenderButtonBarRow extends RenderFlex {
/// Creates a button bar that attempts to display in a row, but displays in /// Creates a button bar that attempts to display in a row, but displays in
/// a column if there is insufficient horizontal space. /// a column if there is insufficient horizontal space.
_RenderButtonBarRow({ _RenderButtonBarRow({
List<RenderBox> children, List<RenderBox>? children,
Axis direction = Axis.horizontal, Axis direction = Axis.horizontal,
MainAxisSize mainAxisSize = MainAxisSize.max, MainAxisSize mainAxisSize = MainAxisSize.max,
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.start,
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
@required TextDirection textDirection, required TextDirection textDirection,
VerticalDirection verticalDirection = VerticalDirection.down, VerticalDirection verticalDirection = VerticalDirection.down,
TextBaseline textBaseline, TextBaseline? textBaseline,
this.overflowButtonSpacing, this.overflowButtonSpacing,
}) : assert(textDirection != null), }) : assert(textDirection != null),
assert(overflowButtonSpacing == null || overflowButtonSpacing >= 0), assert(overflowButtonSpacing == null || overflowButtonSpacing >= 0),
...@@ -330,13 +326,13 @@ class _RenderButtonBarRow extends RenderFlex { ...@@ -330,13 +326,13 @@ class _RenderButtonBarRow extends RenderFlex {
); );
bool _hasCheckedLayoutWidth = false; bool _hasCheckedLayoutWidth = false;
double overflowButtonSpacing; double? overflowButtonSpacing;
@override @override
BoxConstraints get constraints { BoxConstraints get constraints {
if (_hasCheckedLayoutWidth) if (_hasCheckedLayoutWidth)
return super.constraints; return super.constraints;
return super.constraints?.copyWith(maxWidth: double.infinity); return super.constraints.copyWith(maxWidth: double.infinity);
} }
@override @override
...@@ -359,7 +355,7 @@ class _RenderButtonBarRow extends RenderFlex { ...@@ -359,7 +355,7 @@ class _RenderButtonBarRow extends RenderFlex {
super.performLayout(); super.performLayout();
} else { } else {
final BoxConstraints childConstraints = constraints.copyWith(minWidth: 0.0); final BoxConstraints childConstraints = constraints.copyWith(minWidth: 0.0);
RenderBox child; RenderBox? child;
double currentHeight = 0.0; double currentHeight = 0.0;
switch (verticalDirection) { switch (verticalDirection) {
case VerticalDirection.down: case VerticalDirection.down:
...@@ -381,7 +377,7 @@ class _RenderButtonBarRow extends RenderFlex { ...@@ -381,7 +377,7 @@ class _RenderButtonBarRow extends RenderFlex {
// alignment for a row. For [MainAxisAlignment.spaceAround], // alignment for a row. For [MainAxisAlignment.spaceAround],
// [MainAxisAlignment.spaceBetween] and [MainAxisAlignment.spaceEvenly] // [MainAxisAlignment.spaceBetween] and [MainAxisAlignment.spaceEvenly]
// cases, use [MainAxisAlignment.start]. // cases, use [MainAxisAlignment.start].
switch (textDirection) { switch (textDirection!) {
case TextDirection.ltr: case TextDirection.ltr:
switch (mainAxisAlignment) { switch (mainAxisAlignment) {
case MainAxisAlignment.center: case MainAxisAlignment.center:
...@@ -422,7 +418,7 @@ class _RenderButtonBarRow extends RenderFlex { ...@@ -422,7 +418,7 @@ class _RenderButtonBarRow extends RenderFlex {
} }
if (overflowButtonSpacing != null && child != null) if (overflowButtonSpacing != null && child != null)
currentHeight += overflowButtonSpacing; currentHeight += overflowButtonSpacing!;
} }
size = constraints.constrain(Size(constraints.maxWidth, currentHeight)); size = constraints.constrain(Size(constraints.maxWidth, currentHeight));
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -46,10 +44,10 @@ class ButtonBarThemeData with Diagnosticable { ...@@ -46,10 +44,10 @@ class ButtonBarThemeData with Diagnosticable {
assert(buttonHeight == null || buttonHeight >= 0.0); assert(buttonHeight == null || buttonHeight >= 0.0);
/// How the children should be placed along the horizontal axis. /// How the children should be placed along the horizontal axis.
final MainAxisAlignment alignment; final MainAxisAlignment? alignment;
/// How much horizontal space is available. See [Row.mainAxisSize]. /// How much horizontal space is available. See [Row.mainAxisSize].
final MainAxisSize mainAxisSize; final MainAxisSize? mainAxisSize;
/// Defines a [ButtonBar] button's base colors, and the defaults for /// Defines a [ButtonBar] button's base colors, and the defaults for
/// the button's minimum size, internal padding, and shape. /// the button's minimum size, internal padding, and shape.
...@@ -59,7 +57,7 @@ class ButtonBarThemeData with Diagnosticable { ...@@ -59,7 +57,7 @@ class ButtonBarThemeData with Diagnosticable {
/// ///
/// Despite the name, this property is not a [TextTheme], its value is not a /// Despite the name, this property is not a [TextTheme], its value is not a
/// collection of [TextStyle]s. /// collection of [TextStyle]s.
final ButtonTextTheme buttonTextTheme; final ButtonTextTheme? buttonTextTheme;
/// The minimum width for [ButtonBar] buttons. /// The minimum width for [ButtonBar] buttons.
/// ///
...@@ -68,19 +66,19 @@ class ButtonBarThemeData with Diagnosticable { ...@@ -68,19 +66,19 @@ class ButtonBarThemeData with Diagnosticable {
/// ///
/// The actual horizontal space allocated for a button's child is /// The actual horizontal space allocated for a button's child is
/// at least this value less the theme's horizontal [ButtonThemeData.padding]. /// at least this value less the theme's horizontal [ButtonThemeData.padding].
final double buttonMinWidth; final double? buttonMinWidth;
/// The minimum height for [ButtonBar] buttons. /// The minimum height for [ButtonBar] buttons.
/// ///
/// This will override the surrounding [ButtonThemeData.height] setting /// This will override the surrounding [ButtonThemeData.height] setting
/// for buttons contained in the [ButtonBar]. /// for buttons contained in the [ButtonBar].
final double buttonHeight; final double? buttonHeight;
/// Padding for a [ButtonBar] button's child (typically the button's label). /// Padding for a [ButtonBar] button's child (typically the button's label).
/// ///
/// This will override the surrounding [ButtonThemeData.padding] setting /// This will override the surrounding [ButtonThemeData.padding] setting
/// for buttons contained in the [ButtonBar]. /// for buttons contained in the [ButtonBar].
final EdgeInsetsGeometry buttonPadding; final EdgeInsetsGeometry? buttonPadding;
/// If true, then a [DropdownButton] menu's width will match the [ButtonBar] /// If true, then a [DropdownButton] menu's width will match the [ButtonBar]
/// button's width. /// button's width.
...@@ -95,11 +93,11 @@ class ButtonBarThemeData with Diagnosticable { ...@@ -95,11 +93,11 @@ class ButtonBarThemeData with Diagnosticable {
/// ///
/// This property only affects [DropdownButton] contained in a [ButtonBar] /// This property only affects [DropdownButton] contained in a [ButtonBar]
/// and its menu. /// and its menu.
final bool buttonAlignedDropdown; final bool? buttonAlignedDropdown;
/// Defines whether a [ButtonBar] should size itself with a minimum size /// Defines whether a [ButtonBar] should size itself with a minimum size
/// constraint or with padding. /// constraint or with padding.
final ButtonBarLayoutBehavior layoutBehavior; final ButtonBarLayoutBehavior? layoutBehavior;
/// Defines the vertical direction of a [ButtonBar]'s children if it /// Defines the vertical direction of a [ButtonBar]'s children if it
/// overflows. /// overflows.
...@@ -111,20 +109,20 @@ class ButtonBarThemeData with Diagnosticable { ...@@ -111,20 +109,20 @@ class ButtonBarThemeData with Diagnosticable {
/// the first action will be at the bottom of the column if this /// the first action will be at the bottom of the column if this
/// property is set to [VerticalDirection.up], since it "starts" at the /// property is set to [VerticalDirection.up], since it "starts" at the
/// bottom and "ends" at the top. /// bottom and "ends" at the top.
final VerticalDirection overflowDirection; final VerticalDirection? overflowDirection;
/// Creates a copy of this object but with the given fields replaced with the /// Creates a copy of this object but with the given fields replaced with the
/// new values. /// new values.
ButtonBarThemeData copyWith({ ButtonBarThemeData copyWith({
MainAxisAlignment alignment, MainAxisAlignment? alignment,
MainAxisSize mainAxisSize, MainAxisSize? mainAxisSize,
ButtonTextTheme buttonTextTheme, ButtonTextTheme? buttonTextTheme,
double buttonMinWidth, double? buttonMinWidth,
double buttonHeight, double? buttonHeight,
EdgeInsetsGeometry buttonPadding, EdgeInsetsGeometry? buttonPadding,
bool buttonAlignedDropdown, bool? buttonAlignedDropdown,
ButtonBarLayoutBehavior layoutBehavior, ButtonBarLayoutBehavior? layoutBehavior,
VerticalDirection overflowDirection, VerticalDirection? overflowDirection,
}) { }) {
return ButtonBarThemeData( return ButtonBarThemeData(
alignment: alignment ?? this.alignment, alignment: alignment ?? this.alignment,
...@@ -144,20 +142,20 @@ class ButtonBarThemeData with Diagnosticable { ...@@ -144,20 +142,20 @@ class ButtonBarThemeData with Diagnosticable {
/// If both arguments are null, then null is returned. /// If both arguments are null, then null is returned.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static ButtonBarThemeData lerp(ButtonBarThemeData a, ButtonBarThemeData b, double t) { static ButtonBarThemeData? lerp(ButtonBarThemeData? a, ButtonBarThemeData? b, double t) {
assert(t != null); assert(t != null);
if (a == null && b == null) if (a == null && b == null)
return null; return null;
return ButtonBarThemeData( return ButtonBarThemeData(
alignment: t < 0.5 ? a.alignment : b.alignment, alignment: t < 0.5 ? a?.alignment : b?.alignment,
mainAxisSize: t < 0.5 ? a.mainAxisSize : b.mainAxisSize, mainAxisSize: t < 0.5 ? a?.mainAxisSize : b?.mainAxisSize,
buttonTextTheme: t < 0.5 ? a.buttonTextTheme : b.buttonTextTheme, buttonTextTheme: t < 0.5 ? a?.buttonTextTheme : b?.buttonTextTheme,
buttonMinWidth: lerpDouble(a?.buttonMinWidth, b?.buttonMinWidth, t), buttonMinWidth: lerpDouble(a?.buttonMinWidth, b?.buttonMinWidth, t),
buttonHeight: lerpDouble(a?.buttonHeight, b?.buttonHeight, t), buttonHeight: lerpDouble(a?.buttonHeight, b?.buttonHeight, t),
buttonPadding: EdgeInsetsGeometry.lerp(a?.buttonPadding, b?.buttonPadding, t), buttonPadding: EdgeInsetsGeometry.lerp(a?.buttonPadding, b?.buttonPadding, t),
buttonAlignedDropdown: t < 0.5 ? a.buttonAlignedDropdown : b.buttonAlignedDropdown, buttonAlignedDropdown: t < 0.5 ? a?.buttonAlignedDropdown : b?.buttonAlignedDropdown,
layoutBehavior: t < 0.5 ? a.layoutBehavior : b.layoutBehavior, layoutBehavior: t < 0.5 ? a?.layoutBehavior : b?.layoutBehavior,
overflowDirection: t < 0.5 ? a.overflowDirection : b.overflowDirection, overflowDirection: t < 0.5 ? a?.overflowDirection : b?.overflowDirection,
); );
} }
...@@ -235,9 +233,9 @@ class ButtonBarTheme extends InheritedWidget { ...@@ -235,9 +233,9 @@ class ButtonBarTheme extends InheritedWidget {
/// ///
/// The [data] must not be null. /// The [data] must not be null.
const ButtonBarTheme({ const ButtonBarTheme({
Key key, Key? key,
@required this.data, required this.data,
Widget child, required Widget child,
}) : assert(data != null), super(key: key, child: child); }) : assert(data != null), super(key: key, child: child);
/// The properties used for all descendant [ButtonBar] widgets. /// The properties used for all descendant [ButtonBar] widgets.
...@@ -253,8 +251,8 @@ class ButtonBarTheme extends InheritedWidget { ...@@ -253,8 +251,8 @@ class ButtonBarTheme extends InheritedWidget {
/// ButtonBarThemeData theme = ButtonBarTheme.of(context); /// ButtonBarThemeData theme = ButtonBarTheme.of(context);
/// ``` /// ```
static ButtonBarThemeData of(BuildContext context) { static ButtonBarThemeData of(BuildContext context) {
final ButtonBarTheme buttonBarTheme = context.dependOnInheritedWidgetOfExactType<ButtonBarTheme>(); final ButtonBarTheme? buttonBarTheme = context.dependOnInheritedWidgetOfExactType<ButtonBarTheme>();
return buttonBarTheme?.data ?? Theme.of(context).buttonBarTheme; return buttonBarTheme?.data ?? Theme.of(context)!.buttonBarTheme;
} }
@override @override
......
...@@ -30,7 +30,7 @@ void main() { ...@@ -30,7 +30,7 @@ void main() {
expect(themeData.showUnselectedLabels, null); expect(themeData.showUnselectedLabels, null);
expect(themeData.type, null); expect(themeData.type, null);
const BottomNavigationBarTheme theme = BottomNavigationBarTheme(data: BottomNavigationBarThemeData()); const BottomNavigationBarTheme theme = BottomNavigationBarTheme(data: BottomNavigationBarThemeData(), child: SizedBox());
expect(theme.data.backgroundColor, null); expect(theme.data.backgroundColor, null);
expect(theme.data.elevation, null); expect(theme.data.elevation, null);
expect(theme.data.selectedIconTheme, null); expect(theme.data.selectedIconTheme, null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment