Unverified Commit e605b7c2 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

migrate some material files to nullsafty (#66858)

* migrate some material files to nullsafty

* address review comments
parent 0e9c6a3d
...@@ -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,44 +44,44 @@ class CardTheme with Diagnosticable { ...@@ -46,44 +44,44 @@ class CardTheme with Diagnosticable {
/// Default value for [Card.clipBehavior]. /// Default value for [Card.clipBehavior].
/// ///
/// If null, [Card] uses [Clip.none]. /// If null, [Card] uses [Clip.none].
final Clip clipBehavior; final Clip? clipBehavior;
/// Default value for [Card.color]. /// Default value for [Card.color].
/// ///
/// If null, [Card] uses [ThemeData.cardColor]. /// If null, [Card] uses [ThemeData.cardColor].
final Color color; final Color? color;
/// Default value for [Card.shadowColor]. /// Default value for [Card.shadowColor].
/// ///
/// If null, [Card] defaults to fully opaque black. /// If null, [Card] defaults to fully opaque black.
final Color shadowColor; final Color? shadowColor;
/// Default value for [Card.elevation]. /// Default value for [Card.elevation].
/// ///
/// If null, [Card] uses a default of 1.0. /// If null, [Card] uses a default of 1.0.
final double elevation; final double? elevation;
/// Default value for [Card.margin]. /// Default value for [Card.margin].
/// ///
/// If null, [Card] uses a default margin of 4.0 logical pixels on all sides: /// If null, [Card] uses a default margin of 4.0 logical pixels on all sides:
/// `EdgeInsets.all(4.0)`. /// `EdgeInsets.all(4.0)`.
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
/// Default value for [Card.shape]. /// Default value for [Card.shape].
/// ///
/// If null, [Card] then uses a [RoundedRectangleBorder] with a circular /// If null, [Card] then uses a [RoundedRectangleBorder] with a circular
/// corner radius of 4.0. /// corner radius of 4.0.
final ShapeBorder shape; final ShapeBorder? shape;
/// 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.
CardTheme copyWith({ CardTheme copyWith({
Clip clipBehavior, Clip? clipBehavior,
Color color, Color? color,
Color shadowColor, Color? shadowColor,
double elevation, double? elevation,
EdgeInsetsGeometry margin, EdgeInsetsGeometry? margin,
ShapeBorder shape, ShapeBorder? shape,
}) { }) {
return CardTheme( return CardTheme(
clipBehavior: clipBehavior ?? this.clipBehavior, clipBehavior: clipBehavior ?? this.clipBehavior,
...@@ -97,7 +95,7 @@ class CardTheme with Diagnosticable { ...@@ -97,7 +95,7 @@ class CardTheme with Diagnosticable {
/// The [ThemeData.cardTheme] property of the ambient [Theme]. /// The [ThemeData.cardTheme] property of the ambient [Theme].
static CardTheme of(BuildContext context) { static CardTheme of(BuildContext context) {
return Theme.of(context).cardTheme; return Theme.of(context)!.cardTheme;
} }
/// Linearly interpolate between two Card themes. /// Linearly interpolate between two Card themes.
...@@ -105,7 +103,7 @@ class CardTheme with Diagnosticable { ...@@ -105,7 +103,7 @@ class CardTheme 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 CardTheme lerp(CardTheme a, CardTheme b, double t) { static CardTheme lerp(CardTheme? a, CardTheme? b, double t) {
assert(t != null); assert(t != null);
return CardTheme( return CardTheme(
clipBehavior: t < 0.5 ? a?.clipBehavior : b?.clipBehavior, clipBehavior: t < 0.5 ? a?.clipBehavior : b?.clipBehavior,
......
...@@ -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';
......
...@@ -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/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -45,7 +43,7 @@ class ElevationOverlay { ...@@ -45,7 +43,7 @@ class ElevationOverlay {
/// * <https://material.io/design/color/dark-theme.html>, which specifies how /// * <https://material.io/design/color/dark-theme.html>, which specifies how
/// the overlay should be applied. /// the overlay should be applied.
static Color applyOverlay(BuildContext context, Color color, double elevation) { static Color applyOverlay(BuildContext context, Color color, double elevation) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
if (elevation > 0.0 && if (elevation > 0.0 &&
theme.applyElevationOverlayColor && theme.applyElevationOverlayColor &&
theme.brightness == Brightness.dark && theme.brightness == Brightness.dark &&
...@@ -63,7 +61,7 @@ class ElevationOverlay { ...@@ -63,7 +61,7 @@ class ElevationOverlay {
/// * https://material.io/design/color/dark-theme.html#properties which /// * https://material.io/design/color/dark-theme.html#properties which
/// specifies the exact overlay values for a given elevation. /// specifies the exact overlay values for a given elevation.
static Color overlayColor(BuildContext context, double elevation) { static Color overlayColor(BuildContext context, double elevation) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
// Compute the opacity for the given elevation // Compute the opacity for the given elevation
// This formula matches the values in the spec: // This formula matches the values in the spec:
// https://material.io/design/color/dark-theme.html#properties // https://material.io/design/color/dark-theme.html#properties
......
...@@ -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/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/semantics.dart'; import 'package:flutter/semantics.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
...@@ -94,7 +92,7 @@ class Feedback { ...@@ -94,7 +92,7 @@ class Feedback {
/// * [wrapForTap] to trigger platform-specific feedback before executing a /// * [wrapForTap] to trigger platform-specific feedback before executing a
/// [GestureTapCallback]. /// [GestureTapCallback].
static Future<void> forTap(BuildContext context) async { static Future<void> forTap(BuildContext context) async {
context.findRenderObject().sendSemanticsEvent(const TapSemanticEvent()); context.findRenderObject()!.sendSemanticsEvent(const TapSemanticEvent());
switch (_platform(context)) { switch (_platform(context)) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
...@@ -104,10 +102,7 @@ class Feedback { ...@@ -104,10 +102,7 @@ class Feedback {
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows: case TargetPlatform.windows:
return Future<void>.value(); return Future<void>.value();
break;
} }
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.value();
} }
/// Wraps a [GestureTapCallback] to provide platform specific feedback for a /// Wraps a [GestureTapCallback] to provide platform specific feedback for a
...@@ -120,7 +115,7 @@ class Feedback { ...@@ -120,7 +115,7 @@ class Feedback {
/// ///
/// * [forTap] to just trigger the platform-specific feedback without wrapping /// * [forTap] to just trigger the platform-specific feedback without wrapping
/// a [GestureTapCallback]. /// a [GestureTapCallback].
static GestureTapCallback wrapForTap(GestureTapCallback callback, BuildContext context) { static GestureTapCallback? wrapForTap(GestureTapCallback? callback, BuildContext context) {
if (callback == null) if (callback == null)
return null; return null;
return () { return () {
...@@ -139,7 +134,7 @@ class Feedback { ...@@ -139,7 +134,7 @@ class Feedback {
/// * [wrapForLongPress] to trigger platform-specific feedback before /// * [wrapForLongPress] to trigger platform-specific feedback before
/// executing a [GestureLongPressCallback]. /// executing a [GestureLongPressCallback].
static Future<void> forLongPress(BuildContext context) { static Future<void> forLongPress(BuildContext context) {
context.findRenderObject().sendSemanticsEvent(const LongPressSemanticsEvent()); context.findRenderObject()!.sendSemanticsEvent(const LongPressSemanticsEvent());
switch (_platform(context)) { switch (_platform(context)) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
...@@ -149,10 +144,7 @@ class Feedback { ...@@ -149,10 +144,7 @@ class Feedback {
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows: case TargetPlatform.windows:
return Future<void>.value(); return Future<void>.value();
break;
} }
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.value();
} }
/// Wraps a [GestureLongPressCallback] to provide platform specific feedback /// Wraps a [GestureLongPressCallback] to provide platform specific feedback
...@@ -166,7 +158,7 @@ class Feedback { ...@@ -166,7 +158,7 @@ class Feedback {
/// ///
/// * [forLongPress] to just trigger the platform-specific feedback without /// * [forLongPress] to just trigger the platform-specific feedback without
/// wrapping a [GestureLongPressCallback]. /// wrapping a [GestureLongPressCallback].
static GestureLongPressCallback wrapForLongPress(GestureLongPressCallback callback, BuildContext context) { static GestureLongPressCallback? wrapForLongPress(GestureLongPressCallback? callback, BuildContext context) {
if (callback == null) if (callback == null)
return null; return null;
return () { return () {
...@@ -175,5 +167,5 @@ class Feedback { ...@@ -175,5 +167,5 @@ class Feedback {
}; };
} }
static TargetPlatform _platform(BuildContext context) => Theme.of(context).platform; static TargetPlatform _platform(BuildContext context) => Theme.of(context)!.platform;
} }
...@@ -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';
...@@ -56,7 +54,7 @@ enum MaterialType { ...@@ -56,7 +54,7 @@ enum MaterialType {
/// ///
/// * [MaterialType] /// * [MaterialType]
/// * [Material] /// * [Material]
final Map<MaterialType, BorderRadius> kMaterialEdges = <MaterialType, BorderRadius>{ final Map<MaterialType, BorderRadius?> kMaterialEdges = <MaterialType, BorderRadius?>{
MaterialType.canvas: null, MaterialType.canvas: null,
MaterialType.card: BorderRadius.circular(2.0), MaterialType.card: BorderRadius.circular(2.0),
MaterialType.circle: null, MaterialType.circle: null,
...@@ -69,7 +67,7 @@ final Map<MaterialType, BorderRadius> kMaterialEdges = <MaterialType, BorderRadi ...@@ -69,7 +67,7 @@ final Map<MaterialType, BorderRadius> kMaterialEdges = <MaterialType, BorderRadi
/// Typically obtained via [Material.of]. /// Typically obtained via [Material.of].
abstract class MaterialInkController { abstract class MaterialInkController {
/// The color of the material. /// The color of the material.
Color get color; Color? get color;
/// The ticker provider used by the controller. /// The ticker provider used by the controller.
/// ///
...@@ -177,7 +175,7 @@ class Material extends StatefulWidget { ...@@ -177,7 +175,7 @@ class Material extends StatefulWidget {
/// [MaterialType.circle]. In both cases, these restrictions are intended to /// [MaterialType.circle]. In both cases, these restrictions are intended to
/// catch likely errors. /// catch likely errors.
const Material({ const Material({
Key key, Key? key,
this.type = MaterialType.canvas, this.type = MaterialType.canvas,
this.elevation = 0.0, this.elevation = 0.0,
this.color, this.color,
...@@ -201,7 +199,7 @@ class Material extends StatefulWidget { ...@@ -201,7 +199,7 @@ class Material extends StatefulWidget {
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
/// {@macro flutter.widgets.child} /// {@macro flutter.widgets.child}
final Widget child; final Widget? child;
/// The kind of material to show (e.g., card or canvas). This /// The kind of material to show (e.g., card or canvas). This
/// affects the shape of the widget, the roundness of its corners if /// affects the shape of the widget, the roundness of its corners if
...@@ -242,7 +240,7 @@ class Material extends StatefulWidget { ...@@ -242,7 +240,7 @@ class Material extends StatefulWidget {
/// composited on top of this color to indicate the elevation. /// composited on top of this color to indicate the elevation.
/// ///
/// By default, the color is derived from the [type] of material. /// By default, the color is derived from the [type] of material.
final Color color; final Color? color;
/// The color to paint the shadow below the material. /// The color to paint the shadow below the material.
/// ///
...@@ -257,10 +255,10 @@ class Material extends StatefulWidget { ...@@ -257,10 +255,10 @@ class Material extends StatefulWidget {
/// ///
/// * [ThemeData.applyElevationOverlayColor], which turns elevation overlay /// * [ThemeData.applyElevationOverlayColor], which turns elevation overlay
/// on or off for dark themes. /// on or off for dark themes.
final Color shadowColor; final Color? shadowColor;
/// The typographical style to use for text within this material. /// The typographical style to use for text within this material.
final TextStyle textStyle; final TextStyle? textStyle;
/// Defines the material's shape as well its shadow. /// Defines the material's shape as well its shadow.
/// ///
...@@ -269,7 +267,7 @@ class Material extends StatefulWidget { ...@@ -269,7 +267,7 @@ class Material extends StatefulWidget {
/// ///
/// A shadow is only displayed if the [elevation] is greater than /// A shadow is only displayed if the [elevation] is greater than
/// zero. /// zero.
final ShapeBorder shape; final ShapeBorder? shape;
/// Whether to paint the [shape] border in front of the [child]. /// Whether to paint the [shape] border in front of the [child].
/// ///
...@@ -302,7 +300,7 @@ class Material extends StatefulWidget { ...@@ -302,7 +300,7 @@ class Material extends StatefulWidget {
/// If [shape] is non null then the border radius is ignored. /// If [shape] is non null then the border radius is ignored.
/// ///
/// Must be null if [type] is [MaterialType.circle]. /// Must be null if [type] is [MaterialType.circle].
final BorderRadiusGeometry borderRadius; final BorderRadiusGeometry? borderRadius;
/// The ink controller from the closest instance of this class that /// The ink controller from the closest instance of this class that
/// encloses the given context. /// encloses the given context.
...@@ -312,9 +310,8 @@ class Material extends StatefulWidget { ...@@ -312,9 +310,8 @@ class Material extends StatefulWidget {
/// ```dart /// ```dart
/// MaterialInkController inkController = Material.of(context); /// MaterialInkController inkController = Material.of(context);
/// ``` /// ```
static MaterialInkController of(BuildContext context) { static MaterialInkController? of(BuildContext context) {
final _RenderInkFeatures result = context.findAncestorRenderObjectOfType<_RenderInkFeatures>(); return context.findAncestorRenderObjectOfType<_RenderInkFeatures>();
return result;
} }
@override @override
...@@ -340,9 +337,9 @@ class Material extends StatefulWidget { ...@@ -340,9 +337,9 @@ class Material extends StatefulWidget {
class _MaterialState extends State<Material> with TickerProviderStateMixin { class _MaterialState extends State<Material> with TickerProviderStateMixin {
final GlobalKey _inkFeatureRenderer = GlobalKey(debugLabel: 'ink renderer'); final GlobalKey _inkFeatureRenderer = GlobalKey(debugLabel: 'ink renderer');
Color _getBackgroundColor(BuildContext context) { Color? _getBackgroundColor(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
Color color = widget.color; Color? color = widget.color;
if (color == null) { if (color == null) {
switch (widget.type) { switch (widget.type) {
case MaterialType.canvas: case MaterialType.canvas:
...@@ -360,7 +357,7 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -360,7 +357,7 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Color backgroundColor = _getBackgroundColor(context); final Color? backgroundColor = _getBackgroundColor(context);
assert( assert(
backgroundColor != null || widget.type == MaterialType.transparency, backgroundColor != null || widget.type == MaterialType.transparency,
'If Material type is not MaterialType.transparency, a color must ' 'If Material type is not MaterialType.transparency, a color must '
...@@ -368,17 +365,17 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -368,17 +365,17 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
'in the theme (ex. canvasColor != null if type is set to ' 'in the theme (ex. canvasColor != null if type is set to '
'MaterialType.canvas)' 'MaterialType.canvas)'
); );
Widget contents = widget.child; Widget? contents = widget.child;
if (contents != null) { if (contents != null) {
contents = AnimatedDefaultTextStyle( contents = AnimatedDefaultTextStyle(
style: widget.textStyle ?? Theme.of(context).textTheme.bodyText2, style: widget.textStyle ?? Theme.of(context)!.textTheme.bodyText2!,
duration: widget.animationDuration, duration: widget.animationDuration,
child: contents, child: contents,
); );
} }
contents = NotificationListener<LayoutChangedNotification>( contents = NotificationListener<LayoutChangedNotification>(
onNotification: (LayoutChangedNotification notification) { onNotification: (LayoutChangedNotification notification) {
final _RenderInkFeatures renderer = _inkFeatureRenderer.currentContext.findRenderObject() as _RenderInkFeatures; final _RenderInkFeatures renderer = _inkFeatureRenderer.currentContext!.findRenderObject()! as _RenderInkFeatures;
renderer._didChangeLayout(); renderer._didChangeLayout();
return false; return false;
}, },
...@@ -408,8 +405,8 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -408,8 +405,8 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
clipBehavior: widget.clipBehavior, clipBehavior: widget.clipBehavior,
borderRadius: BorderRadius.zero, borderRadius: BorderRadius.zero,
elevation: widget.elevation, elevation: widget.elevation,
color: ElevationOverlay.applyOverlay(context, backgroundColor, widget.elevation), color: ElevationOverlay.applyOverlay(context, backgroundColor!, widget.elevation),
shadowColor: widget.shadowColor ?? Theme.of(context).shadowColor, shadowColor: widget.shadowColor ?? Theme.of(context)!.shadowColor,
animateColor: false, animateColor: false,
child: contents, child: contents,
); );
...@@ -433,17 +430,17 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -433,17 +430,17 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
borderOnForeground: widget.borderOnForeground, borderOnForeground: widget.borderOnForeground,
clipBehavior: widget.clipBehavior, clipBehavior: widget.clipBehavior,
elevation: widget.elevation, elevation: widget.elevation,
color: backgroundColor, color: backgroundColor!,
shadowColor: widget.shadowColor ?? Theme.of(context).shadowColor, shadowColor: widget.shadowColor ?? Theme.of(context)!.shadowColor,
child: contents, child: contents,
); );
} }
static Widget _transparentInterior({ static Widget _transparentInterior({
@required BuildContext context, required BuildContext context,
@required ShapeBorder shape, required ShapeBorder shape,
@required Clip clipBehavior, required Clip clipBehavior,
@required Widget contents, required Widget contents,
}) { }) {
final _ShapeBorderPaint child = _ShapeBorderPaint( final _ShapeBorderPaint child = _ShapeBorderPaint(
child: contents, child: contents,
...@@ -471,9 +468,9 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -471,9 +468,9 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
// Material class documentation. // Material class documentation.
ShapeBorder _getShape() { ShapeBorder _getShape() {
if (widget.shape != null) if (widget.shape != null)
return widget.shape; return widget.shape!;
if (widget.borderRadius != null) if (widget.borderRadius != null)
return RoundedRectangleBorder(borderRadius: widget.borderRadius); return RoundedRectangleBorder(borderRadius: widget.borderRadius!);
switch (widget.type) { switch (widget.type) {
case MaterialType.canvas: case MaterialType.canvas:
case MaterialType.transparency: case MaterialType.transparency:
...@@ -482,21 +479,20 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -482,21 +479,20 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
case MaterialType.card: case MaterialType.card:
case MaterialType.button: case MaterialType.button:
return RoundedRectangleBorder( return RoundedRectangleBorder(
borderRadius: widget.borderRadius ?? kMaterialEdges[widget.type], borderRadius: widget.borderRadius ?? kMaterialEdges[widget.type]!,
); );
case MaterialType.circle: case MaterialType.circle:
return const CircleBorder(); return const CircleBorder();
} }
return const RoundedRectangleBorder();
} }
} }
class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController { class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController {
_RenderInkFeatures({ _RenderInkFeatures({
RenderBox child, RenderBox? child,
@required this.vsync, required this.vsync,
this.absorbHitTest, required this.absorbHitTest,
this.color, this.color,
}) : assert(vsync != null), }) : assert(vsync != null),
super(child); super(child);
...@@ -511,30 +507,30 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController ...@@ -511,30 +507,30 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
// The actual painting of this color is done by a Container in the // The actual painting of this color is done by a Container in the
// MaterialState build method. // MaterialState build method.
@override @override
Color color; Color? color;
bool absorbHitTest; bool absorbHitTest;
List<InkFeature> _inkFeatures; List<InkFeature>? _inkFeatures;
@override @override
void addInkFeature(InkFeature feature) { void addInkFeature(InkFeature feature) {
assert(!feature._debugDisposed); assert(!feature._debugDisposed);
assert(feature._controller == this); assert(feature._controller == this);
_inkFeatures ??= <InkFeature>[]; _inkFeatures ??= <InkFeature>[];
assert(!_inkFeatures.contains(feature)); assert(!_inkFeatures!.contains(feature));
_inkFeatures.add(feature); _inkFeatures!.add(feature);
markNeedsPaint(); markNeedsPaint();
} }
void _removeFeature(InkFeature feature) { void _removeFeature(InkFeature feature) {
assert(_inkFeatures != null); assert(_inkFeatures != null);
_inkFeatures.remove(feature); _inkFeatures!.remove(feature);
markNeedsPaint(); markNeedsPaint();
} }
void _didChangeLayout() { void _didChangeLayout() {
if (_inkFeatures != null && _inkFeatures.isNotEmpty) if (_inkFeatures != null && _inkFeatures!.isNotEmpty)
markNeedsPaint(); markNeedsPaint();
} }
...@@ -543,12 +539,12 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController ...@@ -543,12 +539,12 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
if (_inkFeatures != null && _inkFeatures.isNotEmpty) { if (_inkFeatures != null && _inkFeatures!.isNotEmpty) {
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
canvas.save(); canvas.save();
canvas.translate(offset.dx, offset.dy); canvas.translate(offset.dx, offset.dy);
canvas.clipRect(Offset.zero & size); canvas.clipRect(Offset.zero & size);
for (final InkFeature inkFeature in _inkFeatures) for (final InkFeature inkFeature in _inkFeatures!)
inkFeature._paint(canvas); inkFeature._paint(canvas);
canvas.restore(); canvas.restore();
} }
...@@ -558,17 +554,17 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController ...@@ -558,17 +554,17 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
class _InkFeatures extends SingleChildRenderObjectWidget { class _InkFeatures extends SingleChildRenderObjectWidget {
const _InkFeatures({ const _InkFeatures({
Key key, Key? key,
this.color, this.color,
@required this.vsync, required this.vsync,
@required this.absorbHitTest, required this.absorbHitTest,
Widget child, Widget? child,
}) : super(key: key, child: child); }) : super(key: key, child: child);
// This widget must be owned by a MaterialState, which must be provided as the vsync. // This widget must be owned by a MaterialState, which must be provided as the vsync.
// This relationship must be 1:1 and cannot change for the lifetime of the MaterialState. // This relationship must be 1:1 and cannot change for the lifetime of the MaterialState.
final Color color; final Color? color;
final TickerProvider vsync; final TickerProvider vsync;
...@@ -599,8 +595,8 @@ class _InkFeatures extends SingleChildRenderObjectWidget { ...@@ -599,8 +595,8 @@ class _InkFeatures extends SingleChildRenderObjectWidget {
abstract class InkFeature { abstract class InkFeature {
/// Initializes fields for subclasses. /// Initializes fields for subclasses.
InkFeature({ InkFeature({
@required MaterialInkController controller, required MaterialInkController controller,
@required this.referenceBox, required this.referenceBox,
this.onRemoved, this.onRemoved,
}) : assert(controller != null), }) : assert(controller != null),
assert(referenceBox != null), assert(referenceBox != null),
...@@ -617,7 +613,7 @@ abstract class InkFeature { ...@@ -617,7 +613,7 @@ abstract class InkFeature {
final RenderBox referenceBox; final RenderBox referenceBox;
/// Called when the ink feature is no longer visible on the material. /// Called when the ink feature is no longer visible on the material.
final VoidCallback onRemoved; final VoidCallback? onRemoved;
bool _debugDisposed = false; bool _debugDisposed = false;
...@@ -631,7 +627,7 @@ abstract class InkFeature { ...@@ -631,7 +627,7 @@ abstract class InkFeature {
}()); }());
_controller._removeFeature(this); _controller._removeFeature(this);
if (onRemoved != null) if (onRemoved != null)
onRemoved(); onRemoved!();
} }
void _paint(Canvas canvas) { void _paint(Canvas canvas) {
...@@ -667,16 +663,16 @@ abstract class InkFeature { ...@@ -667,16 +663,16 @@ abstract class InkFeature {
/// An interpolation between two [ShapeBorder]s. /// An interpolation between two [ShapeBorder]s.
/// ///
/// This class specializes the interpolation of [Tween] to use [ShapeBorder.lerp]. /// This class specializes the interpolation of [Tween] to use [ShapeBorder.lerp].
class ShapeBorderTween extends Tween<ShapeBorder> { class ShapeBorderTween extends Tween<ShapeBorder?> {
/// Creates a [ShapeBorder] tween. /// Creates a [ShapeBorder] tween.
/// ///
/// the [begin] and [end] properties may be null; see [ShapeBorder.lerp] for /// the [begin] and [end] properties may be null; see [ShapeBorder.lerp] for
/// the null handling semantics. /// the null handling semantics.
ShapeBorderTween({ShapeBorder begin, ShapeBorder end}) : super(begin: begin, end: end); ShapeBorderTween({ShapeBorder? begin, ShapeBorder? end}) : super(begin: begin, end: end);
/// Returns the value this tween has at the given animation clock value. /// Returns the value this tween has at the given animation clock value.
@override @override
ShapeBorder lerp(double t) { ShapeBorder? lerp(double t) {
return ShapeBorder.lerp(begin, end, t); return ShapeBorder.lerp(begin, end, t);
} }
} }
...@@ -691,16 +687,16 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget { ...@@ -691,16 +687,16 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget {
/// must not be null. The [elevation] must be specified and greater than or /// must not be null. The [elevation] must be specified and greater than or
/// equal to zero. /// equal to zero.
const _MaterialInterior({ const _MaterialInterior({
Key key, Key? key,
@required this.child, required this.child,
@required this.shape, required this.shape,
this.borderOnForeground = true, this.borderOnForeground = true,
this.clipBehavior = Clip.none, this.clipBehavior = Clip.none,
@required this.elevation, required this.elevation,
@required this.color, required this.color,
@required this.shadowColor, required this.shadowColor,
Curve curve = Curves.linear, Curve curve = Curves.linear,
@required Duration duration, required Duration duration,
}) : assert(child != null), }) : assert(child != null),
assert(shape != null), assert(shape != null),
assert(clipBehavior != null), assert(clipBehavior != null),
...@@ -757,9 +753,9 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget { ...@@ -757,9 +753,9 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget {
} }
class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior> { class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior> {
Tween<double> _elevation; Tween<double>? _elevation;
ColorTween _shadowColor; ColorTween? _shadowColor;
ShapeBorderTween _border; ShapeBorderTween? _border;
@override @override
void forEachTween(TweenVisitor<dynamic> visitor) { void forEachTween(TweenVisitor<dynamic> visitor) {
...@@ -782,8 +778,8 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior> ...@@ -782,8 +778,8 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ShapeBorder shape = _border.evaluate(animation); final ShapeBorder shape = _border!.evaluate(animation!)!;
final double elevation = _elevation.evaluate(animation); final double elevation = _elevation!.evaluate(animation!);
return PhysicalShape( return PhysicalShape(
child: _ShapeBorderPaint( child: _ShapeBorderPaint(
child: widget.child, child: widget.child,
...@@ -797,15 +793,15 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior> ...@@ -797,15 +793,15 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior>
clipBehavior: widget.clipBehavior, clipBehavior: widget.clipBehavior,
elevation: elevation, elevation: elevation,
color: ElevationOverlay.applyOverlay(context, widget.color, elevation), color: ElevationOverlay.applyOverlay(context, widget.color, elevation),
shadowColor: _shadowColor.evaluate(animation), shadowColor: _shadowColor!.evaluate(animation!)!,
); );
} }
} }
class _ShapeBorderPaint extends StatelessWidget { class _ShapeBorderPaint extends StatelessWidget {
const _ShapeBorderPaint({ const _ShapeBorderPaint({
@required this.child, required this.child,
@required this.shape, required this.shape,
this.borderOnForeground = true, this.borderOnForeground = true,
}); });
...@@ -826,7 +822,7 @@ class _ShapeBorderPaint extends StatelessWidget { ...@@ -826,7 +822,7 @@ class _ShapeBorderPaint extends StatelessWidget {
class _ShapeBorderPainter extends CustomPainter { class _ShapeBorderPainter extends CustomPainter {
_ShapeBorderPainter(this.border, this.textDirection); _ShapeBorderPainter(this.border, this.textDirection);
final ShapeBorder border; final ShapeBorder border;
final TextDirection textDirection; final TextDirection? textDirection;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
......
...@@ -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';
...@@ -135,7 +133,7 @@ abstract class MaterialLocalizations { ...@@ -135,7 +133,7 @@ abstract class MaterialLocalizations {
/// there are, e.g. 'Tab 1 of 2' in United States English. /// there are, e.g. 'Tab 1 of 2' in United States English.
/// ///
/// `tabIndex` and `tabCount` must be greater than or equal to one. /// `tabIndex` and `tabCount` must be greater than or equal to one.
String tabLabel({ int tabIndex, int tabCount }); String tabLabel({ required int tabIndex, required int tabCount });
/// Title for the [PaginatedDataTable]'s selected row count header. /// Title for the [PaginatedDataTable]'s selected row count header.
String selectedRowCountTitle(int selectedRowCount); String selectedRowCountTitle(int selectedRowCount);
...@@ -319,7 +317,7 @@ abstract class MaterialLocalizations { ...@@ -319,7 +317,7 @@ abstract class MaterialLocalizations {
/// ///
/// See also: /// See also:
/// * [formatCompactDate], which will convert a [DateTime] into a string in the compact format. /// * [formatCompactDate], which will convert a [DateTime] into a string in the compact format.
DateTime parseCompactDate(String inputString); DateTime? parseCompactDate(String? inputString);
/// List of week day names in narrow format, usually 1- or 2-letter /// List of week day names in narrow format, usually 1- or 2-letter
/// abbreviations of full names. /// abbreviations of full names.
...@@ -505,7 +503,7 @@ abstract class MaterialLocalizations { ...@@ -505,7 +503,7 @@ abstract class MaterialLocalizations {
/// ```dart /// ```dart
/// tooltip: MaterialLocalizations.of(context).backButtonTooltip, /// tooltip: MaterialLocalizations.of(context).backButtonTooltip,
/// ``` /// ```
static MaterialLocalizations of(BuildContext context) { static MaterialLocalizations? of(BuildContext context) {
return Localizations.of<MaterialLocalizations>(context, MaterialLocalizations); return Localizations.of<MaterialLocalizations>(context, MaterialLocalizations);
} }
} }
...@@ -696,24 +694,28 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { ...@@ -696,24 +694,28 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
} }
@override @override
DateTime parseCompactDate(String inputString) { DateTime? parseCompactDate(String? inputString) {
if (inputString == null) {
return null;
}
// Assumes US mm/dd/yyyy format // Assumes US mm/dd/yyyy format
final List<String> inputParts = inputString.split('/'); final List<String> inputParts = inputString.split('/');
if (inputParts.length != 3) { if (inputParts.length != 3) {
return null; return null;
} }
final int year = int.tryParse(inputParts[2], radix: 10); final int? year = int.tryParse(inputParts[2], radix: 10);
if (year == null || year < 1) { if (year == null || year < 1) {
return null; return null;
} }
final int month = int.tryParse(inputParts[0], radix: 10); final int? month = int.tryParse(inputParts[0], radix: 10);
if (month == null || month < 1 || month > 12) { if (month == null || month < 1 || month > 12) {
return null; return null;
} }
final int day = int.tryParse(inputParts[1], radix: 10); final int? day = int.tryParse(inputParts[1], radix: 10);
if (day == null || day < 1 || day > _getDaysInMonth(year, month)) { if (day == null || day < 1 || day > _getDaysInMonth(year, month)) {
return null; return null;
} }
...@@ -808,7 +810,6 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { ...@@ -808,7 +810,6 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
case DayPeriod.pm: case DayPeriod.pm:
return postMeridiemAbbreviation; return postMeridiemAbbreviation;
} }
return null;
} }
@override @override
...@@ -932,7 +933,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { ...@@ -932,7 +933,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
String get rowsPerPageTitle => 'Rows per page:'; String get rowsPerPageTitle => 'Rows per page:';
@override @override
String tabLabel({ int tabIndex, int tabCount }) { String tabLabel({ required int tabIndex, required int tabCount }) {
assert(tabIndex >= 1); assert(tabIndex >= 1);
assert(tabCount >= 1); assert(tabCount >= 1);
return 'Tab $tabIndex of $tabCount'; return 'Tab $tabIndex of $tabCount';
......
...@@ -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/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -85,22 +83,22 @@ class SnackBarAction extends StatefulWidget { ...@@ -85,22 +83,22 @@ class SnackBarAction extends StatefulWidget {
/// ///
/// The [label] and [onPressed] arguments must be non-null. /// The [label] and [onPressed] arguments must be non-null.
const SnackBarAction({ const SnackBarAction({
Key key, Key? key,
this.textColor, this.textColor,
this.disabledTextColor, this.disabledTextColor,
@required this.label, required this.label,
@required this.onPressed, required this.onPressed,
}) : assert(label != null), }) : assert(label != null),
assert(onPressed != null), assert(onPressed != null),
super(key: key); super(key: key);
/// The button label color. If not provided, defaults to /// The button label color. If not provided, defaults to
/// [SnackBarThemeData.actionTextColor]. /// [SnackBarThemeData.actionTextColor].
final Color textColor; final Color? textColor;
/// The button disabled label color. This color is shown after the /// The button disabled label color. This color is shown after the
/// [SnackBarAction] is dismissed. /// [SnackBarAction] is dismissed.
final Color disabledTextColor; final Color? disabledTextColor;
/// The button label. /// The button label.
final String label; final String label;
...@@ -125,13 +123,13 @@ class _SnackBarActionState extends State<SnackBarAction> { ...@@ -125,13 +123,13 @@ class _SnackBarActionState extends State<SnackBarAction> {
_haveTriggeredAction = true; _haveTriggeredAction = true;
}); });
widget.onPressed(); widget.onPressed();
Scaffold.of(context).hideCurrentSnackBar(reason: SnackBarClosedReason.action); Scaffold.of(context)!.hideCurrentSnackBar(reason: SnackBarClosedReason.action);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Color resolveForegroundColor(Set<MaterialState> states) { Color? resolveForegroundColor(Set<MaterialState> states) {
final SnackBarThemeData snackBarTheme = Theme.of(context).snackBarTheme; final SnackBarThemeData snackBarTheme = Theme.of(context)!.snackBarTheme;
if (states.contains(MaterialState.disabled)) if (states.contains(MaterialState.disabled))
return widget.disabledTextColor ?? snackBarTheme.disabledActionTextColor; return widget.disabledTextColor ?? snackBarTheme.disabledActionTextColor;
return widget.textColor ?? snackBarTheme.actionTextColor; return widget.textColor ?? snackBarTheme.actionTextColor;
...@@ -178,8 +176,8 @@ class SnackBar extends StatefulWidget { ...@@ -178,8 +176,8 @@ class SnackBar extends StatefulWidget {
/// The [content] argument must be non-null. The [elevation] must be null or /// The [content] argument must be non-null. The [elevation] must be null or
/// non-negative. /// non-negative.
const SnackBar({ const SnackBar({
Key key, Key? key,
@required this.content, required this.content,
this.backgroundColor, this.backgroundColor,
this.elevation, this.elevation,
this.margin, this.margin,
...@@ -218,7 +216,7 @@ class SnackBar extends StatefulWidget { ...@@ -218,7 +216,7 @@ class SnackBar extends StatefulWidget {
/// is not specified it will default to a dark variation of /// is not specified it will default to a dark variation of
/// [ColorScheme.surface] for light themes, or [ColorScheme.onSurface] for /// [ColorScheme.surface] for light themes, or [ColorScheme.onSurface] for
/// dark themes. /// dark themes.
final Color backgroundColor; final Color? backgroundColor;
/// The z-coordinate at which to place the snack bar. This controls the size /// The z-coordinate at which to place the snack bar. This controls the size
/// of the shadow below the snack bar. /// of the shadow below the snack bar.
...@@ -228,7 +226,7 @@ class SnackBar extends StatefulWidget { ...@@ -228,7 +226,7 @@ class SnackBar extends StatefulWidget {
/// If this property is null, then [SnackBarThemeData.elevation] of /// If this property is null, then [SnackBarThemeData.elevation] of
/// [ThemeData.snackBarTheme] is used, if that is also null, the default value /// [ThemeData.snackBarTheme] is used, if that is also null, the default value
/// is 6.0. /// is 6.0.
final double elevation; final double? elevation;
/// Empty space to surround the snack bar. /// Empty space to surround the snack bar.
/// ///
...@@ -237,7 +235,7 @@ class SnackBar extends StatefulWidget { ...@@ -237,7 +235,7 @@ class SnackBar extends StatefulWidget {
/// ///
/// If this property is null, then the default is /// If this property is null, then the default is
/// `EdgeInsets.fromLTRB(15.0, 5.0, 15.0, 10.0)`. /// `EdgeInsets.fromLTRB(15.0, 5.0, 15.0, 10.0)`.
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
/// The amount of padding to apply to the snack bar's content and optional /// The amount of padding to apply to the snack bar's content and optional
/// action. /// action.
...@@ -246,7 +244,7 @@ class SnackBar extends StatefulWidget { ...@@ -246,7 +244,7 @@ class SnackBar extends StatefulWidget {
/// the presence of an [action]. The start padding is 24 if [behavior] is /// the presence of an [action]. The start padding is 24 if [behavior] is
/// [SnackBarBehavior.fixed] and 16 if it is [SnackBarBehavior.floating]. If /// [SnackBarBehavior.fixed] and 16 if it is [SnackBarBehavior.floating]. If
/// there is no [action], the same padding is added to the end. /// there is no [action], the same padding is added to the end.
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
/// The width of the snack bar. /// The width of the snack bar.
/// ///
...@@ -256,7 +254,7 @@ class SnackBar extends StatefulWidget { ...@@ -256,7 +254,7 @@ class SnackBar extends StatefulWidget {
/// ///
/// If this property is null, then the snack bar will take up the full device /// If this property is null, then the snack bar will take up the full device
/// width less the margin. /// width less the margin.
final double width; final double? width;
/// The shape of the snack bar's [Material]. /// The shape of the snack bar's [Material].
/// ///
...@@ -268,7 +266,7 @@ class SnackBar extends StatefulWidget { ...@@ -268,7 +266,7 @@ class SnackBar extends StatefulWidget {
/// overriding shape is specified, so the [SnackBar] is rectangular. For /// overriding shape is specified, so the [SnackBar] is rectangular. For
/// [SnackBarBehavior.floating], it uses a [RoundedRectangleBorder] with a /// [SnackBarBehavior.floating], it uses a [RoundedRectangleBorder] with a
/// circular corner radius of 4.0. /// circular corner radius of 4.0.
final ShapeBorder shape; final ShapeBorder? shape;
/// This defines the behavior and location of the snack bar. /// This defines the behavior and location of the snack bar.
/// ///
...@@ -279,7 +277,7 @@ class SnackBar extends StatefulWidget { ...@@ -279,7 +277,7 @@ class SnackBar extends StatefulWidget {
/// If this property is null, then [SnackBarThemeData.behavior] of /// If this property is null, then [SnackBarThemeData.behavior] of
/// [ThemeData.snackBarTheme] is used. If that is null, then the default is /// [ThemeData.snackBarTheme] is used. If that is null, then the default is
/// [SnackBarBehavior.fixed]. /// [SnackBarBehavior.fixed].
final SnackBarBehavior behavior; final SnackBarBehavior? behavior;
/// (optional) An action that the user can take based on the snack bar. /// (optional) An action that the user can take based on the snack bar.
/// ///
...@@ -287,7 +285,7 @@ class SnackBar extends StatefulWidget { ...@@ -287,7 +285,7 @@ class SnackBar extends StatefulWidget {
/// prompted the snackbar. Snack bars can have at most one action. /// prompted the snackbar. Snack bars can have at most one action.
/// ///
/// The action should not be "dismiss" or "cancel". /// The action should not be "dismiss" or "cancel".
final SnackBarAction action; final SnackBarAction? action;
/// The amount of time the snack bar should be displayed. /// The amount of time the snack bar should be displayed.
/// ///
...@@ -302,15 +300,15 @@ class SnackBar extends StatefulWidget { ...@@ -302,15 +300,15 @@ class SnackBar extends StatefulWidget {
final Duration duration; final Duration duration;
/// The animation driving the entrance and exit of the snack bar. /// The animation driving the entrance and exit of the snack bar.
final Animation<double> animation; final Animation<double>? animation;
/// Called the first time that the snackbar is visible within a [Scaffold]. /// Called the first time that the snackbar is visible within a [Scaffold].
final VoidCallback onVisible; final VoidCallback? onVisible;
// API for Scaffold.showSnackBar(): // API for Scaffold.showSnackBar():
/// Creates an animation controller useful for driving a snack bar's entrance and exit animation. /// Creates an animation controller useful for driving a snack bar's entrance and exit animation.
static AnimationController createAnimationController({ @required TickerProvider vsync }) { static AnimationController createAnimationController({ required TickerProvider vsync }) {
return AnimationController( return AnimationController(
duration: _snackBarTransitionDuration, duration: _snackBarTransitionDuration,
debugLabel: 'SnackBar', debugLabel: 'SnackBar',
...@@ -322,7 +320,7 @@ class SnackBar extends StatefulWidget { ...@@ -322,7 +320,7 @@ class SnackBar extends StatefulWidget {
/// ///
/// If the original snack bar lacks a key, the newly created snack bar will /// If the original snack bar lacks a key, the newly created snack bar will
/// use the given fallback key. /// use the given fallback key.
SnackBar withAnimation(Animation<double> newAnimation, { Key fallbackKey }) { SnackBar withAnimation(Animation<double> newAnimation, { Key? fallbackKey }) {
return SnackBar( return SnackBar(
key: key ?? fallbackKey, key: key ?? fallbackKey,
content: content, content: content,
...@@ -351,21 +349,21 @@ class _SnackBarState extends State<SnackBar> { ...@@ -351,21 +349,21 @@ class _SnackBarState extends State<SnackBar> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
widget.animation.addStatusListener(_onAnimationStatusChanged); widget.animation!.addStatusListener(_onAnimationStatusChanged);
} }
@override @override
void didUpdateWidget(SnackBar oldWidget) { void didUpdateWidget(SnackBar oldWidget) {
if (widget.animation != oldWidget.animation) { if (widget.animation != oldWidget.animation) {
oldWidget.animation.removeStatusListener(_onAnimationStatusChanged); oldWidget.animation!.removeStatusListener(_onAnimationStatusChanged);
widget.animation.addStatusListener(_onAnimationStatusChanged); widget.animation!.addStatusListener(_onAnimationStatusChanged);
} }
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
} }
@override @override
void dispose() { void dispose() {
widget.animation.removeStatusListener(_onAnimationStatusChanged); widget.animation!.removeStatusListener(_onAnimationStatusChanged);
super.dispose(); super.dispose();
} }
...@@ -377,7 +375,7 @@ class _SnackBarState extends State<SnackBar> { ...@@ -377,7 +375,7 @@ class _SnackBarState extends State<SnackBar> {
break; break;
case AnimationStatus.completed: case AnimationStatus.completed:
if (widget.onVisible != null && !_wasVisible) { if (widget.onVisible != null && !_wasVisible) {
widget.onVisible(); widget.onVisible!();
} }
_wasVisible = true; _wasVisible = true;
} }
...@@ -385,9 +383,10 @@ class _SnackBarState extends State<SnackBar> { ...@@ -385,9 +383,10 @@ class _SnackBarState extends State<SnackBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final MediaQueryData mediaQueryData = MediaQuery.of(context); assert(debugCheckHasMediaQuery(context));
final MediaQueryData mediaQueryData = MediaQuery.of(context)!;
assert(widget.animation != null); assert(widget.animation != null);
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
final ColorScheme colorScheme = theme.colorScheme; final ColorScheme colorScheme = theme.colorScheme;
final SnackBarThemeData snackBarTheme = theme.snackBarTheme; final SnackBarThemeData snackBarTheme = theme.snackBarTheme;
final bool isThemeDark = theme.brightness == Brightness.dark; final bool isThemeDark = theme.brightness == Brightness.dark;
...@@ -422,17 +421,17 @@ class _SnackBarState extends State<SnackBar> { ...@@ -422,17 +421,17 @@ class _SnackBarState extends State<SnackBar> {
snackBarTheme: snackBarTheme, snackBarTheme: snackBarTheme,
); );
final TextStyle contentTextStyle = snackBarTheme.contentTextStyle ?? inverseTheme.textTheme.subtitle1; final TextStyle? contentTextStyle = snackBarTheme.contentTextStyle ?? inverseTheme.textTheme.subtitle1;
final SnackBarBehavior snackBarBehavior = widget.behavior ?? snackBarTheme.behavior ?? SnackBarBehavior.fixed; final SnackBarBehavior snackBarBehavior = widget.behavior ?? snackBarTheme.behavior ?? SnackBarBehavior.fixed;
final bool isFloatingSnackBar = snackBarBehavior == SnackBarBehavior.floating; final bool isFloatingSnackBar = snackBarBehavior == SnackBarBehavior.floating;
final double horizontalPadding = isFloatingSnackBar ? 16.0 : 24.0; final double horizontalPadding = isFloatingSnackBar ? 16.0 : 24.0;
final EdgeInsetsGeometry padding = widget.padding final EdgeInsetsGeometry padding = widget.padding
?? EdgeInsetsDirectional.only(start: horizontalPadding, end: widget.action != null ? 0 : horizontalPadding); ?? EdgeInsetsDirectional.only(start: horizontalPadding, end: widget.action != null ? 0 : horizontalPadding);
final CurvedAnimation heightAnimation = CurvedAnimation(parent: widget.animation, curve: _snackBarHeightCurve); final CurvedAnimation heightAnimation = CurvedAnimation(parent: widget.animation!, curve: _snackBarHeightCurve);
final CurvedAnimation fadeInAnimation = CurvedAnimation(parent: widget.animation, curve: _snackBarFadeInCurve); final CurvedAnimation fadeInAnimation = CurvedAnimation(parent: widget.animation!, curve: _snackBarFadeInCurve);
final CurvedAnimation fadeOutAnimation = CurvedAnimation( final CurvedAnimation fadeOutAnimation = CurvedAnimation(
parent: widget.animation, parent: widget.animation!,
curve: _snackBarFadeOutCurve, curve: _snackBarFadeOutCurve,
reverseCurve: const Threshold(0.0), reverseCurve: const Threshold(0.0),
); );
...@@ -474,7 +473,7 @@ class _SnackBarState extends State<SnackBar> { ...@@ -474,7 +473,7 @@ class _SnackBarState extends State<SnackBar> {
final double elevation = widget.elevation ?? snackBarTheme.elevation ?? 6.0; final double elevation = widget.elevation ?? snackBarTheme.elevation ?? 6.0;
final Color backgroundColor = widget.backgroundColor ?? snackBarTheme.backgroundColor ?? inverseTheme.backgroundColor; final Color backgroundColor = widget.backgroundColor ?? snackBarTheme.backgroundColor ?? inverseTheme.backgroundColor;
final ShapeBorder shape = widget.shape final ShapeBorder? shape = widget.shape
?? snackBarTheme.shape ?? snackBarTheme.shape
?? (isFloatingSnackBar ? RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0)) : null); ?? (isFloatingSnackBar ? RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0)) : null);
...@@ -526,14 +525,14 @@ class _SnackBarState extends State<SnackBar> { ...@@ -526,14 +525,14 @@ class _SnackBarState extends State<SnackBar> {
container: true, container: true,
liveRegion: true, liveRegion: true,
onDismiss: () { onDismiss: () {
Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss); Scaffold.of(context)!.removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss);
}, },
child: Dismissible( child: Dismissible(
key: const Key('dismissible'), key: const Key('dismissible'),
direction: DismissDirection.down, direction: DismissDirection.down,
resizeDuration: null, resizeDuration: null,
onDismissed: (DismissDirection direction) { onDismissed: (DismissDirection direction) {
Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe); Scaffold.of(context)!.removeCurrentSnackBar(reason: SnackBarClosedReason.swipe);
}, },
child: snackBar, child: snackBar,
), ),
...@@ -550,7 +549,7 @@ class _SnackBarState extends State<SnackBar> { ...@@ -550,7 +549,7 @@ class _SnackBarState extends State<SnackBar> {
} else { } else {
snackBarTransition = AnimatedBuilder( snackBarTransition = AnimatedBuilder(
animation: heightAnimation, animation: heightAnimation,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Align( return Align(
alignment: AlignmentDirectional.topStart, alignment: AlignmentDirectional.topStart,
heightFactor: heightAnimation.value, heightFactor: heightAnimation.value,
......
...@@ -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';
...@@ -67,30 +65,30 @@ class SnackBarThemeData with Diagnosticable { ...@@ -67,30 +65,30 @@ class SnackBarThemeData with Diagnosticable {
/// Default value for [SnackBar.backgroundColor]. /// Default value for [SnackBar.backgroundColor].
/// ///
/// If null, [SnackBar] defaults to dark grey: `Color(0xFF323232)`. /// If null, [SnackBar] defaults to dark grey: `Color(0xFF323232)`.
final Color backgroundColor; final Color? backgroundColor;
/// Default value for [SnackBarAction.textColor]. /// Default value for [SnackBarAction.textColor].
/// ///
/// If null, [SnackBarAction] defaults to [ColorScheme.secondary] of /// If null, [SnackBarAction] defaults to [ColorScheme.secondary] of
/// [ThemeData.colorScheme] . /// [ThemeData.colorScheme] .
final Color actionTextColor; final Color? actionTextColor;
/// Default value for [SnackBarAction.disabledTextColor]. /// Default value for [SnackBarAction.disabledTextColor].
/// ///
/// If null, [SnackBarAction] defaults to [ColorScheme.onSurface] with its /// If null, [SnackBarAction] defaults to [ColorScheme.onSurface] with its
/// opacity set to 0.30 if the [Theme]'s brightness is [Brightness.dark], 0.38 /// opacity set to 0.30 if the [Theme]'s brightness is [Brightness.dark], 0.38
/// otherwise. /// otherwise.
final Color disabledActionTextColor; final Color? disabledActionTextColor;
/// Used to configure the [DefaultTextStyle] for the [SnackBar.content] widget. /// Used to configure the [DefaultTextStyle] for the [SnackBar.content] widget.
/// ///
/// If null, [SnackBar] defines its default. /// If null, [SnackBar] defines its default.
final TextStyle contentTextStyle; final TextStyle? contentTextStyle;
/// Default value for [SnackBar.elevation]. /// Default value for [SnackBar.elevation].
/// ///
/// If null, [SnackBar] uses a default of 6.0. /// If null, [SnackBar] uses a default of 6.0.
final double elevation; final double? elevation;
/// Default value for [SnackBar.shape]. /// Default value for [SnackBar.shape].
/// ///
...@@ -99,23 +97,23 @@ class SnackBarThemeData with Diagnosticable { ...@@ -99,23 +97,23 @@ class SnackBarThemeData with Diagnosticable {
/// specified, so the [SnackBar] is rectangular. For /// specified, so the [SnackBar] is rectangular. For
/// [SnackBarBehavior.floating], it uses a [RoundedRectangleBorder] with a /// [SnackBarBehavior.floating], it uses a [RoundedRectangleBorder] with a
/// circular corner radius of 4.0. /// circular corner radius of 4.0.
final ShapeBorder shape; final ShapeBorder? shape;
/// Default value for [SnackBar.behavior]. /// Default value for [SnackBar.behavior].
/// ///
/// If null, [SnackBar] will default to [SnackBarBehavior.fixed]. /// If null, [SnackBar] will default to [SnackBarBehavior.fixed].
final SnackBarBehavior behavior; final SnackBarBehavior? behavior;
/// 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.
SnackBarThemeData copyWith({ SnackBarThemeData copyWith({
Color backgroundColor, Color? backgroundColor,
Color actionTextColor, Color? actionTextColor,
Color disabledActionTextColor, Color? disabledActionTextColor,
TextStyle contentTextStyle, TextStyle? contentTextStyle,
double elevation, double? elevation,
ShapeBorder shape, ShapeBorder? shape,
SnackBarBehavior behavior, SnackBarBehavior? behavior,
}) { }) {
return SnackBarThemeData( return SnackBarThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColor: backgroundColor ?? this.backgroundColor,
...@@ -133,7 +131,7 @@ class SnackBarThemeData with Diagnosticable { ...@@ -133,7 +131,7 @@ class SnackBarThemeData 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 SnackBarThemeData lerp(SnackBarThemeData a, SnackBarThemeData b, double t) { static SnackBarThemeData lerp(SnackBarThemeData? a, SnackBarThemeData? b, double t) {
assert(t != null); assert(t != null);
return SnackBarThemeData( return SnackBarThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
...@@ -142,7 +140,7 @@ class SnackBarThemeData with Diagnosticable { ...@@ -142,7 +140,7 @@ class SnackBarThemeData with Diagnosticable {
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t), contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t),
elevation: lerpDouble(a?.elevation, b?.elevation, t), elevation: lerpDouble(a?.elevation, b?.elevation, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
behavior: t < 0.5 ? a.behavior : b.behavior, behavior: t < 0.5 ? a?.behavior : b?.behavior,
); );
} }
......
...@@ -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/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -40,10 +38,10 @@ class Theme extends StatelessWidget { ...@@ -40,10 +38,10 @@ class Theme extends StatelessWidget {
/// ///
/// The [data] and [child] arguments must not be null. /// The [data] and [child] arguments must not be null.
const Theme({ const Theme({
Key key, Key? key,
@required this.data, required this.data,
this.isMaterialAppTheme = false, this.isMaterialAppTheme = false,
@required this.child, required this.child,
}) : assert(child != null), }) : assert(child != null),
assert(data != null), assert(data != null),
super(key: key); super(key: key);
...@@ -126,17 +124,17 @@ class Theme extends StatelessWidget { ...@@ -126,17 +124,17 @@ class Theme extends StatelessWidget {
/// ); /// );
/// } /// }
/// ``` /// ```
static ThemeData of(BuildContext context, { bool shadowThemeOnly = false }) { static ThemeData? of(BuildContext context, { bool shadowThemeOnly = false }) {
final _InheritedTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>(); final _InheritedTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>();
if (shadowThemeOnly) { if (shadowThemeOnly) {
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme) if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme)
return null; return null;
return inheritedTheme.theme.data; return inheritedTheme.theme.data;
} }
final MaterialLocalizations localizations = MaterialLocalizations.of(context); final MaterialLocalizations? localizations = MaterialLocalizations.of(context);
final ScriptCategory category = localizations?.scriptCategory ?? ScriptCategory.englishLike; final ScriptCategory category = localizations?.scriptCategory ?? ScriptCategory.englishLike;
final ThemeData theme = inheritedTheme?.theme?.data ?? _kFallbackTheme; final ThemeData theme = inheritedTheme?.theme.data ?? _kFallbackTheme;
return ThemeData.localize(theme, theme.typography.geometryThemeFor(category)); return ThemeData.localize(theme, theme.typography.geometryThemeFor(category));
} }
...@@ -168,9 +166,9 @@ class Theme extends StatelessWidget { ...@@ -168,9 +166,9 @@ class Theme extends StatelessWidget {
class _InheritedTheme extends InheritedTheme { class _InheritedTheme extends InheritedTheme {
const _InheritedTheme({ const _InheritedTheme({
Key key, Key? key,
@required this.theme, required this.theme,
@required Widget child, required Widget child,
}) : assert(theme != null), }) : assert(theme != null),
super(key: key, child: child); super(key: key, child: child);
...@@ -178,7 +176,7 @@ class _InheritedTheme extends InheritedTheme { ...@@ -178,7 +176,7 @@ class _InheritedTheme extends InheritedTheme {
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final _InheritedTheme ancestorTheme = context.findAncestorWidgetOfExactType<_InheritedTheme>(); final _InheritedTheme? ancestorTheme = context.findAncestorWidgetOfExactType<_InheritedTheme>();
return identical(this, ancestorTheme) ? child : Theme(data: theme.data, child: child); return identical(this, ancestorTheme) ? child : Theme(data: theme.data, child: child);
} }
...@@ -198,10 +196,10 @@ class ThemeDataTween extends Tween<ThemeData> { ...@@ -198,10 +196,10 @@ class ThemeDataTween extends Tween<ThemeData> {
/// The [begin] and [end] properties must be non-null before the tween is /// The [begin] and [end] properties must be non-null before the tween is
/// first used, but the arguments can be null if the values are going to be /// first used, but the arguments can be null if the values are going to be
/// filled in later. /// filled in later.
ThemeDataTween({ ThemeData begin, ThemeData end }) : super(begin: begin, end: end); ThemeDataTween({ ThemeData? begin, ThemeData? end }) : super(begin: begin, end: end);
@override @override
ThemeData lerp(double t) => ThemeData.lerp(begin, end, t); ThemeData lerp(double t) => ThemeData.lerp(begin!, end!, t);
} }
/// Animated version of [Theme] which automatically transitions the colors, /// Animated version of [Theme] which automatically transitions the colors,
...@@ -224,13 +222,13 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget { ...@@ -224,13 +222,13 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget {
/// By default, the theme transition uses a linear curve. The [data] and /// By default, the theme transition uses a linear curve. The [data] and
/// [child] arguments must not be null. /// [child] arguments must not be null.
const AnimatedTheme({ const AnimatedTheme({
Key key, Key? key,
@required this.data, required this.data,
this.isMaterialAppTheme = false, this.isMaterialAppTheme = false,
Curve curve = Curves.linear, Curve curve = Curves.linear,
Duration duration = kThemeAnimationDuration, Duration duration = kThemeAnimationDuration,
VoidCallback onEnd, VoidCallback? onEnd,
@required this.child, required this.child,
}) : assert(child != null), }) : assert(child != null),
assert(data != null), assert(data != null),
super(key: key, curve: curve, duration: duration, onEnd: onEnd); super(key: key, curve: curve, duration: duration, onEnd: onEnd);
...@@ -251,7 +249,7 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget { ...@@ -251,7 +249,7 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget {
} }
class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> { class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
ThemeDataTween _data; ThemeDataTween? _data;
@override @override
void forEachTween(TweenVisitor<dynamic> visitor) { void forEachTween(TweenVisitor<dynamic> visitor) {
...@@ -265,7 +263,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> { ...@@ -265,7 +263,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
return Theme( return Theme(
isMaterialAppTheme: widget.isMaterialAppTheme, isMaterialAppTheme: widget.isMaterialAppTheme,
child: widget.child, child: widget.child,
data: _data.evaluate(animation), data: _data!.evaluate(animation!),
); );
} }
......
...@@ -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 Color, hashList, lerpDouble; import 'dart:ui' show Color, hashList, lerpDouble;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -211,118 +209,118 @@ class ThemeData with Diagnosticable { ...@@ -211,118 +209,118 @@ class ThemeData with Diagnosticable {
/// * [ThemeData.light], which creates a light blue theme. /// * [ThemeData.light], which creates a light blue theme.
/// * [ThemeData.dark], which creates dark theme with a teal secondary [ColorScheme] color. /// * [ThemeData.dark], which creates dark theme with a teal secondary [ColorScheme] color.
factory ThemeData({ factory ThemeData({
Brightness brightness, Brightness? brightness,
VisualDensity visualDensity, VisualDensity? visualDensity,
MaterialColor primarySwatch, MaterialColor? primarySwatch,
Color primaryColor, Color? primaryColor,
Brightness primaryColorBrightness, Brightness? primaryColorBrightness,
Color primaryColorLight, Color? primaryColorLight,
Color primaryColorDark, Color? primaryColorDark,
Color accentColor, Color? accentColor,
Brightness accentColorBrightness, Brightness? accentColorBrightness,
Color canvasColor, Color? canvasColor,
Color shadowColor, Color? shadowColor,
Color scaffoldBackgroundColor, Color? scaffoldBackgroundColor,
Color bottomAppBarColor, Color? bottomAppBarColor,
Color cardColor, Color? cardColor,
Color dividerColor, Color? dividerColor,
Color focusColor, Color? focusColor,
Color hoverColor, Color? hoverColor,
Color highlightColor, Color? highlightColor,
Color splashColor, Color? splashColor,
InteractiveInkFeatureFactory splashFactory, InteractiveInkFeatureFactory? splashFactory,
Color selectedRowColor, Color? selectedRowColor,
Color unselectedWidgetColor, Color? unselectedWidgetColor,
Color disabledColor, Color? disabledColor,
Color buttonColor, Color? buttonColor,
ButtonThemeData buttonTheme, ButtonThemeData? buttonTheme,
ToggleButtonsThemeData toggleButtonsTheme, ToggleButtonsThemeData? toggleButtonsTheme,
Color secondaryHeaderColor, Color? secondaryHeaderColor,
@Deprecated( @Deprecated(
'Use TextSelectionThemeData.selectionColor instead. ' 'Use TextSelectionThemeData.selectionColor instead. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
Color textSelectionColor, Color? textSelectionColor,
@Deprecated( @Deprecated(
'Use TextSelectionThemeData.cursorColor instead. ' 'Use TextSelectionThemeData.cursorColor instead. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
Color cursorColor, Color? cursorColor,
@Deprecated( @Deprecated(
'Use TextSelectionThemeData.selectionHandleColor instead. ' 'Use TextSelectionThemeData.selectionHandleColor instead. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
Color textSelectionHandleColor, Color? textSelectionHandleColor,
Color backgroundColor, Color? backgroundColor,
Color dialogBackgroundColor, Color? dialogBackgroundColor,
Color indicatorColor, Color? indicatorColor,
Color hintColor, Color? hintColor,
Color errorColor, Color? errorColor,
Color toggleableActiveColor, Color? toggleableActiveColor,
String fontFamily, String? fontFamily,
TextTheme textTheme, TextTheme? textTheme,
TextTheme primaryTextTheme, TextTheme? primaryTextTheme,
TextTheme accentTextTheme, TextTheme? accentTextTheme,
InputDecorationTheme inputDecorationTheme, InputDecorationTheme? inputDecorationTheme,
IconThemeData iconTheme, IconThemeData? iconTheme,
IconThemeData primaryIconTheme, IconThemeData? primaryIconTheme,
IconThemeData accentIconTheme, IconThemeData? accentIconTheme,
SliderThemeData sliderTheme, SliderThemeData? sliderTheme,
TabBarTheme tabBarTheme, TabBarTheme? tabBarTheme,
TooltipThemeData tooltipTheme, TooltipThemeData? tooltipTheme,
CardTheme cardTheme, CardTheme? cardTheme,
ChipThemeData chipTheme, ChipThemeData? chipTheme,
TargetPlatform platform, TargetPlatform? platform,
MaterialTapTargetSize materialTapTargetSize, MaterialTapTargetSize? materialTapTargetSize,
bool applyElevationOverlayColor, bool? applyElevationOverlayColor,
PageTransitionsTheme pageTransitionsTheme, PageTransitionsTheme? pageTransitionsTheme,
AppBarTheme appBarTheme, AppBarTheme? appBarTheme,
BottomAppBarTheme bottomAppBarTheme, BottomAppBarTheme? bottomAppBarTheme,
ColorScheme colorScheme, ColorScheme? colorScheme,
DialogTheme dialogTheme, DialogTheme? dialogTheme,
FloatingActionButtonThemeData floatingActionButtonTheme, FloatingActionButtonThemeData? floatingActionButtonTheme,
NavigationRailThemeData navigationRailTheme, NavigationRailThemeData? navigationRailTheme,
Typography typography, Typography? typography,
NoDefaultCupertinoThemeData cupertinoOverrideTheme, NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
SnackBarThemeData snackBarTheme, SnackBarThemeData? snackBarTheme,
BottomSheetThemeData bottomSheetTheme, BottomSheetThemeData? bottomSheetTheme,
PopupMenuThemeData popupMenuTheme, PopupMenuThemeData? popupMenuTheme,
MaterialBannerThemeData bannerTheme, MaterialBannerThemeData? bannerTheme,
DividerThemeData dividerTheme, DividerThemeData? dividerTheme,
ButtonBarThemeData buttonBarTheme, ButtonBarThemeData? buttonBarTheme,
BottomNavigationBarThemeData bottomNavigationBarTheme, BottomNavigationBarThemeData? bottomNavigationBarTheme,
TimePickerThemeData timePickerTheme, TimePickerThemeData? timePickerTheme,
TextButtonThemeData textButtonTheme, TextButtonThemeData? textButtonTheme,
ElevatedButtonThemeData elevatedButtonTheme, ElevatedButtonThemeData? elevatedButtonTheme,
OutlinedButtonThemeData outlinedButtonTheme, OutlinedButtonThemeData? outlinedButtonTheme,
TextSelectionThemeData textSelectionTheme, TextSelectionThemeData? textSelectionTheme,
DataTableThemeData dataTableTheme, DataTableThemeData? dataTableTheme,
bool fixTextFieldOutlineLabel, bool? fixTextFieldOutlineLabel,
@Deprecated( @Deprecated(
'No longer used by the framework, please remove any reference to it. ' 'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
bool useTextSelectionTheme, bool? useTextSelectionTheme,
}) { }) {
assert(colorScheme?.brightness == null || brightness == null || colorScheme.brightness == brightness); assert(colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness);
final Brightness _brightness = brightness ?? colorScheme?.brightness ?? Brightness.light; final Brightness _brightness = brightness ?? colorScheme?.brightness ?? Brightness.light;
final bool isDark = _brightness == Brightness.dark; final bool isDark = _brightness == Brightness.dark;
visualDensity ??= VisualDensity.adaptivePlatformDensity; visualDensity ??= VisualDensity.adaptivePlatformDensity;
primarySwatch ??= Colors.blue; primarySwatch ??= Colors.blue;
primaryColor ??= isDark ? Colors.grey[900] : primarySwatch; primaryColor ??= isDark ? Colors.grey[900]! : primarySwatch;
primaryColorBrightness ??= estimateBrightnessForColor(primaryColor); primaryColorBrightness ??= estimateBrightnessForColor(primaryColor);
primaryColorLight ??= isDark ? Colors.grey[500] : primarySwatch[100]; primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]; primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
final bool primaryIsDark = primaryColorBrightness == Brightness.dark; final bool primaryIsDark = primaryColorBrightness == Brightness.dark;
toggleableActiveColor ??= isDark ? Colors.tealAccent[200] : (accentColor ?? primarySwatch[600]); toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (accentColor ?? primarySwatch[600]!);
accentColor ??= isDark ? Colors.tealAccent[200] : primarySwatch[500]; accentColor ??= isDark ? Colors.tealAccent[200]! : primarySwatch[500]!;
accentColorBrightness ??= estimateBrightnessForColor(accentColor); accentColorBrightness ??= estimateBrightnessForColor(accentColor);
final bool accentIsDark = accentColorBrightness == Brightness.dark; final bool accentIsDark = accentColorBrightness == Brightness.dark;
canvasColor ??= isDark ? Colors.grey[850] : Colors.grey[50]; canvasColor ??= isDark ? Colors.grey[850]! : Colors.grey[50]!;
shadowColor ??= Colors.black; shadowColor ??= Colors.black;
scaffoldBackgroundColor ??= canvasColor; scaffoldBackgroundColor ??= canvasColor;
bottomAppBarColor ??= isDark ? Colors.grey[800] : Colors.white; bottomAppBarColor ??= isDark ? Colors.grey[800]! : Colors.white;
cardColor ??= isDark ? Colors.grey[800] : Colors.white; cardColor ??= isDark ? Colors.grey[800]! : Colors.white;
dividerColor ??= isDark ? const Color(0x1FFFFFFF) : const Color(0x1F000000); dividerColor ??= isDark ? const Color(0x1FFFFFFF) : const Color(0x1F000000);
// Create a ColorScheme that is backwards compatible as possible // Create a ColorScheme that is backwards compatible as possible
...@@ -338,18 +336,18 @@ class ThemeData with Diagnosticable { ...@@ -338,18 +336,18 @@ class ThemeData with Diagnosticable {
); );
splashFactory ??= InkSplash.splashFactory; splashFactory ??= InkSplash.splashFactory;
selectedRowColor ??= Colors.grey[100]; selectedRowColor ??= Colors.grey[100]!;
unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54; unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54;
// Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess. // Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
secondaryHeaderColor ??= isDark ? Colors.grey[700] : primarySwatch[50]; secondaryHeaderColor ??= isDark ? Colors.grey[700]! : primarySwatch[50]!;
textSelectionColor ??= isDark ? accentColor : primarySwatch[200]; textSelectionColor ??= isDark ? accentColor : primarySwatch[200]!;
cursorColor = cursorColor ?? const Color.fromRGBO(66, 133, 244, 1.0); cursorColor = cursorColor ?? const Color.fromRGBO(66, 133, 244, 1.0);
textSelectionHandleColor ??= isDark ? Colors.tealAccent[400] : primarySwatch[300]; textSelectionHandleColor ??= isDark ? Colors.tealAccent[400]! : primarySwatch[300]!;
backgroundColor ??= isDark ? Colors.grey[700] : primarySwatch[200]; backgroundColor ??= isDark ? Colors.grey[700]! : primarySwatch[200]!;
dialogBackgroundColor ??= isDark ? Colors.grey[800] : Colors.white; dialogBackgroundColor ??= isDark ? Colors.grey[800]! : Colors.white;
indicatorColor ??= accentColor == primaryColor ? Colors.white : accentColor; indicatorColor ??= accentColor == primaryColor ? Colors.white : accentColor;
hintColor ??= isDark ? Colors.white60 : Colors.black.withOpacity(0.6); hintColor ??= isDark ? Colors.white60 : Colors.black.withOpacity(0.6);
errorColor ??= Colors.red[700]; errorColor ??= Colors.red[700]!;
inputDecorationTheme ??= const InputDecorationTheme(); inputDecorationTheme ??= const InputDecorationTheme();
pageTransitionsTheme ??= const PageTransitionsTheme(); pageTransitionsTheme ??= const PageTransitionsTheme();
primaryIconTheme ??= primaryIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); primaryIconTheme ??= primaryIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
...@@ -384,7 +382,7 @@ class ThemeData with Diagnosticable { ...@@ -384,7 +382,7 @@ class ThemeData with Diagnosticable {
// Used as the default color (fill color) for RaisedButtons. Computing the // Used as the default color (fill color) for RaisedButtons. Computing the
// default for ButtonThemeData for the sake of backwards compatibility. // default for ButtonThemeData for the sake of backwards compatibility.
buttonColor ??= isDark ? primarySwatch[600] : Colors.grey[300]; buttonColor ??= isDark ? primarySwatch[600]! : Colors.grey[300]!;
focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12); focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12);
hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04); hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04);
buttonTheme ??= ButtonThemeData( buttonTheme ??= ButtonThemeData(
...@@ -411,7 +409,7 @@ class ThemeData with Diagnosticable { ...@@ -411,7 +409,7 @@ class ThemeData with Diagnosticable {
chipTheme ??= ChipThemeData.fromDefaults( chipTheme ??= ChipThemeData.fromDefaults(
secondaryColor: primaryColor, secondaryColor: primaryColor,
brightness: colorScheme.brightness, brightness: colorScheme.brightness,
labelStyle: textTheme.bodyText1, labelStyle: textTheme.bodyText1!,
); );
dialogTheme ??= const DialogTheme(); dialogTheme ??= const DialogTheme();
floatingActionButtonTheme ??= const FloatingActionButtonThemeData(); floatingActionButtonTheme ??= const FloatingActionButtonThemeData();
...@@ -522,79 +520,79 @@ class ThemeData with Diagnosticable { ...@@ -522,79 +520,79 @@ class ThemeData with Diagnosticable {
// Warning: make sure these properties are in the exact same order as in // Warning: make sure these properties are in the exact same order as in
// operator == and in the hashValues method and in the order of fields // operator == and in the hashValues method and in the order of fields
// in this class, and in the lerp() method. // in this class, and in the lerp() method.
@required this.visualDensity, required this.visualDensity,
@required this.primaryColor, required this.primaryColor,
@required this.primaryColorBrightness, required this.primaryColorBrightness,
@required this.primaryColorLight, required this.primaryColorLight,
@required this.primaryColorDark, required this.primaryColorDark,
@required this.canvasColor, required this.canvasColor,
@required this.shadowColor, required this.shadowColor,
@required this.accentColor, required this.accentColor,
@required this.accentColorBrightness, required this.accentColorBrightness,
@required this.scaffoldBackgroundColor, required this.scaffoldBackgroundColor,
@required this.bottomAppBarColor, required this.bottomAppBarColor,
@required this.cardColor, required this.cardColor,
@required this.dividerColor, required this.dividerColor,
@required this.focusColor, required this.focusColor,
@required this.hoverColor, required this.hoverColor,
@required this.highlightColor, required this.highlightColor,
@required this.splashColor, required this.splashColor,
@required this.splashFactory, required this.splashFactory,
@required this.selectedRowColor, required this.selectedRowColor,
@required this.unselectedWidgetColor, required this.unselectedWidgetColor,
@required this.disabledColor, required this.disabledColor,
@required this.buttonTheme, required this.buttonTheme,
@required this.buttonColor, required this.buttonColor,
@required this.toggleButtonsTheme, required this.toggleButtonsTheme,
@required this.secondaryHeaderColor, required this.secondaryHeaderColor,
@required this.textSelectionColor, required this.textSelectionColor,
@required this.cursorColor, required this.cursorColor,
@required this.textSelectionHandleColor, required this.textSelectionHandleColor,
@required this.backgroundColor, required this.backgroundColor,
@required this.dialogBackgroundColor, required this.dialogBackgroundColor,
@required this.indicatorColor, required this.indicatorColor,
@required this.hintColor, required this.hintColor,
@required this.errorColor, required this.errorColor,
@required this.toggleableActiveColor, required this.toggleableActiveColor,
@required this.textTheme, required this.textTheme,
@required this.primaryTextTheme, required this.primaryTextTheme,
@required this.accentTextTheme, required this.accentTextTheme,
@required this.inputDecorationTheme, required this.inputDecorationTheme,
@required this.iconTheme, required this.iconTheme,
@required this.primaryIconTheme, required this.primaryIconTheme,
@required this.accentIconTheme, required this.accentIconTheme,
@required this.sliderTheme, required this.sliderTheme,
@required this.tabBarTheme, required this.tabBarTheme,
@required this.tooltipTheme, required this.tooltipTheme,
@required this.cardTheme, required this.cardTheme,
@required this.chipTheme, required this.chipTheme,
@required this.platform, required this.platform,
@required this.materialTapTargetSize, required this.materialTapTargetSize,
@required this.applyElevationOverlayColor, required this.applyElevationOverlayColor,
@required this.pageTransitionsTheme, required this.pageTransitionsTheme,
@required this.appBarTheme, required this.appBarTheme,
@required this.bottomAppBarTheme, required this.bottomAppBarTheme,
@required this.colorScheme, required this.colorScheme,
@required this.dialogTheme, required this.dialogTheme,
@required this.floatingActionButtonTheme, required this.floatingActionButtonTheme,
@required this.navigationRailTheme, required this.navigationRailTheme,
@required this.typography, required this.typography,
@required this.cupertinoOverrideTheme, required this.cupertinoOverrideTheme,
@required this.snackBarTheme, required this.snackBarTheme,
@required this.bottomSheetTheme, required this.bottomSheetTheme,
@required this.popupMenuTheme, required this.popupMenuTheme,
@required this.bannerTheme, required this.bannerTheme,
@required this.dividerTheme, required this.dividerTheme,
@required this.buttonBarTheme, required this.buttonBarTheme,
@required this.bottomNavigationBarTheme, required this.bottomNavigationBarTheme,
@required this.timePickerTheme, required this.timePickerTheme,
@required this.textButtonTheme, required this.textButtonTheme,
@required this.elevatedButtonTheme, required this.elevatedButtonTheme,
@required this.outlinedButtonTheme, required this.outlinedButtonTheme,
@required this.textSelectionTheme, required this.textSelectionTheme,
@required this.dataTableTheme, required this.dataTableTheme,
@required this.fixTextFieldOutlineLabel, required this.fixTextFieldOutlineLabel,
@required this.useTextSelectionTheme, required this.useTextSelectionTheme,
}) : assert(visualDensity != null), }) : assert(visualDensity != null),
assert(primaryColor != null), assert(primaryColor != null),
assert(primaryColorBrightness != null), assert(primaryColorBrightness != null),
...@@ -695,8 +693,8 @@ class ThemeData with Diagnosticable { ...@@ -695,8 +693,8 @@ class ThemeData with Diagnosticable {
/// See <https://material.io/design/color/> for /// See <https://material.io/design/color/> for
/// more discussion on how to pick the right colors. /// more discussion on how to pick the right colors.
factory ThemeData.from({ factory ThemeData.from({
@required ColorScheme colorScheme, required ColorScheme colorScheme,
TextTheme textTheme, TextTheme? textTheme,
}) { }) {
assert(colorScheme != null); assert(colorScheme != null);
...@@ -1110,7 +1108,7 @@ class ThemeData with Diagnosticable { ...@@ -1110,7 +1108,7 @@ class ThemeData with Diagnosticable {
/// ///
/// This cascading effect for individual attributes of the [CupertinoThemeData] /// This cascading effect for individual attributes of the [CupertinoThemeData]
/// can be overridden using attributes of this [cupertinoOverrideTheme]. /// can be overridden using attributes of this [cupertinoOverrideTheme].
final NoDefaultCupertinoThemeData cupertinoOverrideTheme; final NoDefaultCupertinoThemeData? cupertinoOverrideTheme;
/// A theme for customizing the color, elevation, and shape of a bottom sheet. /// A theme for customizing the color, elevation, and shape of a bottom sheet.
final BottomSheetThemeData bottomSheetTheme; final BottomSheetThemeData bottomSheetTheme;
...@@ -1181,96 +1179,96 @@ class ThemeData with Diagnosticable { ...@@ -1181,96 +1179,96 @@ class ThemeData with Diagnosticable {
/// ///
/// The [brightness] value is applied to the [colorScheme]. /// The [brightness] value is applied to the [colorScheme].
ThemeData copyWith({ ThemeData copyWith({
Brightness brightness, Brightness? brightness,
VisualDensity visualDensity, VisualDensity? visualDensity,
Color primaryColor, Color? primaryColor,
Brightness primaryColorBrightness, Brightness? primaryColorBrightness,
Color primaryColorLight, Color? primaryColorLight,
Color primaryColorDark, Color? primaryColorDark,
Color accentColor, Color? accentColor,
Brightness accentColorBrightness, Brightness? accentColorBrightness,
Color canvasColor, Color? canvasColor,
Color shadowColor, Color? shadowColor,
Color scaffoldBackgroundColor, Color? scaffoldBackgroundColor,
Color bottomAppBarColor, Color? bottomAppBarColor,
Color cardColor, Color? cardColor,
Color dividerColor, Color? dividerColor,
Color focusColor, Color? focusColor,
Color hoverColor, Color? hoverColor,
Color highlightColor, Color? highlightColor,
Color splashColor, Color? splashColor,
InteractiveInkFeatureFactory splashFactory, InteractiveInkFeatureFactory? splashFactory,
Color selectedRowColor, Color? selectedRowColor,
Color unselectedWidgetColor, Color? unselectedWidgetColor,
Color disabledColor, Color? disabledColor,
ButtonThemeData buttonTheme, ButtonThemeData? buttonTheme,
ToggleButtonsThemeData toggleButtonsTheme, ToggleButtonsThemeData? toggleButtonsTheme,
Color buttonColor, Color? buttonColor,
Color secondaryHeaderColor, Color? secondaryHeaderColor,
@Deprecated( @Deprecated(
'Use TextSelectionThemeData.selectionColor instead. ' 'Use TextSelectionThemeData.selectionColor instead. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
Color textSelectionColor, Color? textSelectionColor,
@Deprecated( @Deprecated(
'Use TextSelectionThemeData.cursorColor instead. ' 'Use TextSelectionThemeData.cursorColor instead. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
Color cursorColor, Color? cursorColor,
@Deprecated( @Deprecated(
'Use TextSelectionThemeData.selectionHandleColor instead. ' 'Use TextSelectionThemeData.selectionHandleColor instead. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
Color textSelectionHandleColor, Color? textSelectionHandleColor,
Color backgroundColor, Color? backgroundColor,
Color dialogBackgroundColor, Color? dialogBackgroundColor,
Color indicatorColor, Color? indicatorColor,
Color hintColor, Color? hintColor,
Color errorColor, Color? errorColor,
Color toggleableActiveColor, Color? toggleableActiveColor,
TextTheme textTheme, TextTheme? textTheme,
TextTheme primaryTextTheme, TextTheme? primaryTextTheme,
TextTheme accentTextTheme, TextTheme? accentTextTheme,
InputDecorationTheme inputDecorationTheme, InputDecorationTheme? inputDecorationTheme,
IconThemeData iconTheme, IconThemeData? iconTheme,
IconThemeData primaryIconTheme, IconThemeData? primaryIconTheme,
IconThemeData accentIconTheme, IconThemeData? accentIconTheme,
SliderThemeData sliderTheme, SliderThemeData? sliderTheme,
TabBarTheme tabBarTheme, TabBarTheme? tabBarTheme,
TooltipThemeData tooltipTheme, TooltipThemeData? tooltipTheme,
CardTheme cardTheme, CardTheme? cardTheme,
ChipThemeData chipTheme, ChipThemeData? chipTheme,
TargetPlatform platform, TargetPlatform? platform,
MaterialTapTargetSize materialTapTargetSize, MaterialTapTargetSize? materialTapTargetSize,
bool applyElevationOverlayColor, bool? applyElevationOverlayColor,
PageTransitionsTheme pageTransitionsTheme, PageTransitionsTheme? pageTransitionsTheme,
AppBarTheme appBarTheme, AppBarTheme? appBarTheme,
BottomAppBarTheme bottomAppBarTheme, BottomAppBarTheme? bottomAppBarTheme,
ColorScheme colorScheme, ColorScheme? colorScheme,
DialogTheme dialogTheme, DialogTheme? dialogTheme,
FloatingActionButtonThemeData floatingActionButtonTheme, FloatingActionButtonThemeData? floatingActionButtonTheme,
NavigationRailThemeData navigationRailTheme, NavigationRailThemeData? navigationRailTheme,
Typography typography, Typography? typography,
NoDefaultCupertinoThemeData cupertinoOverrideTheme, NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
SnackBarThemeData snackBarTheme, SnackBarThemeData? snackBarTheme,
BottomSheetThemeData bottomSheetTheme, BottomSheetThemeData? bottomSheetTheme,
PopupMenuThemeData popupMenuTheme, PopupMenuThemeData? popupMenuTheme,
MaterialBannerThemeData bannerTheme, MaterialBannerThemeData? bannerTheme,
DividerThemeData dividerTheme, DividerThemeData? dividerTheme,
ButtonBarThemeData buttonBarTheme, ButtonBarThemeData? buttonBarTheme,
BottomNavigationBarThemeData bottomNavigationBarTheme, BottomNavigationBarThemeData? bottomNavigationBarTheme,
TimePickerThemeData timePickerTheme, TimePickerThemeData? timePickerTheme,
TextButtonThemeData textButtonTheme, TextButtonThemeData? textButtonTheme,
ElevatedButtonThemeData elevatedButtonTheme, ElevatedButtonThemeData? elevatedButtonTheme,
OutlinedButtonThemeData outlinedButtonTheme, OutlinedButtonThemeData? outlinedButtonTheme,
TextSelectionThemeData textSelectionTheme, TextSelectionThemeData? textSelectionTheme,
DataTableThemeData dataTableTheme, DataTableThemeData? dataTableTheme,
bool fixTextFieldOutlineLabel, bool? fixTextFieldOutlineLabel,
@Deprecated( @Deprecated(
'No longer used by the framework, please remove any reference to it. ' 'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v1.23.0-4.0.pre.' 'This feature was deprecated after v1.23.0-4.0.pre.'
) )
bool useTextSelectionTheme, bool? useTextSelectionTheme,
}) { }) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
return ThemeData.raw( return ThemeData.raw(
...@@ -1429,39 +1427,39 @@ class ThemeData with Diagnosticable { ...@@ -1429,39 +1427,39 @@ class ThemeData with Diagnosticable {
// the class and in the lerp() method. // the class and in the lerp() method.
return ThemeData.raw( return ThemeData.raw(
visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t), visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t),
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t), primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!,
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness, primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t), primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t)!,
primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t), primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t)!,
canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t), canvasColor: Color.lerp(a.canvasColor, b.canvasColor, t)!,
shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t), shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t)!,
accentColor: Color.lerp(a.accentColor, b.accentColor, t), accentColor: Color.lerp(a.accentColor, b.accentColor, t)!,
accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness, accentColorBrightness: t < 0.5 ? a.accentColorBrightness : b.accentColorBrightness,
scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t), scaffoldBackgroundColor: Color.lerp(a.scaffoldBackgroundColor, b.scaffoldBackgroundColor, t)!,
bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t), bottomAppBarColor: Color.lerp(a.bottomAppBarColor, b.bottomAppBarColor, t)!,
cardColor: Color.lerp(a.cardColor, b.cardColor, t), cardColor: Color.lerp(a.cardColor, b.cardColor, t)!,
dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t), dividerColor: Color.lerp(a.dividerColor, b.dividerColor, t)!,
focusColor: Color.lerp(a.focusColor, b.focusColor, t), focusColor: Color.lerp(a.focusColor, b.focusColor, t)!,
hoverColor: Color.lerp(a.hoverColor, b.hoverColor, t), hoverColor: Color.lerp(a.hoverColor, b.hoverColor, t)!,
highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t), highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t)!,
splashColor: Color.lerp(a.splashColor, b.splashColor, t), splashColor: Color.lerp(a.splashColor, b.splashColor, t)!,
splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory, splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t), selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t)!,
unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t), unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t)!,
disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t), disabledColor: Color.lerp(a.disabledColor, b.disabledColor, t)!,
buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme, buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t), toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t),
buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t), buttonColor: Color.lerp(a.buttonColor, b.buttonColor, t)!,
secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t), secondaryHeaderColor: Color.lerp(a.secondaryHeaderColor, b.secondaryHeaderColor, t)!,
textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t), textSelectionColor: Color.lerp(a.textSelectionColor, b.textSelectionColor, t)!,
cursorColor: Color.lerp(a.cursorColor, b.cursorColor, t), cursorColor: Color.lerp(a.cursorColor, b.cursorColor, t)!,
textSelectionHandleColor: Color.lerp(a.textSelectionHandleColor, b.textSelectionHandleColor, t), textSelectionHandleColor: Color.lerp(a.textSelectionHandleColor, b.textSelectionHandleColor, t)!,
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t)!,
dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t), dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t)!,
indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t), indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t)!,
hintColor: Color.lerp(a.hintColor, b.hintColor, t), hintColor: Color.lerp(a.hintColor, b.hintColor, t)!,
errorColor: Color.lerp(a.errorColor, b.errorColor, t), errorColor: Color.lerp(a.errorColor, b.errorColor, t)!,
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t), toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t)!,
textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t), textTheme: TextTheme.lerp(a.textTheme, b.textTheme, t),
primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t), primaryTextTheme: TextTheme.lerp(a.primaryTextTheme, b.primaryTextTheme, t),
accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t), accentTextTheme: TextTheme.lerp(a.accentTextTheme, b.accentTextTheme, t),
...@@ -1471,9 +1469,9 @@ class ThemeData with Diagnosticable { ...@@ -1471,9 +1469,9 @@ class ThemeData with Diagnosticable {
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t), accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
sliderTheme: SliderThemeData.lerp(a.sliderTheme, b.sliderTheme, t), sliderTheme: SliderThemeData.lerp(a.sliderTheme, b.sliderTheme, t),
tabBarTheme: TabBarTheme.lerp(a.tabBarTheme, b.tabBarTheme, t), tabBarTheme: TabBarTheme.lerp(a.tabBarTheme, b.tabBarTheme, t),
tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t), tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
cardTheme: CardTheme.lerp(a.cardTheme, b.cardTheme, t), cardTheme: CardTheme.lerp(a.cardTheme, b.cardTheme, t),
chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t), chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t)!,
platform: t < 0.5 ? a.platform : b.platform, platform: t < 0.5 ? a.platform : b.platform,
materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize, materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
applyElevationOverlayColor: t < 0.5 ? a.applyElevationOverlayColor : b.applyElevationOverlayColor, applyElevationOverlayColor: t < 0.5 ? a.applyElevationOverlayColor : b.applyElevationOverlayColor,
...@@ -1482,20 +1480,20 @@ class ThemeData with Diagnosticable { ...@@ -1482,20 +1480,20 @@ class ThemeData with Diagnosticable {
bottomAppBarTheme: BottomAppBarTheme.lerp(a.bottomAppBarTheme, b.bottomAppBarTheme, t), bottomAppBarTheme: BottomAppBarTheme.lerp(a.bottomAppBarTheme, b.bottomAppBarTheme, t),
colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t), colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
dialogTheme: DialogTheme.lerp(a.dialogTheme, b.dialogTheme, t), dialogTheme: DialogTheme.lerp(a.dialogTheme, b.dialogTheme, t),
floatingActionButtonTheme: FloatingActionButtonThemeData.lerp(a.floatingActionButtonTheme, b.floatingActionButtonTheme, t), floatingActionButtonTheme: FloatingActionButtonThemeData.lerp(a.floatingActionButtonTheme, b.floatingActionButtonTheme, t)!,
navigationRailTheme: NavigationRailThemeData.lerp(a.navigationRailTheme, b.navigationRailTheme, t), navigationRailTheme: NavigationRailThemeData.lerp(a.navigationRailTheme, b.navigationRailTheme, t),
typography: Typography.lerp(a.typography, b.typography, t), typography: Typography.lerp(a.typography, b.typography, t),
cupertinoOverrideTheme: t < 0.5 ? a.cupertinoOverrideTheme : b.cupertinoOverrideTheme, cupertinoOverrideTheme: t < 0.5 ? a.cupertinoOverrideTheme : b.cupertinoOverrideTheme,
snackBarTheme: SnackBarThemeData.lerp(a.snackBarTheme, b.snackBarTheme, t), snackBarTheme: SnackBarThemeData.lerp(a.snackBarTheme, b.snackBarTheme, t),
bottomSheetTheme: BottomSheetThemeData.lerp(a.bottomSheetTheme, b.bottomSheetTheme, t), bottomSheetTheme: BottomSheetThemeData.lerp(a.bottomSheetTheme, b.bottomSheetTheme, t)!,
popupMenuTheme: PopupMenuThemeData.lerp(a.popupMenuTheme, b.popupMenuTheme, t), popupMenuTheme: PopupMenuThemeData.lerp(a.popupMenuTheme, b.popupMenuTheme, t),
bannerTheme: MaterialBannerThemeData.lerp(a.bannerTheme, b.bannerTheme, t), bannerTheme: MaterialBannerThemeData.lerp(a.bannerTheme, b.bannerTheme, t),
dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t), dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t),
buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t), buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t)!,
bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t), bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t),
timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t), timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t),
textButtonTheme: TextButtonThemeData.lerp(a.textButtonTheme, b.textButtonTheme, t), textButtonTheme: TextButtonThemeData.lerp(a.textButtonTheme, b.textButtonTheme, t),
elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t), elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t)!,
outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t), outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t),
textSelectionTheme: TextSelectionThemeData .lerp(a.textSelectionTheme, b.textSelectionTheme, t), textSelectionTheme: TextSelectionThemeData .lerp(a.textSelectionTheme, b.textSelectionTheme, t),
dataTableTheme: DataTableThemeData.lerp(a.dataTableTheme, b.dataTableTheme, t), dataTableTheme: DataTableThemeData.lerp(a.dataTableTheme, b.dataTableTheme, t),
...@@ -1590,7 +1588,7 @@ class ThemeData with Diagnosticable { ...@@ -1590,7 +1588,7 @@ class ThemeData with Diagnosticable {
// Warning: For the sanity of the reader, please make sure these properties // Warning: For the sanity of the reader, please make sure these properties
// are in the exact same order as in operator == and in the raw constructor // are in the exact same order as in operator == and in the raw constructor
// and in the order of fields in the class and in the lerp() method. // and in the order of fields in the class and in the lerp() method.
final List<Object> values = <Object>[ final List<Object?> values = <Object?>[
visualDensity, visualDensity,
primaryColor, primaryColor,
primaryColorBrightness, primaryColorBrightness,
...@@ -1779,7 +1777,7 @@ class MaterialBasedCupertinoThemeData extends CupertinoThemeData { ...@@ -1779,7 +1777,7 @@ class MaterialBasedCupertinoThemeData extends CupertinoThemeData {
/// ///
/// The [materialTheme] parameter must not be null. /// The [materialTheme] parameter must not be null.
MaterialBasedCupertinoThemeData({ MaterialBasedCupertinoThemeData({
@required ThemeData materialTheme, required ThemeData materialTheme,
}) : this._( }) : this._(
materialTheme, materialTheme,
(materialTheme.cupertinoOverrideTheme ?? const CupertinoThemeData()).noDefault(), (materialTheme.cupertinoOverrideTheme ?? const CupertinoThemeData()).noDefault(),
...@@ -1830,12 +1828,12 @@ class MaterialBasedCupertinoThemeData extends CupertinoThemeData { ...@@ -1830,12 +1828,12 @@ class MaterialBasedCupertinoThemeData extends CupertinoThemeData {
/// instead. /// instead.
@override @override
MaterialBasedCupertinoThemeData copyWith({ MaterialBasedCupertinoThemeData copyWith({
Brightness brightness, Brightness? brightness,
Color primaryColor, Color? primaryColor,
Color primaryContrastingColor, Color? primaryContrastingColor,
CupertinoTextThemeData textTheme, CupertinoTextThemeData? textTheme,
Color barBackgroundColor, Color? barBackgroundColor,
Color scaffoldBackgroundColor, Color? scaffoldBackgroundColor,
}) { }) {
return MaterialBasedCupertinoThemeData._( return MaterialBasedCupertinoThemeData._(
_materialTheme, _materialTheme,
...@@ -1909,7 +1907,7 @@ class _FifoCache<K, V> { ...@@ -1909,7 +1907,7 @@ class _FifoCache<K, V> {
V putIfAbsent(K key, V loader()) { V putIfAbsent(K key, V loader()) {
assert(key != null); assert(key != null);
assert(loader != null); assert(loader != null);
final V result = _cache[key]; final V? result = _cache[key];
if (result != null) if (result != null)
return result; return result;
if (_cache.length == _maximumSize) if (_cache.length == _maximumSize)
...@@ -2010,8 +2008,8 @@ class VisualDensity with Diagnosticable { ...@@ -2010,8 +2008,8 @@ class VisualDensity with Diagnosticable {
/// Copy the current [VisualDensity] with the given values replacing the /// Copy the current [VisualDensity] with the given values replacing the
/// current values. /// current values.
VisualDensity copyWith({ VisualDensity copyWith({
double horizontal, double? horizontal,
double vertical, double? vertical,
}) { }) {
return VisualDensity( return VisualDensity(
horizontal: horizontal ?? this.horizontal, horizontal: horizontal ?? this.horizontal,
...@@ -2070,8 +2068,8 @@ class VisualDensity with Diagnosticable { ...@@ -2070,8 +2068,8 @@ class VisualDensity with Diagnosticable {
/// Linearly interpolate between two densities. /// Linearly interpolate between two densities.
static VisualDensity lerp(VisualDensity a, VisualDensity b, double t) { static VisualDensity lerp(VisualDensity a, VisualDensity b, double t) {
return VisualDensity( return VisualDensity(
horizontal: lerpDouble(a.horizontal, b.horizontal, t), horizontal: lerpDouble(a.horizontal, b.horizontal, t)!,
vertical: lerpDouble(a.horizontal, b.horizontal, t), vertical: lerpDouble(a.horizontal, b.horizontal, 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 hashValues; import 'dart:ui' show hashValues;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -53,7 +51,7 @@ class TimeOfDay { ...@@ -53,7 +51,7 @@ class TimeOfDay {
/// ///
/// The [hour] argument must be between 0 and 23, inclusive. The [minute] /// The [hour] argument must be between 0 and 23, inclusive. The [minute]
/// argument must be between 0 and 59, inclusive. /// argument must be between 0 and 59, inclusive.
const TimeOfDay({ @required this.hour, @required this.minute }); const TimeOfDay({ required this.hour, required this.minute });
/// Creates a time of day based on the given time. /// Creates a time of day based on the given time.
/// ///
...@@ -79,7 +77,7 @@ class TimeOfDay { ...@@ -79,7 +77,7 @@ class TimeOfDay {
static const int minutesPerHour = 60; static const int minutesPerHour = 60;
/// Returns a new TimeOfDay with the hour and/or minute replaced. /// Returns a new TimeOfDay with the hour and/or minute replaced.
TimeOfDay replacing({ int hour, int minute }) { TimeOfDay replacing({ int? hour, int? minute }) {
assert(hour == null || (hour >= 0 && hour < hoursPerDay)); assert(hour == null || (hour >= 0 && hour < hoursPerDay));
assert(minute == null || (minute >= 0 && minute < minutesPerHour)); assert(minute == null || (minute >= 0 && minute < minutesPerHour));
return TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute); return TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute);
...@@ -106,10 +104,10 @@ class TimeOfDay { ...@@ -106,10 +104,10 @@ class TimeOfDay {
String format(BuildContext context) { String format(BuildContext context) {
assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
final MaterialLocalizations localizations = MaterialLocalizations.of(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context)!;
return localizations.formatTimeOfDay( return localizations.formatTimeOfDay(
this, this,
alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat, alwaysUse24HourFormat: MediaQuery.of(context)!.alwaysUse24HourFormat,
); );
} }
...@@ -204,7 +202,7 @@ enum HourFormat { ...@@ -204,7 +202,7 @@ enum HourFormat {
} }
/// The [HourFormat] used for the given [TimeOfDayFormat]. /// The [HourFormat] used for the given [TimeOfDayFormat].
HourFormat hourFormat({ @required TimeOfDayFormat of }) { HourFormat hourFormat({ required TimeOfDayFormat of }) {
switch (of) { switch (of) {
case TimeOfDayFormat.h_colon_mm_space_a: case TimeOfDayFormat.h_colon_mm_space_a:
case TimeOfDayFormat.a_space_h_colon_mm: case TimeOfDayFormat.a_space_h_colon_mm:
...@@ -216,6 +214,4 @@ HourFormat hourFormat({ @required TimeOfDayFormat of }) { ...@@ -216,6 +214,4 @@ HourFormat hourFormat({ @required TimeOfDayFormat of }) {
case TimeOfDayFormat.frenchCanadian: case TimeOfDayFormat.frenchCanadian:
return HourFormat.HH; return HourFormat.HH;
} }
return null;
} }
...@@ -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:async'; import 'dart:async';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -49,8 +47,8 @@ class Tooltip extends StatefulWidget { ...@@ -49,8 +47,8 @@ class Tooltip extends StatefulWidget {
/// All parameters that are defined in the constructor will /// All parameters that are defined in the constructor will
/// override the default values _and_ the values in [TooltipTheme.of]. /// override the default values _and_ the values in [TooltipTheme.of].
const Tooltip({ const Tooltip({
Key key, Key? key,
@required this.message, required this.message,
this.height, this.height,
this.padding, this.padding,
this.margin, this.margin,
...@@ -71,12 +69,12 @@ class Tooltip extends StatefulWidget { ...@@ -71,12 +69,12 @@ class Tooltip extends StatefulWidget {
/// The height of the tooltip's [child]. /// The height of the tooltip's [child].
/// ///
/// If the [child] is null, then this is the tooltip's intrinsic height. /// If the [child] is null, then this is the tooltip's intrinsic height.
final double height; final double? height;
/// The amount of space by which to inset the tooltip's [child]. /// The amount of space by which to inset the tooltip's [child].
/// ///
/// Defaults to 16.0 logical pixels in each direction. /// Defaults to 16.0 logical pixels in each direction.
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
/// The empty space that surrounds the tooltip. /// The empty space that surrounds the tooltip.
/// ///
...@@ -89,7 +87,7 @@ class Tooltip extends StatefulWidget { ...@@ -89,7 +87,7 @@ class Tooltip extends StatefulWidget {
/// If this property is null, then [TooltipThemeData.margin] is used. /// If this property is null, then [TooltipThemeData.margin] is used.
/// If [TooltipThemeData.margin] is also null, the default margin is /// If [TooltipThemeData.margin] is also null, the default margin is
/// 0.0 logical pixels on all sides. /// 0.0 logical pixels on all sides.
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
/// The vertical gap between the widget and the displayed tooltip. /// The vertical gap between the widget and the displayed tooltip.
/// ///
...@@ -98,14 +96,14 @@ class Tooltip extends StatefulWidget { ...@@ -98,14 +96,14 @@ class Tooltip extends StatefulWidget {
/// tooltips will position themselves under their corresponding widgets. /// tooltips will position themselves under their corresponding widgets.
/// Otherwise, tooltips will position themselves above their corresponding /// Otherwise, tooltips will position themselves above their corresponding
/// widgets with the given offset. /// widgets with the given offset.
final double verticalOffset; final double? verticalOffset;
/// Whether the tooltip defaults to being displayed below the widget. /// Whether the tooltip defaults to being displayed below the widget.
/// ///
/// Defaults to true. If there is insufficient space to display the tooltip in /// Defaults to true. If there is insufficient space to display the tooltip in
/// the preferred direction, the tooltip will be displayed in the opposite /// the preferred direction, the tooltip will be displayed in the opposite
/// direction. /// direction.
final bool preferBelow; final bool? preferBelow;
/// Whether the tooltip's [message] should be excluded from the semantics /// Whether the tooltip's [message] should be excluded from the semantics
/// tree. /// tree.
...@@ -113,12 +111,12 @@ class Tooltip extends StatefulWidget { ...@@ -113,12 +111,12 @@ class Tooltip extends StatefulWidget {
/// Defaults to false. A tooltip will add a [Semantics] label that is set to /// Defaults to false. A tooltip will add a [Semantics] label that is set to
/// [Tooltip.message]. Set this property to true if the app is going to /// [Tooltip.message]. Set this property to true if the app is going to
/// provide its own custom semantics label. /// provide its own custom semantics label.
final bool excludeFromSemantics; final bool? excludeFromSemantics;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
/// {@macro flutter.widgets.child} /// {@macro flutter.widgets.child}
final Widget child; final Widget? child;
/// Specifies the tooltip's shape and background color. /// Specifies the tooltip's shape and background color.
/// ///
...@@ -126,7 +124,7 @@ class Tooltip extends StatefulWidget { ...@@ -126,7 +124,7 @@ class Tooltip extends StatefulWidget {
/// 4.0. Tooltips will also default to an opacity of 90% and with the color /// 4.0. Tooltips will also default to an opacity of 90% and with the color
/// [Colors.grey[700]] if [ThemeData.brightness] is [Brightness.dark], and /// [Colors.grey[700]] if [ThemeData.brightness] is [Brightness.dark], and
/// [Colors.white] if it is [Brightness.light]. /// [Colors.white] if it is [Brightness.light].
final Decoration decoration; final Decoration? decoration;
/// The style to use for the message of the tooltip. /// The style to use for the message of the tooltip.
/// ///
...@@ -136,7 +134,7 @@ class Tooltip extends StatefulWidget { ...@@ -136,7 +134,7 @@ class Tooltip extends StatefulWidget {
/// [Colors.white]. Otherwise, if [ThemeData.brightness] is set to /// [Colors.white]. Otherwise, if [ThemeData.brightness] is set to
/// [Brightness.light], [TextTheme.bodyText2] of [ThemeData.textTheme] will be /// [Brightness.light], [TextTheme.bodyText2] of [ThemeData.textTheme] will be
/// used with [Colors.black]. /// used with [Colors.black].
final TextStyle textStyle; final TextStyle? textStyle;
/// The length of time that a pointer must hover over a tooltip's widget /// The length of time that a pointer must hover over a tooltip's widget
/// before the tooltip will be shown. /// before the tooltip will be shown.
...@@ -145,13 +143,13 @@ class Tooltip extends StatefulWidget { ...@@ -145,13 +143,13 @@ class Tooltip extends StatefulWidget {
/// disappear. /// disappear.
/// ///
/// Defaults to 0 milliseconds (tooltips are shown immediately upon hover). /// Defaults to 0 milliseconds (tooltips are shown immediately upon hover).
final Duration waitDuration; final Duration? waitDuration;
/// The length of time that the tooltip will be shown after a long press /// The length of time that the tooltip will be shown after a long press
/// is released. /// is released.
/// ///
/// Defaults to 1.5 seconds. /// Defaults to 1.5 seconds.
final Duration showDuration; final Duration? showDuration;
@override @override
_TooltipState createState() => _TooltipState(); _TooltipState createState() => _TooltipState();
...@@ -183,27 +181,27 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -183,27 +181,27 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
static const Duration _defaultWaitDuration = Duration(milliseconds: 0); static const Duration _defaultWaitDuration = Duration(milliseconds: 0);
static const bool _defaultExcludeFromSemantics = false; static const bool _defaultExcludeFromSemantics = false;
double height; late double height;
EdgeInsetsGeometry padding; late EdgeInsetsGeometry padding;
EdgeInsetsGeometry margin; late EdgeInsetsGeometry margin;
Decoration decoration; late Decoration decoration;
TextStyle textStyle; late TextStyle textStyle;
double verticalOffset; late double verticalOffset;
bool preferBelow; late bool preferBelow;
bool excludeFromSemantics; late bool excludeFromSemantics;
AnimationController _controller; late AnimationController _controller;
OverlayEntry _entry; OverlayEntry? _entry;
Timer _hideTimer; Timer? _hideTimer;
Timer _showTimer; Timer? _showTimer;
Duration showDuration; late Duration showDuration;
Duration waitDuration; late Duration waitDuration;
bool _mouseIsConnected; late bool _mouseIsConnected;
bool _longPressActivated = false; bool _longPressActivated = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_mouseIsConnected = RendererBinding.instance.mouseTracker.mouseIsConnected; _mouseIsConnected = RendererBinding.instance!.mouseTracker.mouseIsConnected;
_controller = AnimationController( _controller = AnimationController(
duration: _fadeInDuration, duration: _fadeInDuration,
reverseDuration: _fadeOutDuration, reverseDuration: _fadeOutDuration,
...@@ -211,10 +209,10 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -211,10 +209,10 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
) )
..addStatusListener(_handleStatusChanged); ..addStatusListener(_handleStatusChanged);
// Listen to see when a mouse is added. // Listen to see when a mouse is added.
RendererBinding.instance.mouseTracker.addListener(_handleMouseTrackerChange); RendererBinding.instance!.mouseTracker.addListener(_handleMouseTrackerChange);
// Listen to global pointer events so that we can hide a tooltip immediately // Listen to global pointer events so that we can hide a tooltip immediately
// if some other control is clicked on. // if some other control is clicked on.
GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent); GestureBinding.instance!.pointerRouter.addGlobalRoute(_handlePointerEvent);
} }
// Forces a rebuild if a mouse has been added or removed. // Forces a rebuild if a mouse has been added or removed.
...@@ -222,7 +220,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -222,7 +220,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
if (!mounted) { if (!mounted) {
return; return;
} }
final bool mouseIsConnected = RendererBinding.instance.mouseTracker.mouseIsConnected; final bool mouseIsConnected = RendererBinding.instance!.mouseTracker.mouseIsConnected;
if (mouseIsConnected != _mouseIsConnected) { if (mouseIsConnected != _mouseIsConnected) {
setState((){ setState((){
_mouseIsConnected = mouseIsConnected; _mouseIsConnected = mouseIsConnected;
...@@ -287,9 +285,9 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -287,9 +285,9 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
final OverlayState overlayState = Overlay.of( final OverlayState overlayState = Overlay.of(
context, context,
debugRequiredFor: widget, debugRequiredFor: widget,
); )!;
final RenderBox box = context.findRenderObject() as RenderBox; final RenderBox box = context.findRenderObject()! as RenderBox;
final Offset target = box.localToGlobal( final Offset target = box.localToGlobal(
box.size.center(Offset.zero), box.size.center(Offset.zero),
ancestor: overlayState.context.findRenderObject(), ancestor: overlayState.context.findRenderObject(),
...@@ -299,7 +297,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -299,7 +297,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
// updated values from happening to leak into the overlay when the overlay // updated values from happening to leak into the overlay when the overlay
// rebuilds. // rebuilds.
final Widget overlay = Directionality( final Widget overlay = Directionality(
textDirection: Directionality.of(context), textDirection: Directionality.of(context)!,
child: _TooltipOverlay( child: _TooltipOverlay(
message: widget.message, message: widget.message,
height: height, height: height,
...@@ -317,7 +315,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -317,7 +315,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
), ),
); );
_entry = OverlayEntry(builder: (BuildContext context) => overlay); _entry = OverlayEntry(builder: (BuildContext context) => overlay);
overlayState.insert(_entry); overlayState.insert(_entry!);
SemanticsService.tooltip(widget.message); SemanticsService.tooltip(widget.message);
} }
...@@ -352,8 +350,8 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -352,8 +350,8 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
@override @override
void dispose() { void dispose() {
GestureBinding.instance.pointerRouter.removeGlobalRoute(_handlePointerEvent); GestureBinding.instance!.pointerRouter.removeGlobalRoute(_handlePointerEvent);
RendererBinding.instance.mouseTracker.removeListener(_handleMouseTrackerChange); RendererBinding.instance!.mouseTracker.removeListener(_handleMouseTrackerChange);
if (_entry != null) if (_entry != null)
_removeEntry(); _removeEntry();
_controller.dispose(); _controller.dispose();
...@@ -370,12 +368,12 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -370,12 +368,12 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(Overlay.of(context, debugRequiredFor: widget) != null); assert(Overlay.of(context, debugRequiredFor: widget) != null);
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
final TooltipThemeData tooltipTheme = TooltipTheme.of(context); final TooltipThemeData tooltipTheme = TooltipTheme.of(context);
TextStyle defaultTextStyle; TextStyle defaultTextStyle;
BoxDecoration defaultDecoration; BoxDecoration defaultDecoration;
if (theme.brightness == Brightness.dark) { if (theme.brightness == Brightness.dark) {
defaultTextStyle = theme.textTheme.bodyText2.copyWith( defaultTextStyle = theme.textTheme.bodyText2!.copyWith(
color: Colors.black, color: Colors.black,
); );
defaultDecoration = BoxDecoration( defaultDecoration = BoxDecoration(
...@@ -383,11 +381,11 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -383,11 +381,11 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
borderRadius: const BorderRadius.all(Radius.circular(4)), borderRadius: const BorderRadius.all(Radius.circular(4)),
); );
} else { } else {
defaultTextStyle = theme.textTheme.bodyText2.copyWith( defaultTextStyle = theme.textTheme.bodyText2!.copyWith(
color: Colors.white, color: Colors.white,
); );
defaultDecoration = BoxDecoration( defaultDecoration = BoxDecoration(
color: Colors.grey[700].withOpacity(0.9), color: Colors.grey[700]!.withOpacity(0.9),
borderRadius: const BorderRadius.all(Radius.circular(4)), borderRadius: const BorderRadius.all(Radius.circular(4)),
); );
} }
...@@ -433,9 +431,9 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate { ...@@ -433,9 +431,9 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
/// ///
/// The arguments must not be null. /// The arguments must not be null.
_TooltipPositionDelegate({ _TooltipPositionDelegate({
@required this.target, required this.target,
@required this.verticalOffset, required this.verticalOffset,
@required this.preferBelow, required this.preferBelow,
}) : assert(target != null), }) : assert(target != null),
assert(verticalOffset != null), assert(verticalOffset != null),
assert(preferBelow != null); assert(preferBelow != null);
...@@ -478,25 +476,25 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate { ...@@ -478,25 +476,25 @@ class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
class _TooltipOverlay extends StatelessWidget { class _TooltipOverlay extends StatelessWidget {
const _TooltipOverlay({ const _TooltipOverlay({
Key key, Key? key,
this.message, required this.message,
this.height, required this.height,
this.padding, this.padding,
this.margin, this.margin,
this.decoration, this.decoration,
this.textStyle, this.textStyle,
this.animation, required this.animation,
this.target, required this.target,
this.verticalOffset, required this.verticalOffset,
this.preferBelow, required this.preferBelow,
}) : super(key: key); }) : super(key: key);
final String message; final String message;
final double height; final double height;
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
final Decoration decoration; final Decoration? decoration;
final TextStyle textStyle; final TextStyle? textStyle;
final Animation<double> animation; final Animation<double> animation;
final Offset target; final Offset target;
final double verticalOffset; final double verticalOffset;
...@@ -517,7 +515,7 @@ class _TooltipOverlay extends StatelessWidget { ...@@ -517,7 +515,7 @@ class _TooltipOverlay extends StatelessWidget {
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints(minHeight: height), constraints: BoxConstraints(minHeight: height),
child: DefaultTextStyle( child: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyText2, style: Theme.of(context)!.textTheme.bodyText2,
child: Container( child: Container(
decoration: decoration, decoration: decoration,
padding: padding, padding: padding,
......
...@@ -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';
...@@ -42,13 +40,13 @@ class TooltipThemeData with Diagnosticable { ...@@ -42,13 +40,13 @@ class TooltipThemeData with Diagnosticable {
}); });
/// The height of [Tooltip.child]. /// The height of [Tooltip.child].
final double height; final double? height;
/// If provided, the amount of space by which to inset [Tooltip.child]. /// If provided, the amount of space by which to inset [Tooltip.child].
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry? padding;
/// If provided, the amount of empty space to surround the [Tooltip]. /// If provided, the amount of empty space to surround the [Tooltip].
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
/// The vertical gap between the widget and the displayed tooltip. /// The vertical gap between the widget and the displayed tooltip.
/// ///
...@@ -57,13 +55,13 @@ class TooltipThemeData with Diagnosticable { ...@@ -57,13 +55,13 @@ class TooltipThemeData with Diagnosticable {
/// tooltips will position themselves under their corresponding widgets. /// tooltips will position themselves under their corresponding widgets.
/// Otherwise, tooltips will position themselves above their corresponding /// Otherwise, tooltips will position themselves above their corresponding
/// widgets with the given offset. /// widgets with the given offset.
final double verticalOffset; final double? verticalOffset;
/// Whether the tooltip is displayed below its widget by default. /// Whether the tooltip is displayed below its widget by default.
/// ///
/// If there is insufficient space to display the tooltip in the preferred /// If there is insufficient space to display the tooltip in the preferred
/// direction, the tooltip will be displayed in the opposite direction. /// direction, the tooltip will be displayed in the opposite direction.
final bool preferBelow; final bool? preferBelow;
/// Whether the [Tooltip.message] should be excluded from the semantics /// Whether the [Tooltip.message] should be excluded from the semantics
/// tree. /// tree.
...@@ -71,34 +69,34 @@ class TooltipThemeData with Diagnosticable { ...@@ -71,34 +69,34 @@ class TooltipThemeData with Diagnosticable {
/// By default, [Tooltip]s will add a [Semantics] label that is set to /// By default, [Tooltip]s will add a [Semantics] label that is set to
/// [Tooltip.message]. Set this property to true if the app is going to /// [Tooltip.message]. Set this property to true if the app is going to
/// provide its own custom semantics label. /// provide its own custom semantics label.
final bool excludeFromSemantics; final bool? excludeFromSemantics;
/// The [Tooltip]'s shape and background color. /// The [Tooltip]'s shape and background color.
final Decoration decoration; final Decoration? decoration;
/// The style to use for the message of [Tooltip]s. /// The style to use for the message of [Tooltip]s.
final TextStyle textStyle; final TextStyle? textStyle;
/// The length of time that a pointer must hover over a tooltip's widget /// The length of time that a pointer must hover over a tooltip's widget
/// before the tooltip will be shown. /// before the tooltip will be shown.
final Duration waitDuration; final Duration? waitDuration;
/// The length of time that the tooltip will be shown once it has appeared. /// The length of time that the tooltip will be shown once it has appeared.
final Duration showDuration; final Duration? showDuration;
/// 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.
TooltipThemeData copyWith({ TooltipThemeData copyWith({
double height, double? height,
EdgeInsetsGeometry padding, EdgeInsetsGeometry? padding,
EdgeInsetsGeometry margin, EdgeInsetsGeometry? margin,
double verticalOffset, double? verticalOffset,
bool preferBelow, bool? preferBelow,
bool excludeFromSemantics, bool? excludeFromSemantics,
Decoration decoration, Decoration? decoration,
TextStyle textStyle, TextStyle? textStyle,
Duration waitDuration, Duration? waitDuration,
Duration showDuration, Duration? showDuration,
}) { }) {
return TooltipThemeData( return TooltipThemeData(
height: height ?? this.height, height: height ?? this.height,
...@@ -119,7 +117,7 @@ class TooltipThemeData with Diagnosticable { ...@@ -119,7 +117,7 @@ class TooltipThemeData 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 TooltipThemeData lerp(TooltipThemeData a, TooltipThemeData b, double t) { static TooltipThemeData? lerp(TooltipThemeData? a, TooltipThemeData? b, double t) {
if (a == null && b == null) if (a == null && b == null)
return null; return null;
assert(t != null); assert(t != null);
...@@ -128,8 +126,8 @@ class TooltipThemeData with Diagnosticable { ...@@ -128,8 +126,8 @@ class TooltipThemeData with Diagnosticable {
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t), padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
margin: EdgeInsetsGeometry.lerp(a?.margin, b?.margin, t), margin: EdgeInsetsGeometry.lerp(a?.margin, b?.margin, t),
verticalOffset: lerpDouble(a?.verticalOffset, b?.verticalOffset, t), verticalOffset: lerpDouble(a?.verticalOffset, b?.verticalOffset, t),
preferBelow: t < 0.5 ? a.preferBelow: b.preferBelow, preferBelow: t < 0.5 ? a?.preferBelow: b?.preferBelow,
excludeFromSemantics: t < 0.5 ? a.excludeFromSemantics : b.excludeFromSemantics, excludeFromSemantics: t < 0.5 ? a?.excludeFromSemantics : b?.excludeFromSemantics,
decoration: Decoration.lerp(a?.decoration, b?.decoration, t), decoration: Decoration.lerp(a?.decoration, b?.decoration, t),
textStyle: TextStyle.lerp(a?.textStyle, b?.textStyle, t), textStyle: TextStyle.lerp(a?.textStyle, b?.textStyle, t),
); );
...@@ -222,9 +220,9 @@ class TooltipTheme extends InheritedTheme { ...@@ -222,9 +220,9 @@ class TooltipTheme extends InheritedTheme {
/// ///
/// The data argument must not be null. /// The data argument must not be null.
const TooltipTheme({ const TooltipTheme({
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 for descendant [Tooltip] widgets. /// The properties for descendant [Tooltip] widgets.
...@@ -240,13 +238,13 @@ class TooltipTheme extends InheritedTheme { ...@@ -240,13 +238,13 @@ class TooltipTheme extends InheritedTheme {
/// TooltipThemeData theme = TooltipTheme.of(context); /// TooltipThemeData theme = TooltipTheme.of(context);
/// ``` /// ```
static TooltipThemeData of(BuildContext context) { static TooltipThemeData of(BuildContext context) {
final TooltipTheme tooltipTheme = context.dependOnInheritedWidgetOfExactType<TooltipTheme>(); final TooltipTheme? tooltipTheme = context.dependOnInheritedWidgetOfExactType<TooltipTheme>();
return tooltipTheme?.data ?? Theme.of(context).tooltipTheme; return tooltipTheme?.data ?? Theme.of(context)!.tooltipTheme;
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final TooltipTheme ancestorTheme = context.findAncestorWidgetOfExactType<TooltipTheme>(); final TooltipTheme? ancestorTheme = context.findAncestorWidgetOfExactType<TooltipTheme>();
return identical(this, ancestorTheme) ? child : TooltipTheme(data: data, child: child); return identical(this, ancestorTheme) ? child : TooltipTheme(data: data, child: child);
} }
......
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