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 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart';
......@@ -46,44 +44,44 @@ class CardTheme with Diagnosticable {
/// Default value for [Card.clipBehavior].
///
/// If null, [Card] uses [Clip.none].
final Clip clipBehavior;
final Clip? clipBehavior;
/// Default value for [Card.color].
///
/// If null, [Card] uses [ThemeData.cardColor].
final Color color;
final Color? color;
/// Default value for [Card.shadowColor].
///
/// If null, [Card] defaults to fully opaque black.
final Color shadowColor;
final Color? shadowColor;
/// Default value for [Card.elevation].
///
/// If null, [Card] uses a default of 1.0.
final double elevation;
final double? elevation;
/// Default value for [Card.margin].
///
/// If null, [Card] uses a default margin of 4.0 logical pixels on all sides:
/// `EdgeInsets.all(4.0)`.
final EdgeInsetsGeometry margin;
final EdgeInsetsGeometry? margin;
/// Default value for [Card.shape].
///
/// If null, [Card] then uses a [RoundedRectangleBorder] with a circular
/// corner radius of 4.0.
final ShapeBorder shape;
final ShapeBorder? shape;
/// Creates a copy of this object with the given fields replaced with the
/// new values.
CardTheme copyWith({
Clip clipBehavior,
Color color,
Color shadowColor,
double elevation,
EdgeInsetsGeometry margin,
ShapeBorder shape,
Clip? clipBehavior,
Color? color,
Color? shadowColor,
double? elevation,
EdgeInsetsGeometry? margin,
ShapeBorder? shape,
}) {
return CardTheme(
clipBehavior: clipBehavior ?? this.clipBehavior,
......@@ -97,7 +95,7 @@ class CardTheme with Diagnosticable {
/// The [ThemeData.cardTheme] property of the ambient [Theme].
static CardTheme of(BuildContext context) {
return Theme.of(context).cardTheme;
return Theme.of(context)!.cardTheme;
}
/// Linearly interpolate between two Card themes.
......@@ -105,7 +103,7 @@ class CardTheme with Diagnosticable {
/// The argument `t` must not be null.
///
/// {@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);
return CardTheme(
clipBehavior: t < 0.5 ? a?.clipBehavior : b?.clipBehavior,
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math;
import 'package:flutter/widgets.dart';
......@@ -45,7 +43,7 @@ class ElevationOverlay {
/// * <https://material.io/design/color/dark-theme.html>, which specifies how
/// the overlay should be applied.
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 &&
theme.applyElevationOverlayColor &&
theme.brightness == Brightness.dark &&
......@@ -63,7 +61,7 @@ class ElevationOverlay {
/// * https://material.io/design/color/dark-theme.html#properties which
/// specifies the exact overlay values for a given 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
// This formula matches the values in the spec:
// https://material.io/design/color/dark-theme.html#properties
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter/services.dart';
......@@ -94,7 +92,7 @@ class Feedback {
/// * [wrapForTap] to trigger platform-specific feedback before executing a
/// [GestureTapCallback].
static Future<void> forTap(BuildContext context) async {
context.findRenderObject().sendSemanticsEvent(const TapSemanticEvent());
context.findRenderObject()!.sendSemanticsEvent(const TapSemanticEvent());
switch (_platform(context)) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......@@ -104,10 +102,7 @@ class Feedback {
case TargetPlatform.macOS:
case TargetPlatform.windows:
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
......@@ -120,7 +115,7 @@ class Feedback {
///
/// * [forTap] to just trigger the platform-specific feedback without wrapping
/// a [GestureTapCallback].
static GestureTapCallback wrapForTap(GestureTapCallback callback, BuildContext context) {
static GestureTapCallback? wrapForTap(GestureTapCallback? callback, BuildContext context) {
if (callback == null)
return null;
return () {
......@@ -139,7 +134,7 @@ class Feedback {
/// * [wrapForLongPress] to trigger platform-specific feedback before
/// executing a [GestureLongPressCallback].
static Future<void> forLongPress(BuildContext context) {
context.findRenderObject().sendSemanticsEvent(const LongPressSemanticsEvent());
context.findRenderObject()!.sendSemanticsEvent(const LongPressSemanticsEvent());
switch (_platform(context)) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......@@ -149,10 +144,7 @@ class Feedback {
case TargetPlatform.macOS:
case TargetPlatform.windows:
return Future<void>.value();
break;
}
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.value();
}
/// Wraps a [GestureLongPressCallback] to provide platform specific feedback
......@@ -166,7 +158,7 @@ class Feedback {
///
/// * [forLongPress] to just trigger the platform-specific feedback without
/// wrapping a [GestureLongPressCallback].
static GestureLongPressCallback wrapForLongPress(GestureLongPressCallback callback, BuildContext context) {
static GestureLongPressCallback? wrapForLongPress(GestureLongPressCallback? callback, BuildContext context) {
if (callback == null)
return null;
return () {
......@@ -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 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
......@@ -135,7 +133,7 @@ abstract class MaterialLocalizations {
/// there are, e.g. 'Tab 1 of 2' in United States English.
///
/// `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.
String selectedRowCountTitle(int selectedRowCount);
......@@ -319,7 +317,7 @@ abstract class MaterialLocalizations {
///
/// See also:
/// * [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
/// abbreviations of full names.
......@@ -505,7 +503,7 @@ abstract class MaterialLocalizations {
/// ```dart
/// tooltip: MaterialLocalizations.of(context).backButtonTooltip,
/// ```
static MaterialLocalizations of(BuildContext context) {
static MaterialLocalizations? of(BuildContext context) {
return Localizations.of<MaterialLocalizations>(context, MaterialLocalizations);
}
}
......@@ -696,24 +694,28 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
}
@override
DateTime parseCompactDate(String inputString) {
DateTime? parseCompactDate(String? inputString) {
if (inputString == null) {
return null;
}
// Assumes US mm/dd/yyyy format
final List<String> inputParts = inputString.split('/');
if (inputParts.length != 3) {
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) {
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) {
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)) {
return null;
}
......@@ -808,7 +810,6 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
case DayPeriod.pm:
return postMeridiemAbbreviation;
}
return null;
}
@override
......@@ -932,7 +933,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
String get rowsPerPageTitle => 'Rows per page:';
@override
String tabLabel({ int tabIndex, int tabCount }) {
String tabLabel({ required int tabIndex, required int tabCount }) {
assert(tabIndex >= 1);
assert(tabCount >= 1);
return 'Tab $tabIndex of $tabCount';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart';
......@@ -67,30 +65,30 @@ class SnackBarThemeData with Diagnosticable {
/// Default value for [SnackBar.backgroundColor].
///
/// If null, [SnackBar] defaults to dark grey: `Color(0xFF323232)`.
final Color backgroundColor;
final Color? backgroundColor;
/// Default value for [SnackBarAction.textColor].
///
/// If null, [SnackBarAction] defaults to [ColorScheme.secondary] of
/// [ThemeData.colorScheme] .
final Color actionTextColor;
final Color? actionTextColor;
/// Default value for [SnackBarAction.disabledTextColor].
///
/// If null, [SnackBarAction] defaults to [ColorScheme.onSurface] with its
/// opacity set to 0.30 if the [Theme]'s brightness is [Brightness.dark], 0.38
/// otherwise.
final Color disabledActionTextColor;
final Color? disabledActionTextColor;
/// Used to configure the [DefaultTextStyle] for the [SnackBar.content] widget.
///
/// If null, [SnackBar] defines its default.
final TextStyle contentTextStyle;
final TextStyle? contentTextStyle;
/// Default value for [SnackBar.elevation].
///
/// If null, [SnackBar] uses a default of 6.0.
final double elevation;
final double? elevation;
/// Default value for [SnackBar.shape].
///
......@@ -99,23 +97,23 @@ class SnackBarThemeData with Diagnosticable {
/// specified, so the [SnackBar] is rectangular. For
/// [SnackBarBehavior.floating], it uses a [RoundedRectangleBorder] with a
/// circular corner radius of 4.0.
final ShapeBorder shape;
final ShapeBorder? shape;
/// Default value for [SnackBar.behavior].
///
/// 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
/// new values.
SnackBarThemeData copyWith({
Color backgroundColor,
Color actionTextColor,
Color disabledActionTextColor,
TextStyle contentTextStyle,
double elevation,
ShapeBorder shape,
SnackBarBehavior behavior,
Color? backgroundColor,
Color? actionTextColor,
Color? disabledActionTextColor,
TextStyle? contentTextStyle,
double? elevation,
ShapeBorder? shape,
SnackBarBehavior? behavior,
}) {
return SnackBarThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
......@@ -133,7 +131,7 @@ class SnackBarThemeData with Diagnosticable {
/// The argument `t` must not be null.
///
/// {@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);
return SnackBarThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
......@@ -142,7 +140,7 @@ class SnackBarThemeData with Diagnosticable {
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t),
elevation: lerpDouble(a?.elevation, b?.elevation, 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 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
......@@ -40,10 +38,10 @@ class Theme extends StatelessWidget {
///
/// The [data] and [child] arguments must not be null.
const Theme({
Key key,
@required this.data,
Key? key,
required this.data,
this.isMaterialAppTheme = false,
@required this.child,
required this.child,
}) : assert(child != null),
assert(data != null),
super(key: key);
......@@ -126,17 +124,17 @@ class Theme extends StatelessWidget {
/// );
/// }
/// ```
static ThemeData of(BuildContext context, { bool shadowThemeOnly = false }) {
final _InheritedTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>();
static ThemeData? of(BuildContext context, { bool shadowThemeOnly = false }) {
final _InheritedTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>();
if (shadowThemeOnly) {
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme)
return null;
return inheritedTheme.theme.data;
}
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final MaterialLocalizations? localizations = MaterialLocalizations.of(context);
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));
}
......@@ -168,9 +166,9 @@ class Theme extends StatelessWidget {
class _InheritedTheme extends InheritedTheme {
const _InheritedTheme({
Key key,
@required this.theme,
@required Widget child,
Key? key,
required this.theme,
required Widget child,
}) : assert(theme != null),
super(key: key, child: child);
......@@ -178,7 +176,7 @@ class _InheritedTheme extends InheritedTheme {
@override
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);
}
......@@ -198,10 +196,10 @@ class ThemeDataTween extends Tween<ThemeData> {
/// 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
/// filled in later.
ThemeDataTween({ ThemeData begin, ThemeData end }) : super(begin: begin, end: end);
ThemeDataTween({ ThemeData? begin, ThemeData? end }) : super(begin: begin, end: end);
@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,
......@@ -224,13 +222,13 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget {
/// By default, the theme transition uses a linear curve. The [data] and
/// [child] arguments must not be null.
const AnimatedTheme({
Key key,
@required this.data,
Key? key,
required this.data,
this.isMaterialAppTheme = false,
Curve curve = Curves.linear,
Duration duration = kThemeAnimationDuration,
VoidCallback onEnd,
@required this.child,
VoidCallback? onEnd,
required this.child,
}) : assert(child != null),
assert(data != null),
super(key: key, curve: curve, duration: duration, onEnd: onEnd);
......@@ -251,7 +249,7 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget {
}
class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
ThemeDataTween _data;
ThemeDataTween? _data;
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
......@@ -265,7 +263,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
return Theme(
isMaterialAppTheme: widget.isMaterialAppTheme,
child: widget.child,
data: _data.evaluate(animation),
data: _data!.evaluate(animation!),
);
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show hashValues;
import 'package:flutter/widgets.dart';
......@@ -53,7 +51,7 @@ class TimeOfDay {
///
/// The [hour] argument must be between 0 and 23, inclusive. The [minute]
/// 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.
///
......@@ -79,7 +77,7 @@ class TimeOfDay {
static const int minutesPerHour = 60;
/// 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(minute == null || (minute >= 0 && minute < minutesPerHour));
return TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute);
......@@ -106,10 +104,10 @@ class TimeOfDay {
String format(BuildContext context) {
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final MaterialLocalizations localizations = MaterialLocalizations.of(context)!;
return localizations.formatTimeOfDay(
this,
alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat,
alwaysUse24HourFormat: MediaQuery.of(context)!.alwaysUse24HourFormat,
);
}
......@@ -204,7 +202,7 @@ enum HourFormat {
}
/// The [HourFormat] used for the given [TimeOfDayFormat].
HourFormat hourFormat({ @required TimeOfDayFormat of }) {
HourFormat hourFormat({ required TimeOfDayFormat of }) {
switch (of) {
case TimeOfDayFormat.h_colon_mm_space_a:
case TimeOfDayFormat.a_space_h_colon_mm:
......@@ -216,6 +214,4 @@ HourFormat hourFormat({ @required TimeOfDayFormat of }) {
case TimeOfDayFormat.frenchCanadian:
return HourFormat.HH;
}
return null;
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart';
......@@ -42,13 +40,13 @@ class TooltipThemeData with Diagnosticable {
});
/// The height of [Tooltip.child].
final double height;
final double? height;
/// 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].
final EdgeInsetsGeometry margin;
final EdgeInsetsGeometry? margin;
/// The vertical gap between the widget and the displayed tooltip.
///
......@@ -57,13 +55,13 @@ class TooltipThemeData with Diagnosticable {
/// tooltips will position themselves under their corresponding widgets.
/// Otherwise, tooltips will position themselves above their corresponding
/// widgets with the given offset.
final double verticalOffset;
final double? verticalOffset;
/// Whether the tooltip is displayed below its widget by default.
///
/// If there is insufficient space to display the tooltip in the preferred
/// 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
/// tree.
......@@ -71,34 +69,34 @@ class TooltipThemeData with Diagnosticable {
/// 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
/// provide its own custom semantics label.
final bool excludeFromSemantics;
final bool? excludeFromSemantics;
/// The [Tooltip]'s shape and background color.
final Decoration decoration;
final Decoration? decoration;
/// 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
/// 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.
final Duration showDuration;
final Duration? showDuration;
/// Creates a copy of this object but with the given fields replaced with the
/// new values.
TooltipThemeData copyWith({
double height,
EdgeInsetsGeometry padding,
EdgeInsetsGeometry margin,
double verticalOffset,
bool preferBelow,
bool excludeFromSemantics,
Decoration decoration,
TextStyle textStyle,
Duration waitDuration,
Duration showDuration,
double? height,
EdgeInsetsGeometry? padding,
EdgeInsetsGeometry? margin,
double? verticalOffset,
bool? preferBelow,
bool? excludeFromSemantics,
Decoration? decoration,
TextStyle? textStyle,
Duration? waitDuration,
Duration? showDuration,
}) {
return TooltipThemeData(
height: height ?? this.height,
......@@ -119,7 +117,7 @@ class TooltipThemeData with Diagnosticable {
/// If both arguments are null, then null is returned.
///
/// {@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)
return null;
assert(t != null);
......@@ -128,8 +126,8 @@ class TooltipThemeData with Diagnosticable {
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
margin: EdgeInsetsGeometry.lerp(a?.margin, b?.margin, t),
verticalOffset: lerpDouble(a?.verticalOffset, b?.verticalOffset, t),
preferBelow: t < 0.5 ? a.preferBelow: b.preferBelow,
excludeFromSemantics: t < 0.5 ? a.excludeFromSemantics : b.excludeFromSemantics,
preferBelow: t < 0.5 ? a?.preferBelow: b?.preferBelow,
excludeFromSemantics: t < 0.5 ? a?.excludeFromSemantics : b?.excludeFromSemantics,
decoration: Decoration.lerp(a?.decoration, b?.decoration, t),
textStyle: TextStyle.lerp(a?.textStyle, b?.textStyle, t),
);
......@@ -222,9 +220,9 @@ class TooltipTheme extends InheritedTheme {
///
/// The data argument must not be null.
const TooltipTheme({
Key key,
@required this.data,
Widget child,
Key? key,
required this.data,
required Widget child,
}) : assert(data != null), super(key: key, child: child);
/// The properties for descendant [Tooltip] widgets.
......@@ -240,13 +238,13 @@ class TooltipTheme extends InheritedTheme {
/// TooltipThemeData theme = TooltipTheme.of(context);
/// ```
static TooltipThemeData of(BuildContext context) {
final TooltipTheme tooltipTheme = context.dependOnInheritedWidgetOfExactType<TooltipTheme>();
return tooltipTheme?.data ?? Theme.of(context).tooltipTheme;
final TooltipTheme? tooltipTheme = context.dependOnInheritedWidgetOfExactType<TooltipTheme>();
return tooltipTheme?.data ?? Theme.of(context)!.tooltipTheme;
}
@override
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);
}
......
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