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

migrate material to nullsafety (#67166)

* migrate material to nullsafety

* address review comments

* address review comments

* fix build
parent aaa99f6d
...@@ -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
/// Flutter widgets implementing Material Design. /// Flutter widgets implementing Material Design.
/// ///
/// To use, import `package:flutter/material.dart`. /// To use, import `package:flutter/material.dart`.
......
...@@ -1376,7 +1376,7 @@ class _BackChevron extends StatelessWidget { ...@@ -1376,7 +1376,7 @@ class _BackChevron extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextDirection textDirection = Directionality.of(context)!; final TextDirection textDirection = Directionality.of(context)!;
final TextStyle textStyle = DefaultTextStyle.of(context).style!; final TextStyle textStyle = DefaultTextStyle.of(context).style;
// Replicate the Icon logic here to get a tightly sized icon and add // Replicate the Icon logic here to get a tightly sized icon and add
// custom non-square padding. // custom non-square padding.
...@@ -1982,7 +1982,7 @@ class _NavigationBarComponentsTransition { ...@@ -1982,7 +1982,7 @@ class _NavigationBarComponentsTransition {
opacity: fadeOutBy(0.4), opacity: fadeOutBy(0.4),
// Keep the font when transitioning into a non-back-label leading. // Keep the font when transitioning into a non-back-label leading.
child: DefaultTextStyle( child: DefaultTextStyle(
style: bottomLargeTitleTextStyle, style: bottomLargeTitleTextStyle!,
child: bottomLargeTitle.child, child: bottomLargeTitle.child,
), ),
), ),
...@@ -2219,7 +2219,7 @@ class _NavigationBarComponentsTransition { ...@@ -2219,7 +2219,7 @@ class _NavigationBarComponentsTransition {
child: FadeTransition( child: FadeTransition(
opacity: fadeInFrom(0.3), opacity: fadeInFrom(0.3),
child: DefaultTextStyle( child: DefaultTextStyle(
style: topLargeTitleTextStyle, style: topLargeTitleTextStyle!,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
child: topLargeTitle.child, child: topLargeTitle.child,
......
...@@ -370,7 +370,7 @@ class _SegmentedControlState<T extends Object> extends State<CupertinoSegmentedC ...@@ -370,7 +370,7 @@ class _SegmentedControlState<T extends Object> extends State<CupertinoSegmentedC
selectedIndex = (widget.groupValue == currentKey) ? index : selectedIndex; selectedIndex = (widget.groupValue == currentKey) ? index : selectedIndex;
pressedIndex = (_pressedKey == currentKey) ? index : pressedIndex; pressedIndex = (_pressedKey == currentKey) ? index : pressedIndex;
final TextStyle textStyle = DefaultTextStyle.of(context).style!.copyWith( final TextStyle textStyle = DefaultTextStyle.of(context).style.copyWith(
color: getTextColor(index, currentKey), color: getTextColor(index, currentKey),
); );
final IconThemeData iconTheme = IconThemeData( final IconThemeData iconTheme = IconThemeData(
......
...@@ -416,7 +416,7 @@ class _SegmentedControlState<T> extends State<CupertinoSlidingSegmentedControl<T ...@@ -416,7 +416,7 @@ class _SegmentedControlState<T> extends State<CupertinoSlidingSegmentedControl<T
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
final List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
for (final T currentKey in keys) { for (final T currentKey in keys) {
final TextStyle textStyle = DefaultTextStyle.of(context).style!.copyWith( final TextStyle textStyle = DefaultTextStyle.of(context).style.copyWith(
fontWeight: _highlightTween.evaluate(_highlightControllers[currentKey]!), fontWeight: _highlightTween.evaluate(_highlightControllers[currentKey]!),
); );
......
...@@ -703,10 +703,10 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio ...@@ -703,10 +703,10 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
super.dispose(); super.dispose();
} }
EditableTextState? get _editableText => editableTextKey.currentState; EditableTextState get _editableText => editableTextKey.currentState!;
void _requestKeyboard() { void _requestKeyboard() {
_editableText?.requestKeyboard(); _editableText.requestKeyboard();
} }
bool _shouldShowSelectionHandles(SelectionChangedCause? cause) { bool _shouldShowSelectionHandles(SelectionChangedCause? cause) {
...@@ -730,7 +730,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio ...@@ -730,7 +730,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
void _handleSelectionChanged(TextSelection selection, SelectionChangedCause? cause) { void _handleSelectionChanged(TextSelection selection, SelectionChangedCause? cause) {
if (cause == SelectionChangedCause.longPress) { if (cause == SelectionChangedCause.longPress) {
_editableText?.bringIntoView(selection.base); _editableText.bringIntoView(selection.base);
} }
final bool willShowSelectionHandles = _shouldShowSelectionHandles(cause); final bool willShowSelectionHandles = _shouldShowSelectionHandles(cause);
if (willShowSelectionHandles != _showSelectionHandles) { if (willShowSelectionHandles != _showSelectionHandles) {
......
...@@ -961,7 +961,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> { ...@@ -961,7 +961,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
); );
} }
return DefaultTextStyle( return DefaultTextStyle(
style: theme.textTheme.caption, style: theme.textTheme.caption!,
child: page, child: page,
); );
} }
......
...@@ -588,7 +588,7 @@ class _AppBarState extends State<AppBar> { ...@@ -588,7 +588,7 @@ class _AppBarState extends State<AppBar> {
} }
title = DefaultTextStyle( title = DefaultTextStyle(
style: centerStyle, style: centerStyle!,
softWrap: false, softWrap: false,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
child: title, child: title,
...@@ -650,7 +650,7 @@ class _AppBarState extends State<AppBar> { ...@@ -650,7 +650,7 @@ class _AppBarState extends State<AppBar> {
child: IconTheme.merge( child: IconTheme.merge(
data: overallIconTheme, data: overallIconTheme,
child: DefaultTextStyle( child: DefaultTextStyle(
style: sideStyle, style: sideStyle!,
child: toolbar, child: toolbar,
), ),
), ),
......
...@@ -145,7 +145,7 @@ class MaterialBanner extends StatelessWidget { ...@@ -145,7 +145,7 @@ class MaterialBanner extends StatelessWidget {
), ),
Expanded( Expanded(
child: DefaultTextStyle( child: DefaultTextStyle(
style: textStyle, style: textStyle!,
child: content, child: content,
), ),
), ),
......
...@@ -393,11 +393,11 @@ class _RawMaterialButtonState extends State<RawMaterialButton> { ...@@ -393,11 +393,11 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Color? effectiveTextColor = MaterialStateProperty.resolveAs<Color>(widget.textStyle?.color, _states); final Color? effectiveTextColor = MaterialStateProperty.resolveAs<Color?>(widget.textStyle?.color, _states);
final ShapeBorder? effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder>(widget.shape, _states); final ShapeBorder? effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder?>(widget.shape, _states);
final Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment; final Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment;
final BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints); final BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints);
final MouseCursor? effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>( final MouseCursor? effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor?>(
widget.mouseCursor ?? MaterialStateMouseCursor.clickable, widget.mouseCursor ?? MaterialStateMouseCursor.clickable,
_states, _states,
); );
......
...@@ -261,21 +261,21 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat ...@@ -261,21 +261,21 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
); );
} }
final double? resolvedElevation = resolve<double>((ButtonStyle? style) => style?.elevation); final double? resolvedElevation = resolve<double?>((ButtonStyle? style) => style?.elevation);
final TextStyle? resolvedTextStyle = resolve<TextStyle>((ButtonStyle? style) => style?.textStyle); final TextStyle? resolvedTextStyle = resolve<TextStyle?>((ButtonStyle? style) => style?.textStyle);
Color? resolvedBackgroundColor = resolve<Color>((ButtonStyle? style) => style?.backgroundColor); Color? resolvedBackgroundColor = resolve<Color?>((ButtonStyle? style) => style?.backgroundColor);
final Color? resolvedForegroundColor = resolve<Color>((ButtonStyle? style) => style?.foregroundColor); final Color? resolvedForegroundColor = resolve<Color?>((ButtonStyle? style) => style?.foregroundColor);
final Color? resolvedShadowColor = resolve<Color>((ButtonStyle? style) => style?.shadowColor); final Color? resolvedShadowColor = resolve<Color?>((ButtonStyle? style) => style?.shadowColor);
final EdgeInsetsGeometry? resolvedPadding = resolve<EdgeInsetsGeometry>((ButtonStyle? style) => style?.padding); final EdgeInsetsGeometry? resolvedPadding = resolve<EdgeInsetsGeometry?>((ButtonStyle? style) => style?.padding);
final Size? resolvedMinimumSize = resolve<Size>((ButtonStyle? style) => style?.minimumSize); final Size? resolvedMinimumSize = resolve<Size?>((ButtonStyle? style) => style?.minimumSize);
final BorderSide? resolvedSide = resolve<BorderSide>((ButtonStyle? style) => style?.side); final BorderSide? resolvedSide = resolve<BorderSide?>((ButtonStyle? style) => style?.side);
final OutlinedBorder? resolvedShape = resolve<OutlinedBorder>((ButtonStyle? style) => style?.shape); final OutlinedBorder? resolvedShape = resolve<OutlinedBorder?>((ButtonStyle? style) => style?.shape);
final MaterialStateMouseCursor resolvedMouseCursor = _MouseCursor( final MaterialStateMouseCursor resolvedMouseCursor = _MouseCursor(
(Set<MaterialState> states) => effectiveValue((ButtonStyle? style) => style?.mouseCursor?.resolve(states)), (Set<MaterialState> states) => effectiveValue((ButtonStyle? style) => style?.mouseCursor?.resolve(states)),
); );
final MaterialStateProperty<Color> overlayColor = MaterialStateProperty.resolveWith<Color>( final MaterialStateProperty<Color?> overlayColor = MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) => effectiveValue((ButtonStyle? style) => style?.overlayColor?.resolve(states)), (Set<MaterialState> states) => effectiveValue((ButtonStyle? style) => style?.overlayColor?.resolve(states)),
); );
...@@ -401,10 +401,10 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat ...@@ -401,10 +401,10 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
class _MouseCursor extends MaterialStateMouseCursor { class _MouseCursor extends MaterialStateMouseCursor {
const _MouseCursor(this.resolveCallback); const _MouseCursor(this.resolveCallback);
final MaterialPropertyResolver<MouseCursor> resolveCallback; final MaterialPropertyResolver<MouseCursor?> resolveCallback;
@override @override
MouseCursor? resolve(Set<MaterialState> states) => resolveCallback(states); MouseCursor resolve(Set<MaterialState> states) => resolveCallback(states)!;
@override @override
String get debugDescription => 'ButtonStyleButton_MouseCursor'; String get debugDescription => 'ButtonStyleButton_MouseCursor';
......
...@@ -539,7 +539,7 @@ class ButtonThemeData with Diagnosticable { ...@@ -539,7 +539,7 @@ class ButtonThemeData with Diagnosticable {
/// If [MaterialButton.textColor] is a [MaterialStateProperty<Color>], it will be /// If [MaterialButton.textColor] is a [MaterialStateProperty<Color>], it will be
/// used as the `disabledTextColor`. It will be resolved in the [MaterialState.disabled] state. /// used as the `disabledTextColor`. It will be resolved in the [MaterialState.disabled] state.
Color getDisabledTextColor(MaterialButton button) { Color getDisabledTextColor(MaterialButton button) {
if (button.textColor is MaterialStateProperty<Color>) if (button.textColor is MaterialStateProperty<Color?>)
return button.textColor!; return button.textColor!;
if (button.disabledTextColor != null) if (button.disabledTextColor != null)
return button.disabledTextColor!; return button.disabledTextColor!;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'card_theme.dart'; import 'card_theme.dart';
...@@ -104,7 +102,7 @@ class Card extends StatelessWidget { ...@@ -104,7 +102,7 @@ class Card extends StatelessWidget {
/// The [elevation] must be null or non-negative. The [borderOnForeground] /// The [elevation] must be null or non-negative. The [borderOnForeground]
/// must not be null. /// must not be null.
const Card({ const Card({
Key key, Key? key,
this.color, this.color,
this.shadowColor, this.shadowColor,
this.elevation, this.elevation,
...@@ -124,14 +122,14 @@ class Card extends StatelessWidget { ...@@ -124,14 +122,14 @@ class Card extends StatelessWidget {
/// ///
/// If this property is null then [CardTheme.color] of [ThemeData.cardTheme] /// If this property is null then [CardTheme.color] of [ThemeData.cardTheme]
/// is used. If that's null then [ThemeData.cardColor] is used. /// is used. If that's null then [ThemeData.cardColor] is used.
final Color color; final Color? color;
/// The color to paint the shadow below the card. /// The color to paint the shadow below the card.
/// ///
/// If null then the ambient [CardTheme]'s shadowColor is used. /// If null then the ambient [CardTheme]'s shadowColor is used.
/// If that's null too, then the overall theme's [ThemeData.shadowColor] /// If that's null too, then the overall theme's [ThemeData.shadowColor]
/// (default black) is used. /// (default black) is used.
final Color shadowColor; final Color? shadowColor;
/// The z-coordinate at which to place this card. This controls the size of /// The z-coordinate at which to place this card. This controls the size of
/// the shadow below the card. /// the shadow below the card.
...@@ -140,7 +138,7 @@ class Card extends StatelessWidget { ...@@ -140,7 +138,7 @@ class Card extends StatelessWidget {
/// ///
/// If this property is null then [CardTheme.elevation] of /// If this property is null then [CardTheme.elevation] of
/// [ThemeData.cardTheme] is used. If that's null, the default value is 1.0. /// [ThemeData.cardTheme] is used. If that's null, the default value is 1.0.
final double elevation; final double? elevation;
/// The shape of the card's [Material]. /// The shape of the card's [Material].
/// ///
...@@ -149,7 +147,7 @@ class Card extends StatelessWidget { ...@@ -149,7 +147,7 @@ class Card extends StatelessWidget {
/// If this property is null then [CardTheme.shape] of [ThemeData.cardTheme] /// If this property is null then [CardTheme.shape] of [ThemeData.cardTheme]
/// is used. If that's null then the shape will be a [RoundedRectangleBorder] /// is used. If that's null then the shape will be a [RoundedRectangleBorder]
/// with a circular corner radius of 4.0. /// with a circular corner radius of 4.0.
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].
/// ///
...@@ -161,7 +159,7 @@ class Card extends StatelessWidget { ...@@ -161,7 +159,7 @@ class Card extends StatelessWidget {
/// ///
/// If this property is null then [CardTheme.clipBehavior] of /// If this property is null then [CardTheme.clipBehavior] of
/// [ThemeData.cardTheme] is used. If that's null then the behavior will be [Clip.none]. /// [ThemeData.cardTheme] is used. If that's null then the behavior will be [Clip.none].
final Clip clipBehavior; final Clip? clipBehavior;
/// The empty space that surrounds the card. /// The empty space that surrounds the card.
/// ///
...@@ -170,7 +168,7 @@ class Card extends StatelessWidget { ...@@ -170,7 +168,7 @@ class Card extends StatelessWidget {
/// If this property is null then [CardTheme.margin] of /// If this property is null then [CardTheme.margin] of
/// [ThemeData.cardTheme] is used. If that's null, the default margin is 4.0 /// [ThemeData.cardTheme] is used. If that's null, the default margin is 4.0
/// logical pixels on all sides: `EdgeInsets.all(4.0)`. /// logical pixels on all sides: `EdgeInsets.all(4.0)`.
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
/// Whether this widget represents a single semantic container, or if false /// Whether this widget represents a single semantic container, or if false
/// a collection of individual semantic nodes. /// a collection of individual semantic nodes.
...@@ -188,13 +186,13 @@ class Card extends StatelessWidget { ...@@ -188,13 +186,13 @@ class Card extends StatelessWidget {
/// 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;
static const double _defaultElevation = 1.0; static const double _defaultElevation = 1.0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
final CardTheme cardTheme = CardTheme.of(context); final CardTheme cardTheme = CardTheme.of(context);
return Semantics( return Semantics(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'checkbox.dart'; import 'checkbox.dart';
...@@ -259,9 +257,9 @@ class CheckboxListTile extends StatelessWidget { ...@@ -259,9 +257,9 @@ class CheckboxListTile extends StatelessWidget {
/// ///
/// The value of [tristate] must not be null. /// The value of [tristate] must not be null.
const CheckboxListTile({ const CheckboxListTile({
Key key, Key? key,
@required this.value, required this.value,
@required this.onChanged, required this.onChanged,
this.activeColor, this.activeColor,
this.checkColor, this.checkColor,
this.title, this.title,
...@@ -284,7 +282,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -284,7 +282,7 @@ class CheckboxListTile extends StatelessWidget {
super(key: key); super(key: key);
/// Whether this checkbox is checked. /// Whether this checkbox is checked.
final bool value; final bool? value;
/// Called when the value of the checkbox should change. /// Called when the value of the checkbox should change.
/// ///
...@@ -309,32 +307,32 @@ class CheckboxListTile extends StatelessWidget { ...@@ -309,32 +307,32 @@ class CheckboxListTile extends StatelessWidget {
/// title: Text('Throw away your shot'), /// title: Text('Throw away your shot'),
/// ) /// )
/// ``` /// ```
final ValueChanged<bool> onChanged; final ValueChanged<bool?>? onChanged;
/// The color to use when this checkbox is checked. /// The color to use when this checkbox is checked.
/// ///
/// Defaults to accent color of the current [Theme]. /// Defaults to accent color of the current [Theme].
final Color activeColor; final Color? activeColor;
/// The color to use for the check icon when this checkbox is checked. /// The color to use for the check icon when this checkbox is checked.
/// ///
/// Defaults to Color(0xFFFFFFFF). /// Defaults to Color(0xFFFFFFFF).
final Color checkColor; final Color? checkColor;
/// The primary content of the list tile. /// The primary content of the list tile.
/// ///
/// Typically a [Text] widget. /// Typically a [Text] widget.
final Widget title; final Widget? title;
/// Additional content displayed below the title. /// Additional content displayed below the title.
/// ///
/// Typically a [Text] widget. /// Typically a [Text] widget.
final Widget subtitle; final Widget? subtitle;
/// A widget to display on the opposite side of the tile from the checkbox. /// A widget to display on the opposite side of the tile from the checkbox.
/// ///
/// Typically an [Icon] widget. /// Typically an [Icon] widget.
final Widget secondary; final Widget? secondary;
/// Whether this list tile is intended to display three lines of text. /// Whether this list tile is intended to display three lines of text.
/// ///
...@@ -345,7 +343,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -345,7 +343,7 @@ class CheckboxListTile extends StatelessWidget {
/// Whether this list tile is part of a vertically dense list. /// Whether this list tile is part of a vertically dense list.
/// ///
/// If this property is null then its value is based on [ListTileTheme.dense]. /// If this property is null then its value is based on [ListTileTheme.dense].
final bool dense; final bool? dense;
/// Whether to render icons and text in the [activeColor]. /// Whether to render icons and text in the [activeColor].
/// ///
...@@ -368,7 +366,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -368,7 +366,7 @@ class CheckboxListTile extends StatelessWidget {
/// widgets in [CheckboxListTile]. /// widgets in [CheckboxListTile].
/// ///
/// When the value is null, the `contentPadding` is `EdgeInsets.symmetric(horizontal: 16.0)`. /// When the value is null, the `contentPadding` is `EdgeInsets.symmetric(horizontal: 16.0)`.
final EdgeInsetsGeometry contentPadding; final EdgeInsetsGeometry? contentPadding;
/// If true the checkbox's [value] can be true, false, or null. /// If true the checkbox's [value] can be true, false, or null.
/// ///
...@@ -386,13 +384,13 @@ class CheckboxListTile extends StatelessWidget { ...@@ -386,13 +384,13 @@ class CheckboxListTile extends StatelessWidget {
assert(onChanged != null); assert(onChanged != null);
switch (value) { switch (value) {
case false: case false:
onChanged(true); onChanged!(true);
break; break;
case true: case true:
onChanged(tristate ? null : false); onChanged!(tristate ? null : false);
break; break;
default: // case null: case null:
onChanged(false); onChanged!(false);
break; break;
} }
} }
...@@ -408,7 +406,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -408,7 +406,7 @@ class CheckboxListTile extends StatelessWidget {
autofocus: autofocus, autofocus: autofocus,
tristate: tristate, tristate: tristate,
); );
Widget leading, trailing; Widget? leading, trailing;
switch (controlAffinity) { switch (controlAffinity) {
case ListTileControlAffinity.leading: case ListTileControlAffinity.leading:
leading = control; leading = control;
...@@ -422,7 +420,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -422,7 +420,7 @@ class CheckboxListTile extends StatelessWidget {
} }
return MergeSemantics( return MergeSemantics(
child: ListTileTheme.merge( child: ListTileTheme.merge(
selectedColor: activeColor ?? Theme.of(context).accentColor, selectedColor: activeColor ?? Theme.of(context)!.accentColor,
child: ListTile( child: ListTile(
leading: leading, leading: leading,
title: title, title: title,
......
This diff is collapsed.
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -47,9 +45,9 @@ class ChipTheme extends InheritedTheme { ...@@ -47,9 +45,9 @@ class ChipTheme extends InheritedTheme {
/// ///
/// The [data] and [child] arguments must not be null. /// The [data] and [child] arguments must not be null.
const ChipTheme({ const ChipTheme({
Key key, Key? key,
@required this.data, required this.data,
@required Widget child, required Widget child,
}) : assert(child != null), }) : assert(child != null),
assert(data != null), assert(data != null),
super(key: key, child: child); super(key: key, child: child);
...@@ -87,13 +85,13 @@ class ChipTheme extends InheritedTheme { ...@@ -87,13 +85,13 @@ class ChipTheme extends InheritedTheme {
/// * [ChipThemeData], which describes the actual configuration of a chip /// * [ChipThemeData], which describes the actual configuration of a chip
/// theme. /// theme.
static ChipThemeData of(BuildContext context) { static ChipThemeData of(BuildContext context) {
final ChipTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType<ChipTheme>(); final ChipTheme? inheritedTheme = context.dependOnInheritedWidgetOfExactType<ChipTheme>();
return inheritedTheme?.data ?? Theme.of(context).chipTheme; return inheritedTheme?.data ?? Theme.of(context)!.chipTheme;
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final ChipTheme ancestorTheme = context.findAncestorWidgetOfExactType<ChipTheme>(); final ChipTheme? ancestorTheme = context.findAncestorWidgetOfExactType<ChipTheme>();
return identical(this, ancestorTheme) ? child : ChipTheme(data: data, child: child); return identical(this, ancestorTheme) ? child : ChipTheme(data: data, child: child);
} }
...@@ -179,21 +177,21 @@ class ChipThemeData with Diagnosticable { ...@@ -179,21 +177,21 @@ class ChipThemeData with Diagnosticable {
/// This will rarely be used directly. It is used by [lerp] to /// This will rarely be used directly. It is used by [lerp] to
/// create intermediate themes based on two themes. /// create intermediate themes based on two themes.
const ChipThemeData({ const ChipThemeData({
@required this.backgroundColor, required this.backgroundColor,
this.deleteIconColor, this.deleteIconColor,
@required this.disabledColor, required this.disabledColor,
@required this.selectedColor, required this.selectedColor,
@required this.secondarySelectedColor, required this.secondarySelectedColor,
this.shadowColor, this.shadowColor,
this.selectedShadowColor, this.selectedShadowColor,
this.showCheckmark, this.showCheckmark,
this.checkmarkColor, this.checkmarkColor,
this.labelPadding, this.labelPadding,
@required this.padding, required this.padding,
@required this.shape, required this.shape,
@required this.labelStyle, required this.labelStyle,
@required this.secondaryLabelStyle, required this.secondaryLabelStyle,
@required this.brightness, required this.brightness,
this.elevation, this.elevation,
this.pressElevation, this.pressElevation,
}) : assert(backgroundColor != null), }) : assert(backgroundColor != null),
...@@ -224,10 +222,10 @@ class ChipThemeData with Diagnosticable { ...@@ -224,10 +222,10 @@ class ChipThemeData with Diagnosticable {
/// ///
/// This is used to generate the default chip theme for a [ThemeData]. /// This is used to generate the default chip theme for a [ThemeData].
factory ChipThemeData.fromDefaults({ factory ChipThemeData.fromDefaults({
Brightness brightness, Brightness? brightness,
Color primaryColor, Color? primaryColor,
@required Color secondaryColor, required Color secondaryColor,
@required TextStyle labelStyle, required TextStyle labelStyle,
}) { }) {
assert(primaryColor != null || brightness != null, assert(primaryColor != null || brightness != null,
'One of primaryColor or brightness must be specified'); 'One of primaryColor or brightness must be specified');
...@@ -271,7 +269,7 @@ class ChipThemeData with Diagnosticable { ...@@ -271,7 +269,7 @@ class ChipThemeData with Diagnosticable {
shape: shape, shape: shape,
labelStyle: labelStyle, labelStyle: labelStyle,
secondaryLabelStyle: secondaryLabelStyle, secondaryLabelStyle: secondaryLabelStyle,
brightness: brightness, brightness: brightness!,
); );
} }
...@@ -285,7 +283,7 @@ class ChipThemeData with Diagnosticable { ...@@ -285,7 +283,7 @@ class ChipThemeData with Diagnosticable {
/// (slightly transparent white) for dark themes. /// (slightly transparent white) for dark themes.
/// ///
/// May be set to null, in which case the ambient [IconThemeData.color] is used. /// May be set to null, in which case the ambient [IconThemeData.color] is used.
final Color deleteIconColor; final Color? deleteIconColor;
/// Color to be used for the chip's background indicating that it is disabled. /// Color to be used for the chip's background indicating that it is disabled.
/// ///
...@@ -317,7 +315,7 @@ class ChipThemeData with Diagnosticable { ...@@ -317,7 +315,7 @@ class ChipThemeData with Diagnosticable {
/// See also: /// See also:
/// ///
/// * [selectedShadowColor] /// * [selectedShadowColor]
final Color shadowColor; final Color? shadowColor;
/// Color of the chip's shadow when the elevation is greater than 0 and the /// Color of the chip's shadow when the elevation is greater than 0 and the
/// chip is selected. /// chip is selected.
...@@ -327,7 +325,7 @@ class ChipThemeData with Diagnosticable { ...@@ -327,7 +325,7 @@ class ChipThemeData with Diagnosticable {
/// See also: /// See also:
/// ///
/// * [shadowColor] /// * [shadowColor]
final Color selectedShadowColor; final Color? selectedShadowColor;
/// Whether or not to show a check mark when [SelectableChipAttributes.selected] is true. /// Whether or not to show a check mark when [SelectableChipAttributes.selected] is true.
/// ///
...@@ -335,18 +333,18 @@ class ChipThemeData with Diagnosticable { ...@@ -335,18 +333,18 @@ class ChipThemeData with Diagnosticable {
/// selected without showing the check mark. /// selected without showing the check mark.
/// ///
/// Defaults to true. /// Defaults to true.
final bool showCheckmark; final bool? showCheckmark;
/// Color of the chip's check mark when a check mark is visible. /// Color of the chip's check mark when a check mark is visible.
/// ///
/// This will override the color set by the platform's brightness setting. /// This will override the color set by the platform's brightness setting.
final Color checkmarkColor; final Color? checkmarkColor;
/// The padding around the [Chip.label] widget. /// The padding around the [Chip.label] widget.
/// ///
/// By default, this is 4 logical pixels at the beginning and the end of the /// By default, this is 4 logical pixels at the beginning and the end of the
/// label, and zero on top and bottom. /// label, and zero on top and bottom.
final EdgeInsetsGeometry labelPadding; final EdgeInsetsGeometry? labelPadding;
/// The padding between the contents of the chip and the outside [shape]. /// The padding between the contents of the chip and the outside [shape].
/// ///
...@@ -379,32 +377,32 @@ class ChipThemeData with Diagnosticable { ...@@ -379,32 +377,32 @@ class ChipThemeData with Diagnosticable {
/// The elevation to be applied to the chip. /// The elevation to be applied to the chip.
/// ///
/// If null, the chip defaults to 0. /// If null, the chip defaults to 0.
final double elevation; final double? elevation;
/// The elevation to be applied to the chip during the press motion. /// The elevation to be applied to the chip during the press motion.
/// ///
/// If null, the chip defaults to 8. /// If null, the chip defaults to 8.
final double pressElevation; final double? pressElevation;
/// 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.
ChipThemeData copyWith({ ChipThemeData copyWith({
Color backgroundColor, Color? backgroundColor,
Color deleteIconColor, Color? deleteIconColor,
Color disabledColor, Color? disabledColor,
Color selectedColor, Color? selectedColor,
Color secondarySelectedColor, Color? secondarySelectedColor,
Color shadowColor, Color? shadowColor,
Color selectedShadowColor, Color? selectedShadowColor,
Color checkmarkColor, Color? checkmarkColor,
EdgeInsetsGeometry labelPadding, EdgeInsetsGeometry? labelPadding,
EdgeInsetsGeometry padding, EdgeInsetsGeometry? padding,
ShapeBorder shape, ShapeBorder? shape,
TextStyle labelStyle, TextStyle? labelStyle,
TextStyle secondaryLabelStyle, TextStyle? secondaryLabelStyle,
Brightness brightness, Brightness? brightness,
double elevation, double? elevation,
double pressElevation, double? pressElevation,
}) { }) {
return ChipThemeData( return ChipThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColor: backgroundColor ?? this.backgroundColor,
...@@ -431,24 +429,24 @@ class ChipThemeData with Diagnosticable { ...@@ -431,24 +429,24 @@ class ChipThemeData with Diagnosticable {
/// The arguments must not be null. /// The arguments must not be null.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static ChipThemeData lerp(ChipThemeData a, ChipThemeData b, double t) { static ChipThemeData? lerp(ChipThemeData? a, ChipThemeData? b, double t) {
assert(t != null); assert(t != null);
if (a == null && b == null) if (a == null && b == null)
return null; return null;
return ChipThemeData( return ChipThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t)!,
deleteIconColor: Color.lerp(a?.deleteIconColor, b?.deleteIconColor, t), deleteIconColor: Color.lerp(a?.deleteIconColor, b?.deleteIconColor, t),
disabledColor: Color.lerp(a?.disabledColor, b?.disabledColor, t), disabledColor: Color.lerp(a?.disabledColor, b?.disabledColor, t)!,
selectedColor: Color.lerp(a?.selectedColor, b?.selectedColor, t), selectedColor: Color.lerp(a?.selectedColor, b?.selectedColor, t)!,
secondarySelectedColor: Color.lerp(a?.secondarySelectedColor, b?.secondarySelectedColor, t), secondarySelectedColor: Color.lerp(a?.secondarySelectedColor, b?.secondarySelectedColor, t)!,
shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t), shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
selectedShadowColor: Color.lerp(a?.selectedShadowColor, b?.selectedShadowColor, t), selectedShadowColor: Color.lerp(a?.selectedShadowColor, b?.selectedShadowColor, t),
checkmarkColor: Color.lerp(a?.checkmarkColor, b?.checkmarkColor, t), checkmarkColor: Color.lerp(a?.checkmarkColor, b?.checkmarkColor, t),
labelPadding: EdgeInsetsGeometry.lerp(a?.labelPadding, b?.labelPadding, t), labelPadding: EdgeInsetsGeometry.lerp(a?.labelPadding, b?.labelPadding, t),
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t), padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t)!,
shape: ShapeBorder.lerp(a?.shape, b?.shape, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t)!,
labelStyle: TextStyle.lerp(a?.labelStyle, b?.labelStyle, t), labelStyle: TextStyle.lerp(a?.labelStyle, b?.labelStyle, t)!,
secondaryLabelStyle: TextStyle.lerp(a?.secondaryLabelStyle, b?.secondaryLabelStyle, t), secondaryLabelStyle: TextStyle.lerp(a?.secondaryLabelStyle, b?.secondaryLabelStyle, t)!,
brightness: t < 0.5 ? a?.brightness ?? Brightness.light : b?.brightness ?? Brightness.light, brightness: t < 0.5 ? a?.brightness ?? Brightness.light : b?.brightness ?? Brightness.light,
elevation: lerpDouble(a?.elevation, b?.elevation, t), elevation: lerpDouble(a?.elevation, b?.elevation, t),
pressElevation: lerpDouble(a?.pressElevation, b?.pressElevation, t), pressElevation: lerpDouble(a?.pressElevation, b?.pressElevation, t),
...@@ -511,7 +509,7 @@ class ChipThemeData with Diagnosticable { ...@@ -511,7 +509,7 @@ class ChipThemeData with Diagnosticable {
final ChipThemeData defaultData = ChipThemeData.fromDefaults( final ChipThemeData defaultData = ChipThemeData.fromDefaults(
secondaryColor: defaultTheme.primaryColor, secondaryColor: defaultTheme.primaryColor,
brightness: defaultTheme.brightness, brightness: defaultTheme.brightness,
labelStyle: defaultTheme.textTheme.bodyText1, labelStyle: defaultTheme.textTheme.bodyText1!,
); );
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor)); properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor));
properties.add(ColorProperty('deleteIconColor', deleteIconColor, defaultValue: defaultData.deleteIconColor)); properties.add(ColorProperty('deleteIconColor', deleteIconColor, defaultValue: defaultData.deleteIconColor));
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'constants.dart'; import 'constants.dart';
...@@ -58,7 +56,7 @@ import 'theme_data.dart'; ...@@ -58,7 +56,7 @@ import 'theme_data.dart';
class CircleAvatar extends StatelessWidget { class CircleAvatar extends StatelessWidget {
/// Creates a circle that represents a user. /// Creates a circle that represents a user.
const CircleAvatar({ const CircleAvatar({
Key key, Key? key,
this.child, this.child,
this.backgroundColor, this.backgroundColor,
this.backgroundImage, this.backgroundImage,
...@@ -75,7 +73,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -75,7 +73,7 @@ class CircleAvatar extends StatelessWidget {
/// ///
/// Typically a [Text] widget. If the [CircleAvatar] is to have an image, use /// Typically a [Text] widget. If the [CircleAvatar] is to have an image, use
/// [backgroundImage] instead. /// [backgroundImage] instead.
final Widget child; final Widget? child;
/// The color with which to fill the circle. Changing the background /// The color with which to fill the circle. Changing the background
/// color will cause the avatar to animate to the new color. /// color will cause the avatar to animate to the new color.
...@@ -83,7 +81,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -83,7 +81,7 @@ class CircleAvatar extends StatelessWidget {
/// If a [backgroundColor] is not specified, the theme's /// If a [backgroundColor] is not specified, the theme's
/// [ThemeData.primaryColorLight] is used with dark foreground colors, and /// [ThemeData.primaryColorLight] is used with dark foreground colors, and
/// [ThemeData.primaryColorDark] with light foreground colors. /// [ThemeData.primaryColorDark] with light foreground colors.
final Color backgroundColor; final Color? backgroundColor;
/// The default text color for text in the circle. /// The default text color for text in the circle.
/// ///
...@@ -92,17 +90,17 @@ class CircleAvatar extends StatelessWidget { ...@@ -92,17 +90,17 @@ class CircleAvatar extends StatelessWidget {
/// ///
/// Defaults to [ThemeData.primaryColorLight] for dark background colors, and /// Defaults to [ThemeData.primaryColorLight] for dark background colors, and
/// [ThemeData.primaryColorDark] for light background colors. /// [ThemeData.primaryColorDark] for light background colors.
final Color foregroundColor; final Color? foregroundColor;
/// The background image of the circle. Changing the background /// The background image of the circle. Changing the background
/// image will cause the avatar to animate to the new image. /// image will cause the avatar to animate to the new image.
/// ///
/// If the [CircleAvatar] is to have the user's initials, use [child] instead. /// If the [CircleAvatar] is to have the user's initials, use [child] instead.
final ImageProvider backgroundImage; final ImageProvider? backgroundImage;
/// An optional error callback for errors emitted when loading /// An optional error callback for errors emitted when loading
/// [backgroundImage]. /// [backgroundImage].
final ImageErrorListener onBackgroundImageError; final ImageErrorListener? onBackgroundImageError;
/// The size of the avatar, expressed as the radius (half the diameter). /// The size of the avatar, expressed as the radius (half the diameter).
/// ///
...@@ -116,7 +114,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -116,7 +114,7 @@ class CircleAvatar extends StatelessWidget {
/// ///
/// Changes to the [radius] are animated (including changing from an explicit /// Changes to the [radius] are animated (including changing from an explicit
/// [radius] to a [minRadius]/[maxRadius] pair or vice versa). /// [radius] to a [minRadius]/[maxRadius] pair or vice versa).
final double radius; final double? radius;
/// The minimum size of the avatar, expressed as the radius (half the /// The minimum size of the avatar, expressed as the radius (half the
/// diameter). /// diameter).
...@@ -132,7 +130,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -132,7 +130,7 @@ class CircleAvatar extends StatelessWidget {
/// However, if the [minRadius] is 40 and the [CircleAvatar] has a parent /// However, if the [minRadius] is 40 and the [CircleAvatar] has a parent
/// [SizedBox] whose size changes instantaneously from 20 pixels to 40 pixels, /// [SizedBox] whose size changes instantaneously from 20 pixels to 40 pixels,
/// the size will snap to 40 pixels instantly. /// the size will snap to 40 pixels instantly.
final double minRadius; final double? minRadius;
/// The maximum size of the avatar, expressed as the radius (half the /// The maximum size of the avatar, expressed as the radius (half the
/// diameter). /// diameter).
...@@ -148,7 +146,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -148,7 +146,7 @@ class CircleAvatar extends StatelessWidget {
/// However, if the [maxRadius] is 40 and the [CircleAvatar] has a parent /// However, if the [maxRadius] is 40 and the [CircleAvatar] has a parent
/// [SizedBox] whose size changes instantaneously from 20 pixels to 40 pixels, /// [SizedBox] whose size changes instantaneously from 20 pixels to 40 pixels,
/// the size will snap to 40 pixels instantly. /// the size will snap to 40 pixels instantly.
final double maxRadius; final double? maxRadius;
// The default radius if nothing is specified. // The default radius if nothing is specified.
static const double _defaultRadius = 20.0; static const double _defaultRadius = 20.0;
...@@ -176,11 +174,11 @@ class CircleAvatar extends StatelessWidget { ...@@ -176,11 +174,11 @@ class CircleAvatar extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasMediaQuery(context));
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
TextStyle textStyle = theme.primaryTextTheme.subtitle1.copyWith(color: foregroundColor); TextStyle textStyle = theme.primaryTextTheme.subtitle1!.copyWith(color: foregroundColor);
Color effectiveBackgroundColor = backgroundColor; Color? effectiveBackgroundColor = backgroundColor;
if (effectiveBackgroundColor == null) { if (effectiveBackgroundColor == null) {
switch (ThemeData.estimateBrightnessForColor(textStyle.color)) { switch (ThemeData.estimateBrightnessForColor(textStyle.color!)) {
case Brightness.dark: case Brightness.dark:
effectiveBackgroundColor = theme.primaryColorLight; effectiveBackgroundColor = theme.primaryColorLight;
break; break;
...@@ -189,7 +187,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -189,7 +187,7 @@ class CircleAvatar extends StatelessWidget {
break; break;
} }
} else if (foregroundColor == null) { } else if (foregroundColor == null) {
switch (ThemeData.estimateBrightnessForColor(backgroundColor)) { switch (ThemeData.estimateBrightnessForColor(backgroundColor!)) {
case Brightness.dark: case Brightness.dark:
textStyle = textStyle.copyWith(color: theme.primaryColorLight); textStyle = textStyle.copyWith(color: theme.primaryColorLight);
break; break;
...@@ -212,7 +210,7 @@ class CircleAvatar extends StatelessWidget { ...@@ -212,7 +210,7 @@ class CircleAvatar extends StatelessWidget {
color: effectiveBackgroundColor, color: effectiveBackgroundColor,
image: backgroundImage != null image: backgroundImage != null
? DecorationImage( ? DecorationImage(
image: backgroundImage, image: backgroundImage!,
onError: onBackgroundImageError, onError: onBackgroundImageError,
fit: BoxFit.cover, fit: BoxFit.cover,
) )
...@@ -225,12 +223,12 @@ class CircleAvatar extends StatelessWidget { ...@@ -225,12 +223,12 @@ class CircleAvatar extends StatelessWidget {
child: MediaQuery( child: MediaQuery(
// Need to ignore the ambient textScaleFactor here so that the // Need to ignore the ambient textScaleFactor here so that the
// text doesn't escape the avatar when the textScaleFactor is large. // text doesn't escape the avatar when the textScaleFactor is large.
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), data: MediaQuery.of(context)!.copyWith(textScaleFactor: 1.0),
child: IconTheme( child: IconTheme(
data: theme.iconTheme.copyWith(color: textStyle.color), data: theme.iconTheme.copyWith(color: textStyle.color),
child: DefaultTextStyle( child: DefaultTextStyle(
style: textStyle, style: textStyle,
child: child, child: child!,
), ),
), ),
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart' show Brightness; import 'package:flutter/services.dart' show Brightness;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -21,19 +19,19 @@ import 'theme_data.dart'; ...@@ -21,19 +19,19 @@ import 'theme_data.dart';
class ColorScheme with Diagnosticable { class ColorScheme with Diagnosticable {
/// Create a ColorScheme instance. /// Create a ColorScheme instance.
const ColorScheme({ const ColorScheme({
@required this.primary, required this.primary,
@required this.primaryVariant, required this.primaryVariant,
@required this.secondary, required this.secondary,
@required this.secondaryVariant, required this.secondaryVariant,
@required this.surface, required this.surface,
@required this.background, required this.background,
@required this.error, required this.error,
@required this.onPrimary, required this.onPrimary,
@required this.onSecondary, required this.onSecondary,
@required this.onSurface, required this.onSurface,
@required this.onBackground, required this.onBackground,
@required this.onError, required this.onError,
@required this.brightness, required this.brightness,
}) : assert(primary != null), }) : assert(primary != null),
assert(primaryVariant != null), assert(primaryVariant != null),
assert(secondary != null), assert(secondary != null),
...@@ -175,11 +173,11 @@ class ColorScheme with Diagnosticable { ...@@ -175,11 +173,11 @@ class ColorScheme with Diagnosticable {
/// color scheme. /// color scheme.
factory ColorScheme.fromSwatch({ factory ColorScheme.fromSwatch({
MaterialColor primarySwatch = Colors.blue, MaterialColor primarySwatch = Colors.blue,
Color primaryColorDark, Color? primaryColorDark,
Color accentColor, Color? accentColor,
Color cardColor, Color? cardColor,
Color backgroundColor, Color? backgroundColor,
Color errorColor, Color? errorColor,
Brightness brightness = Brightness.light, Brightness brightness = Brightness.light,
}) { }) {
assert(primarySwatch != null); assert(primarySwatch != null);
...@@ -187,17 +185,17 @@ class ColorScheme with Diagnosticable { ...@@ -187,17 +185,17 @@ class ColorScheme with Diagnosticable {
final bool isDark = brightness == Brightness.dark; final bool isDark = brightness == Brightness.dark;
final bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark; final bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark;
final Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch); final Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200]! : primarySwatch);
final bool secondaryIsDark = _brightnessFor(secondary) == Brightness.dark; final bool secondaryIsDark = _brightnessFor(secondary) == Brightness.dark;
return ColorScheme( return ColorScheme(
primary: primarySwatch, primary: primarySwatch,
primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]), primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]!),
secondary: secondary, secondary: secondary,
secondaryVariant: isDark ? Colors.tealAccent[700] : primarySwatch[700], secondaryVariant: isDark ? Colors.tealAccent[700]! : primarySwatch[700]!,
surface: cardColor ?? (isDark ? Colors.grey[800] : Colors.white), surface: cardColor ?? (isDark ? Colors.grey[800]! : Colors.white),
background: backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]), background: backgroundColor ?? (isDark ? Colors.grey[700]! : primarySwatch[200]!),
error: errorColor ?? Colors.red[700], error: errorColor ?? Colors.red[700]!,
onPrimary: primaryIsDark ? Colors.white : Colors.black, onPrimary: primaryIsDark ? Colors.white : Colors.black,
onSecondary: secondaryIsDark ? Colors.white : Colors.black, onSecondary: secondaryIsDark ? Colors.white : Colors.black,
onSurface: isDark ? Colors.white : Colors.black, onSurface: isDark ? Colors.white : Colors.black,
...@@ -273,19 +271,19 @@ class ColorScheme with Diagnosticable { ...@@ -273,19 +271,19 @@ class ColorScheme with Diagnosticable {
/// Creates a copy of this color scheme with the given fields /// Creates a copy of this color scheme with the given fields
/// replaced by the non-null parameter values. /// replaced by the non-null parameter values.
ColorScheme copyWith({ ColorScheme copyWith({
Color primary, Color? primary,
Color primaryVariant, Color? primaryVariant,
Color secondary, Color? secondary,
Color secondaryVariant, Color? secondaryVariant,
Color surface, Color? surface,
Color background, Color? background,
Color error, Color? error,
Color onPrimary, Color? onPrimary,
Color onSecondary, Color? onSecondary,
Color onSurface, Color? onSurface,
Color onBackground, Color? onBackground,
Color onError, Color? onError,
Brightness brightness, Brightness? brightness,
}) { }) {
return ColorScheme( return ColorScheme(
primary: primary ?? this.primary, primary: primary ?? this.primary,
...@@ -309,18 +307,18 @@ class ColorScheme with Diagnosticable { ...@@ -309,18 +307,18 @@ class ColorScheme with Diagnosticable {
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static ColorScheme lerp(ColorScheme a, ColorScheme b, double t) { static ColorScheme lerp(ColorScheme a, ColorScheme b, double t) {
return ColorScheme( return ColorScheme(
primary: Color.lerp(a.primary, b.primary, t), primary: Color.lerp(a.primary, b.primary, t)!,
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t), primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t)!,
secondary: Color.lerp(a.secondary, b.secondary, t), secondary: Color.lerp(a.secondary, b.secondary, t)!,
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t), secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t)!,
surface: Color.lerp(a.surface, b.surface, t), surface: Color.lerp(a.surface, b.surface, t)!,
background: Color.lerp(a.background, b.background, t), background: Color.lerp(a.background, b.background, t)!,
error: Color.lerp(a.error, b.error, t), error: Color.lerp(a.error, b.error, t)!,
onPrimary: Color.lerp(a.onPrimary, b.onPrimary, t), onPrimary: Color.lerp(a.onPrimary, b.onPrimary, t)!,
onSecondary: Color.lerp(a.onSecondary, b.onSecondary, t), onSecondary: Color.lerp(a.onSecondary, b.onSecondary, t)!,
onSurface: Color.lerp(a.onSurface, b.onSurface, t), onSurface: Color.lerp(a.onSurface, b.onSurface, t)!,
onBackground: Color.lerp(a.onBackground, b.onBackground, t), onBackground: Color.lerp(a.onBackground, b.onBackground, t)!,
onError: Color.lerp(a.onError, b.onError, t), onError: Color.lerp(a.onError, b.onError, t)!,
brightness: t < 0.5 ? a.brightness : b.brightness, brightness: t < 0.5 ? a.brightness : b.brightness,
); );
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'data_table.dart'; import 'data_table.dart';
...@@ -35,7 +33,7 @@ abstract class DataTableSource extends ChangeNotifier { ...@@ -35,7 +33,7 @@ abstract class DataTableSource extends ChangeNotifier {
/// ///
/// Data returned from this method must be consistent for the lifetime of the /// Data returned from this method must be consistent for the lifetime of the
/// object. If the row count changes, then a new delegate must be provided. /// object. If the row count changes, then a new delegate must be provided.
DataRow getRow(int index); DataRow? getRow(int index);
/// Called to obtain the number of rows to tell the user are available. /// Called to obtain the number of rows to tell the user are available.
/// ///
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -50,44 +48,44 @@ class DataTableThemeData with Diagnosticable { ...@@ -50,44 +48,44 @@ class DataTableThemeData with Diagnosticable {
/// {@macro flutter.material.dataTable.dataRowColor} /// {@macro flutter.material.dataTable.dataRowColor}
/// {@macro flutter.material.dataTable.dataRowColorCode} /// {@macro flutter.material.dataTable.dataRowColorCode}
final MaterialStateProperty<Color> dataRowColor; final MaterialStateProperty<Color?>? dataRowColor;
/// {@macro flutter.material.dataTable.dataRowHeight} /// {@macro flutter.material.dataTable.dataRowHeight}
final double dataRowHeight; final double? dataRowHeight;
/// {@macro flutter.material.dataTable.dataTextStyle} /// {@macro flutter.material.dataTable.dataTextStyle}
final TextStyle dataTextStyle; final TextStyle? dataTextStyle;
/// {@macro flutter.material.dataTable.headingRowColor} /// {@macro flutter.material.dataTable.headingRowColor}
final MaterialStateProperty<Color> headingRowColor; final MaterialStateProperty<Color?>? headingRowColor;
/// {@macro flutter.material.dataTable.headingRowHeight} /// {@macro flutter.material.dataTable.headingRowHeight}
final double headingRowHeight; final double? headingRowHeight;
/// {@macro flutter.material.dataTable.headingTextStyle} /// {@macro flutter.material.dataTable.headingTextStyle}
final TextStyle headingTextStyle; final TextStyle? headingTextStyle;
/// {@macro flutter.material.dataTable.horizontalMargin} /// {@macro flutter.material.dataTable.horizontalMargin}
final double horizontalMargin; final double? horizontalMargin;
/// {@macro flutter.material.dataTable.columnSpacing} /// {@macro flutter.material.dataTable.columnSpacing}
final double columnSpacing; final double? columnSpacing;
/// {@macro flutter.material.dataTable.dividerThickness} /// {@macro flutter.material.dataTable.dividerThickness}
final double dividerThickness; final double? dividerThickness;
/// 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.
DataTableThemeData copyWith({ DataTableThemeData copyWith({
MaterialStateProperty<Color> dataRowColor, MaterialStateProperty<Color?>? dataRowColor,
double dataRowHeight, double? dataRowHeight,
TextStyle dataTextStyle, TextStyle? dataTextStyle,
MaterialStateProperty<Color> headingRowColor, MaterialStateProperty<Color?>? headingRowColor,
double headingRowHeight, double? headingRowHeight,
TextStyle headingTextStyle, TextStyle? headingTextStyle,
double horizontalMargin, double? horizontalMargin,
double columnSpacing, double? columnSpacing,
double dividerThickness, double? dividerThickness,
}) { }) {
return DataTableThemeData( return DataTableThemeData(
dataRowColor: dataRowColor ?? this.dataRowColor, dataRowColor: dataRowColor ?? this.dataRowColor,
...@@ -110,10 +108,10 @@ class DataTableThemeData with Diagnosticable { ...@@ -110,10 +108,10 @@ class DataTableThemeData with Diagnosticable {
static DataTableThemeData lerp(DataTableThemeData a, DataTableThemeData b, double t) { static DataTableThemeData lerp(DataTableThemeData a, DataTableThemeData b, double t) {
assert(t != null); assert(t != null);
return DataTableThemeData( return DataTableThemeData(
dataRowColor: _lerpProperties(a.dataRowColor, b.dataRowColor, t, Color.lerp), dataRowColor: _lerpProperties<Color?>(a.dataRowColor, b.dataRowColor, t, Color.lerp),
dataRowHeight: lerpDouble(a.dataRowHeight, b.dataRowHeight, t), dataRowHeight: lerpDouble(a.dataRowHeight, b.dataRowHeight, t),
dataTextStyle: TextStyle.lerp(a.dataTextStyle, b.dataTextStyle, t), dataTextStyle: TextStyle.lerp(a.dataTextStyle, b.dataTextStyle, t),
headingRowColor: _lerpProperties(a.headingRowColor, b.headingRowColor, t, Color.lerp), headingRowColor: _lerpProperties<Color?>(a.headingRowColor, b.headingRowColor, t, Color.lerp),
headingRowHeight: lerpDouble(a.headingRowHeight, b.headingRowHeight, t), headingRowHeight: lerpDouble(a.headingRowHeight, b.headingRowHeight, t),
headingTextStyle: TextStyle.lerp(a.headingTextStyle, b.headingTextStyle, t), headingTextStyle: TextStyle.lerp(a.headingTextStyle, b.headingTextStyle, t),
horizontalMargin: lerpDouble(a.horizontalMargin, b.horizontalMargin, t), horizontalMargin: lerpDouble(a.horizontalMargin, b.horizontalMargin, t),
...@@ -158,10 +156,10 @@ class DataTableThemeData with Diagnosticable { ...@@ -158,10 +156,10 @@ class DataTableThemeData with Diagnosticable {
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('dataRowColor', dataRowColor, defaultValue: null)); properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('dataRowColor', dataRowColor, defaultValue: null));
properties.add(DoubleProperty('dataRowHeight', dataRowHeight, defaultValue: null)); properties.add(DoubleProperty('dataRowHeight', dataRowHeight, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('dataTextStyle', dataTextStyle, defaultValue: null)); properties.add(DiagnosticsProperty<TextStyle>('dataTextStyle', dataTextStyle, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('headingRowColor', headingRowColor, defaultValue: null)); properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('headingRowColor', headingRowColor, defaultValue: null));
properties.add(DoubleProperty('headingRowHeight', headingRowHeight, defaultValue: null)); properties.add(DoubleProperty('headingRowHeight', headingRowHeight, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('headingTextStyle', headingTextStyle, defaultValue: null)); properties.add(DiagnosticsProperty<TextStyle>('headingTextStyle', headingTextStyle, defaultValue: null));
properties.add(DoubleProperty('horizontalMargin', horizontalMargin, defaultValue: null)); properties.add(DoubleProperty('horizontalMargin', horizontalMargin, defaultValue: null));
...@@ -169,7 +167,7 @@ class DataTableThemeData with Diagnosticable { ...@@ -169,7 +167,7 @@ class DataTableThemeData with Diagnosticable {
properties.add(DoubleProperty('dividerThickness', dividerThickness, defaultValue: null)); properties.add(DoubleProperty('dividerThickness', dividerThickness, defaultValue: null));
} }
static MaterialStateProperty<T> _lerpProperties<T>(MaterialStateProperty<T> a, MaterialStateProperty<T> b, double t, T Function(T, T, double) lerpFunction ) { static MaterialStateProperty<T>? _lerpProperties<T>(MaterialStateProperty<T>? a, MaterialStateProperty<T>? b, double t, T Function(T?, T?, double) lerpFunction ) {
// Avoid creating a _LerpProperties object for a common case. // Avoid creating a _LerpProperties object for a common case.
if (a == null && b == null) if (a == null && b == null)
return null; return null;
...@@ -180,15 +178,15 @@ class DataTableThemeData with Diagnosticable { ...@@ -180,15 +178,15 @@ class DataTableThemeData with Diagnosticable {
class _LerpProperties<T> implements MaterialStateProperty<T> { class _LerpProperties<T> implements MaterialStateProperty<T> {
const _LerpProperties(this.a, this.b, this.t, this.lerpFunction); const _LerpProperties(this.a, this.b, this.t, this.lerpFunction);
final MaterialStateProperty<T> a; final MaterialStateProperty<T>? a;
final MaterialStateProperty<T> b; final MaterialStateProperty<T>? b;
final double t; final double t;
final T Function(T, T, double) lerpFunction; final T Function(T?, T?, double) lerpFunction;
@override @override
T resolve(Set<MaterialState> states) { T resolve(Set<MaterialState> states) {
final T resolvedA = a?.resolve(states); final T? resolvedA = a?.resolve(states);
final T resolvedB = b?.resolve(states); final T? resolvedB = b?.resolve(states);
return lerpFunction(resolvedA, resolvedB, t); return lerpFunction(resolvedA, resolvedB, t);
} }
} }
...@@ -212,9 +210,9 @@ class DataTableTheme extends InheritedWidget { ...@@ -212,9 +210,9 @@ class DataTableTheme extends InheritedWidget {
/// ///
/// The [data] must not be null. /// The [data] must not be null.
const DataTableTheme({ const DataTableTheme({
Key key, Key? key,
@required this.data, required this.data,
Widget child, required Widget child,
}) : assert(data != null), super(key: key, child: child); }) : assert(data != null), super(key: key, child: child);
/// The properties used for all descendant [DataTable] widgets. /// The properties used for all descendant [DataTable] widgets.
...@@ -231,8 +229,8 @@ class DataTableTheme extends InheritedWidget { ...@@ -231,8 +229,8 @@ class DataTableTheme extends InheritedWidget {
/// DataTableThemeData theme = DataTableTheme.of(context); /// DataTableThemeData theme = DataTableTheme.of(context);
/// ``` /// ```
static DataTableThemeData of(BuildContext context) { static DataTableThemeData of(BuildContext context) {
final DataTableTheme dataTableTheme = context.dependOnInheritedWidgetOfExactType<DataTableTheme>(); final DataTableTheme? dataTableTheme = context.dependOnInheritedWidgetOfExactType<DataTableTheme>();
return dataTableTheme?.data ?? Theme.of(context).dataTableTheme; return dataTableTheme?.data ?? Theme.of(context)!.dataTableTheme;
} }
@override @override
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -44,34 +42,34 @@ class DialogTheme with Diagnosticable { ...@@ -44,34 +42,34 @@ class DialogTheme with Diagnosticable {
/// ///
/// If null, [ThemeData.dialogBackgroundColor] is used, if that's null, /// If null, [ThemeData.dialogBackgroundColor] is used, if that's null,
/// defaults to [Colors.white]. /// defaults to [Colors.white].
final Color backgroundColor; final Color? backgroundColor;
/// Default value for [Dialog.elevation]. /// Default value for [Dialog.elevation].
/// ///
/// If null, the [Dialog] elevation defaults to `24.0`. /// If null, the [Dialog] elevation defaults to `24.0`.
final double elevation; final double? elevation;
/// Default value for [Dialog.shape]. /// Default value for [Dialog.shape].
final ShapeBorder shape; final ShapeBorder? shape;
/// Used to configure the [DefaultTextStyle] for the [AlertDialog.title] widget. /// Used to configure the [DefaultTextStyle] for the [AlertDialog.title] widget.
/// ///
/// If null, defaults to [TextTheme.headline6] of [ThemeData.textTheme]. /// If null, defaults to [TextTheme.headline6] of [ThemeData.textTheme].
final TextStyle titleTextStyle; final TextStyle? titleTextStyle;
/// Used to configure the [DefaultTextStyle] for the [AlertDialog.content] widget. /// Used to configure the [DefaultTextStyle] for the [AlertDialog.content] widget.
/// ///
/// If null, defaults to [TextTheme.subtitle1] of [ThemeData.textTheme]. /// If null, defaults to [TextTheme.subtitle1] of [ThemeData.textTheme].
final TextStyle contentTextStyle; final TextStyle? contentTextStyle;
/// 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.
DialogTheme copyWith({ DialogTheme copyWith({
Color backgroundColor, Color? backgroundColor,
double elevation, double? elevation,
ShapeBorder shape, ShapeBorder? shape,
TextStyle titleTextStyle, TextStyle? titleTextStyle,
TextStyle contentTextStyle, TextStyle? contentTextStyle,
}) { }) {
return DialogTheme( return DialogTheme(
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColor: backgroundColor ?? this.backgroundColor,
...@@ -84,7 +82,7 @@ class DialogTheme with Diagnosticable { ...@@ -84,7 +82,7 @@ class DialogTheme with Diagnosticable {
/// The data from the closest [DialogTheme] instance given the build context. /// The data from the closest [DialogTheme] instance given the build context.
static DialogTheme of(BuildContext context) { static DialogTheme of(BuildContext context) {
return Theme.of(context).dialogTheme; return Theme.of(context)!.dialogTheme;
} }
/// Linearly interpolate between two dialog themes. /// Linearly interpolate between two dialog themes.
...@@ -92,7 +90,7 @@ class DialogTheme with Diagnosticable { ...@@ -92,7 +90,7 @@ class DialogTheme with Diagnosticable {
/// The arguments must not be null. /// The arguments must not be null.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static DialogTheme lerp(DialogTheme a, DialogTheme b, double t) { static DialogTheme lerp(DialogTheme? a, DialogTheme? b, double t) {
assert(t != null); assert(t != null);
return DialogTheme( return DialogTheme(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, 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 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
...@@ -92,7 +90,7 @@ class Divider extends StatelessWidget { ...@@ -92,7 +90,7 @@ class Divider extends StatelessWidget {
/// The [height], [thickness], [indent], and [endIndent] must be null or /// The [height], [thickness], [indent], and [endIndent] must be null or
/// non-negative. /// non-negative.
const Divider({ const Divider({
Key key, Key? key,
this.height, this.height,
this.thickness, this.thickness,
this.indent, this.indent,
...@@ -112,7 +110,7 @@ class Divider extends StatelessWidget { ...@@ -112,7 +110,7 @@ class Divider extends StatelessWidget {
/// ///
/// If this is null, then the [DividerThemeData.space] is used. If that is /// If this is null, then the [DividerThemeData.space] is used. If that is
/// also null, then this defaults to 16.0. /// also null, then this defaults to 16.0.
final double height; final double? height;
/// The thickness of the line drawn within the divider. /// The thickness of the line drawn within the divider.
/// ///
...@@ -121,19 +119,19 @@ class Divider extends StatelessWidget { ...@@ -121,19 +119,19 @@ class Divider extends StatelessWidget {
/// ///
/// If this is null, then the [DividerThemeData.thickness] is used. If /// If this is null, then the [DividerThemeData.thickness] is used. If
/// that is also null, then this defaults to 0.0. /// that is also null, then this defaults to 0.0.
final double thickness; final double? thickness;
/// The amount of empty space to the leading edge of the divider. /// The amount of empty space to the leading edge of the divider.
/// ///
/// If this is null, then the [DividerThemeData.indent] is used. If that is /// If this is null, then the [DividerThemeData.indent] is used. If that is
/// also null, then this defaults to 0.0. /// also null, then this defaults to 0.0.
final double indent; final double? indent;
/// The amount of empty space to the trailing edge of the divider. /// The amount of empty space to the trailing edge of the divider.
/// ///
/// If this is null, then the [DividerThemeData.endIndent] is used. If that is /// If this is null, then the [DividerThemeData.endIndent] is used. If that is
/// also null, then this defaults to 0.0. /// also null, then this defaults to 0.0.
final double endIndent; final double? endIndent;
/// The color to use when painting the line. /// The color to use when painting the line.
/// ///
...@@ -148,7 +146,7 @@ class Divider extends StatelessWidget { ...@@ -148,7 +146,7 @@ class Divider extends StatelessWidget {
/// ) /// )
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
final Color color; final Color? color;
/// Computes the [BorderSide] that represents a divider. /// Computes the [BorderSide] that represents a divider.
/// ///
...@@ -179,9 +177,9 @@ class Divider extends StatelessWidget { ...@@ -179,9 +177,9 @@ class Divider extends StatelessWidget {
/// ) /// )
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
static BorderSide createBorderSide(BuildContext context, { Color color, double width }) { static BorderSide createBorderSide(BuildContext? context, { Color? color, double? width }) {
final Color effectiveColor = color final Color? effectiveColor = color
?? (context != null ? (DividerTheme.of(context).color ?? Theme.of(context).dividerColor) : null); ?? (context != null ? (DividerTheme.of(context).color ?? Theme.of(context)!.dividerColor) : null);
final double effectiveWidth = width final double effectiveWidth = width
?? (context != null ? DividerTheme.of(context).thickness : null) ?? (context != null ? DividerTheme.of(context).thickness : null)
?? 0.0; ?? 0.0;
...@@ -243,7 +241,7 @@ class VerticalDivider extends StatelessWidget { ...@@ -243,7 +241,7 @@ class VerticalDivider extends StatelessWidget {
/// The [width], [thickness], [indent], and [endIndent] must be null or /// The [width], [thickness], [indent], and [endIndent] must be null or
/// non-negative. /// non-negative.
const VerticalDivider({ const VerticalDivider({
Key key, Key? key,
this.width, this.width,
this.thickness, this.thickness,
this.indent, this.indent,
...@@ -262,7 +260,7 @@ class VerticalDivider extends StatelessWidget { ...@@ -262,7 +260,7 @@ class VerticalDivider extends StatelessWidget {
/// ///
/// If this is null, then the [DividerThemeData.space] is used. If that is /// If this is null, then the [DividerThemeData.space] is used. If that is
/// also null, then this defaults to 16.0. /// also null, then this defaults to 16.0.
final double width; final double? width;
/// The thickness of the line drawn within the divider. /// The thickness of the line drawn within the divider.
/// ///
...@@ -271,19 +269,19 @@ class VerticalDivider extends StatelessWidget { ...@@ -271,19 +269,19 @@ class VerticalDivider extends StatelessWidget {
/// ///
/// If this is null, then the [DividerThemeData.thickness] is used which /// If this is null, then the [DividerThemeData.thickness] is used which
/// defaults to 0.0. /// defaults to 0.0.
final double thickness; final double? thickness;
/// The amount of empty space on top of the divider. /// The amount of empty space on top of the divider.
/// ///
/// If this is null, then the [DividerThemeData.indent] is used. If that is /// If this is null, then the [DividerThemeData.indent] is used. If that is
/// also null, then this defaults to 0.0. /// also null, then this defaults to 0.0.
final double indent; final double? indent;
/// The amount of empty space under the divider. /// The amount of empty space under the divider.
/// ///
/// If this is null, then the [DividerThemeData.endIndent] is used. If that is /// If this is null, then the [DividerThemeData.endIndent] is used. If that is
/// also null, then this defaults to 0.0. /// also null, then this defaults to 0.0.
final double endIndent; final double? endIndent;
/// The color to use when painting the line. /// The color to use when painting the line.
/// ///
...@@ -298,7 +296,7 @@ class VerticalDivider extends StatelessWidget { ...@@ -298,7 +296,7 @@ class VerticalDivider extends StatelessWidget {
/// ) /// )
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
final Color color; final Color? color;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -43,33 +41,33 @@ class DividerThemeData with Diagnosticable { ...@@ -43,33 +41,33 @@ class DividerThemeData with Diagnosticable {
/// The color of [Divider]s and [VerticalDivider]s, also /// The color of [Divider]s and [VerticalDivider]s, also
/// used between [ListTile]s, between rows in [DataTable]s, and so forth. /// used between [ListTile]s, between rows in [DataTable]s, and so forth.
final Color color; final Color? color;
/// The [Divider]'s width or the [VerticalDivider]'s height. /// The [Divider]'s width or the [VerticalDivider]'s height.
/// ///
/// This represents the amount of horizontal or vertical space the divider /// This represents the amount of horizontal or vertical space the divider
/// takes up. /// takes up.
final double space; final double? space;
/// The thickness of the line drawn within the divider. /// The thickness of the line drawn within the divider.
final double thickness; final double? thickness;
/// The amount of empty space at the leading edge of [Divider] or top edge of /// The amount of empty space at the leading edge of [Divider] or top edge of
/// [VerticalDivider]. /// [VerticalDivider].
final double indent; final double? indent;
/// The amount of empty space at the trailing edge of [Divider] or bottom edge /// The amount of empty space at the trailing edge of [Divider] or bottom edge
/// of [VerticalDivider]. /// of [VerticalDivider].
final double endIndent; final double? endIndent;
/// 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.
DividerThemeData copyWith({ DividerThemeData copyWith({
Color color, Color? color,
double space, double? space,
double thickness, double? thickness,
double indent, double? indent,
double endIndent, double? endIndent,
}) { }) {
return DividerThemeData( return DividerThemeData(
color: color ?? this.color, color: color ?? this.color,
...@@ -85,7 +83,7 @@ class DividerThemeData with Diagnosticable { ...@@ -85,7 +83,7 @@ class DividerThemeData 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 DividerThemeData lerp(DividerThemeData a, DividerThemeData b, double t) { static DividerThemeData lerp(DividerThemeData? a, DividerThemeData? b, double t) {
assert(t != null); assert(t != null);
return DividerThemeData( return DividerThemeData(
color: Color.lerp(a?.color, b?.color, t), color: Color.lerp(a?.color, b?.color, t),
...@@ -140,9 +138,9 @@ class DividerTheme extends InheritedTheme { ...@@ -140,9 +138,9 @@ class DividerTheme extends InheritedTheme {
/// [Divider]s, [VerticalDivider]s, dividers between [ListTile]s, and dividers /// [Divider]s, [VerticalDivider]s, dividers between [ListTile]s, and dividers
/// between rows in [DataTable]s in its widget subtree. /// between rows in [DataTable]s in its widget subtree.
const DividerTheme({ const DividerTheme({
Key key, Key? key,
@required this.data, required this.data,
Widget child, required Widget child,
}) : assert(data != null), }) : assert(data != null),
super(key: key, child: child); super(key: key, child: child);
...@@ -162,13 +160,13 @@ class DividerTheme extends InheritedTheme { ...@@ -162,13 +160,13 @@ class DividerTheme extends InheritedTheme {
/// DividerThemeData theme = DividerTheme.of(context); /// DividerThemeData theme = DividerTheme.of(context);
/// ``` /// ```
static DividerThemeData of(BuildContext context) { static DividerThemeData of(BuildContext context) {
final DividerTheme dividerTheme = context.dependOnInheritedWidgetOfExactType<DividerTheme>(); final DividerTheme? dividerTheme = context.dependOnInheritedWidgetOfExactType<DividerTheme>();
return dividerTheme?.data ?? Theme.of(context).dividerTheme; return dividerTheme?.data ?? Theme.of(context)!.dividerTheme;
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final DividerTheme ancestorTheme = context.findAncestorWidgetOfExactType<DividerTheme>(); final DividerTheme? ancestorTheme = context.findAncestorWidgetOfExactType<DividerTheme>();
return identical(this, ancestorTheme) ? child : DividerTheme(data: data, child: child); return identical(this, ancestorTheme) ? child : DividerTheme(data: data, child: child);
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/gestures.dart' show DragStartBehavior;
...@@ -141,7 +139,7 @@ class Drawer extends StatelessWidget { ...@@ -141,7 +139,7 @@ class Drawer extends StatelessWidget {
/// ///
/// The [elevation] must be non-negative. /// The [elevation] must be non-negative.
const Drawer({ const Drawer({
Key key, Key? key,
this.elevation = 16.0, this.elevation = 16.0,
this.child, this.child,
this.semanticLabel, this.semanticLabel,
...@@ -161,7 +159,7 @@ class Drawer extends StatelessWidget { ...@@ -161,7 +159,7 @@ class Drawer extends StatelessWidget {
/// Typically a [SliverList]. /// Typically a [SliverList].
/// ///
/// {@macro flutter.widgets.child} /// {@macro flutter.widgets.child}
final Widget child; final Widget? child;
/// The semantic label of the dialog used by accessibility frameworks to /// The semantic label of the dialog used by accessibility frameworks to
/// announce screen transitions when the drawer is opened and closed. /// announce screen transitions when the drawer is opened and closed.
...@@ -173,13 +171,13 @@ class Drawer extends StatelessWidget { ...@@ -173,13 +171,13 @@ class Drawer extends StatelessWidget {
/// ///
/// * [SemanticsConfiguration.namesRoute], for a description of how this /// * [SemanticsConfiguration.namesRoute], for a description of how this
/// value is used. /// value is used.
final String semanticLabel; final String? semanticLabel;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
String label = semanticLabel; String? label = semanticLabel;
switch (Theme.of(context).platform) { switch (Theme.of(context)!.platform) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
label = semanticLabel; label = semanticLabel;
...@@ -231,9 +229,9 @@ class DrawerController extends StatefulWidget { ...@@ -231,9 +229,9 @@ class DrawerController extends StatefulWidget {
/// ///
/// The [child] argument must not be null and is typically a [Drawer]. /// The [child] argument must not be null and is typically a [Drawer].
const DrawerController({ const DrawerController({
GlobalKey key, GlobalKey? key,
@required this.child, required this.child,
@required this.alignment, required this.alignment,
this.drawerCallback, this.drawerCallback,
this.dragStartBehavior = DragStartBehavior.start, this.dragStartBehavior = DragStartBehavior.start,
this.scrimColor, this.scrimColor,
...@@ -256,7 +254,7 @@ class DrawerController extends StatefulWidget { ...@@ -256,7 +254,7 @@ class DrawerController extends StatefulWidget {
final DrawerAlignment alignment; final DrawerAlignment alignment;
/// Optional callback that is called when a [Drawer] is opened or closed. /// Optional callback that is called when a [Drawer] is opened or closed.
final DrawerCallback drawerCallback; final DrawerCallback? drawerCallback;
/// {@template flutter.material.drawer.dragStartBehavior} /// {@template flutter.material.drawer.dragStartBehavior}
/// Determines the way that drag start behavior is handled. /// Determines the way that drag start behavior is handled.
...@@ -283,7 +281,7 @@ class DrawerController extends StatefulWidget { ...@@ -283,7 +281,7 @@ class DrawerController extends StatefulWidget {
/// The color to use for the scrim that obscures primary content while a drawer is open. /// The color to use for the scrim that obscures primary content while a drawer is open.
/// ///
/// By default, the color used is [Colors.black54] /// By default, the color used is [Colors.black54]
final Color scrimColor; final Color? scrimColor;
/// Determines if the [Drawer] can be opened with a drag gesture. /// Determines if the [Drawer] can be opened with a drag gesture.
/// ///
...@@ -299,7 +297,7 @@ class DrawerController extends StatefulWidget { ...@@ -299,7 +297,7 @@ class DrawerController extends StatefulWidget {
/// example, if [alignment] is set to [DrawerAlignment.start] and /// example, if [alignment] is set to [DrawerAlignment.start] and
/// `TextDirection.of(context)` is set to [TextDirection.ltr], /// `TextDirection.of(context)` is set to [TextDirection.ltr],
/// 20.0 will be added to `MediaQuery.of(context).padding.left`. /// 20.0 will be added to `MediaQuery.of(context).padding.left`.
final double edgeDragWidth; final double? edgeDragWidth;
@override @override
DrawerControllerState createState() => DrawerControllerState(); DrawerControllerState createState() => DrawerControllerState();
...@@ -338,15 +336,15 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -338,15 +336,15 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
}); });
} }
LocalHistoryEntry _historyEntry; LocalHistoryEntry? _historyEntry;
final FocusScopeNode _focusScopeNode = FocusScopeNode(); final FocusScopeNode _focusScopeNode = FocusScopeNode();
void _ensureHistoryEntry() { void _ensureHistoryEntry() {
if (_historyEntry == null) { if (_historyEntry == null) {
final ModalRoute<dynamic> route = ModalRoute.of(context); final ModalRoute<dynamic>? route = ModalRoute.of(context);
if (route != null) { if (route != null) {
_historyEntry = LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved); _historyEntry = LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved);
route.addLocalHistoryEntry(_historyEntry); route.addLocalHistoryEntry(_historyEntry!);
FocusScope.of(context).setFirstFocus(_focusScopeNode); FocusScope.of(context).setFirstFocus(_focusScopeNode);
} }
} }
...@@ -373,7 +371,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -373,7 +371,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
close(); close();
} }
AnimationController _controller; late AnimationController _controller;
void _handleDragDown(DragDownDetails details) { void _handleDragDown(DragDownDetails details) {
_controller.stop(); _controller.stop();
...@@ -393,7 +391,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -393,7 +391,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
final GlobalKey _drawerKey = GlobalKey(); final GlobalKey _drawerKey = GlobalKey();
double get _width { double get _width {
final RenderBox box = _drawerKey.currentContext?.findRenderObject() as RenderBox; final RenderBox? box = _drawerKey.currentContext?.findRenderObject() as RenderBox?;
if (box != null) if (box != null)
return box.size.width; return box.size.width;
return _kWidth; // drawer not being shown currently return _kWidth; // drawer not being shown currently
...@@ -402,7 +400,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -402,7 +400,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
bool _previouslyOpened = false; bool _previouslyOpened = false;
void _move(DragUpdateDetails details) { void _move(DragUpdateDetails details) {
double delta = details.primaryDelta / _width; double delta = details.primaryDelta! / _width;
switch (widget.alignment) { switch (widget.alignment) {
case DrawerAlignment.start: case DrawerAlignment.start:
break; break;
...@@ -410,7 +408,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -410,7 +408,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
delta = -delta; delta = -delta;
break; break;
} }
switch (Directionality.of(context)) { switch (Directionality.of(context)!) {
case TextDirection.rtl: case TextDirection.rtl:
_controller.value -= delta; _controller.value -= delta;
break; break;
...@@ -421,7 +419,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -421,7 +419,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
final bool opened = _controller.value > 0.5; final bool opened = _controller.value > 0.5;
if (opened != _previouslyOpened && widget.drawerCallback != null) if (opened != _previouslyOpened && widget.drawerCallback != null)
widget.drawerCallback(opened); widget.drawerCallback!(opened);
_previouslyOpened = opened; _previouslyOpened = opened;
} }
...@@ -437,16 +435,16 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -437,16 +435,16 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
visualVelocity = -visualVelocity; visualVelocity = -visualVelocity;
break; break;
} }
switch (Directionality.of(context)) { switch (Directionality.of(context)!) {
case TextDirection.rtl: case TextDirection.rtl:
_controller.fling(velocity: -visualVelocity); _controller.fling(velocity: -visualVelocity);
if (widget.drawerCallback != null) if (widget.drawerCallback != null)
widget.drawerCallback(visualVelocity < 0.0); widget.drawerCallback!(visualVelocity < 0.0);
break; break;
case TextDirection.ltr: case TextDirection.ltr:
_controller.fling(velocity: visualVelocity); _controller.fling(velocity: visualVelocity);
if (widget.drawerCallback != null) if (widget.drawerCallback != null)
widget.drawerCallback(visualVelocity > 0.0); widget.drawerCallback!(visualVelocity > 0.0);
break; break;
} }
} else if (_controller.value < 0.5) { } else if (_controller.value < 0.5) {
...@@ -462,17 +460,17 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -462,17 +460,17 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
void open() { void open() {
_controller.fling(velocity: 1.0); _controller.fling(velocity: 1.0);
if (widget.drawerCallback != null) if (widget.drawerCallback != null)
widget.drawerCallback(true); widget.drawerCallback!(true);
} }
/// Starts an animation to close the drawer. /// Starts an animation to close the drawer.
void close() { void close() {
_controller.fling(velocity: -1.0); _controller.fling(velocity: -1.0);
if (widget.drawerCallback != null) if (widget.drawerCallback != null)
widget.drawerCallback(false); widget.drawerCallback!(false);
} }
ColorTween _scrimColorTween; late ColorTween _scrimColorTween;
final GlobalKey _gestureDetectorKey = GlobalKey(); final GlobalKey _gestureDetectorKey = GlobalKey();
ColorTween _buildScrimColorTween() { ColorTween _buildScrimColorTween() {
...@@ -487,7 +485,6 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -487,7 +485,6 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
case DrawerAlignment.end: case DrawerAlignment.end:
return AlignmentDirectional.centerEnd; return AlignmentDirectional.centerEnd;
} }
return null;
} }
AlignmentDirectional get _drawerInnerAlignment { AlignmentDirectional get _drawerInnerAlignment {
...@@ -498,17 +495,16 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -498,17 +495,16 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
case DrawerAlignment.end: case DrawerAlignment.end:
return AlignmentDirectional.centerStart; return AlignmentDirectional.centerStart;
} }
return null;
} }
Widget _buildDrawer(BuildContext context) { Widget _buildDrawer(BuildContext context) {
final bool drawerIsStart = widget.alignment == DrawerAlignment.start; final bool drawerIsStart = widget.alignment == DrawerAlignment.start;
final EdgeInsets padding = MediaQuery.of(context).padding; final EdgeInsets padding = MediaQuery.of(context)!.padding;
final TextDirection textDirection = Directionality.of(context); final TextDirection? textDirection = Directionality.of(context);
double dragAreaWidth = widget.edgeDragWidth; double? dragAreaWidth = widget.edgeDragWidth;
if (widget.edgeDragWidth == null) { if (widget.edgeDragWidth == null) {
switch (textDirection) { switch (textDirection!) {
case TextDirection.ltr: case TextDirection.ltr:
dragAreaWidth = _kEdgeDragWidth + dragAreaWidth = _kEdgeDragWidth +
(drawerIsStart ? padding.left : padding.right); (drawerIsStart ? padding.left : padding.right);
...@@ -539,7 +535,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -539,7 +535,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
} }
} else { } else {
bool platformHasBackButton; bool platformHasBackButton;
switch (Theme.of(context).platform) { switch (Theme.of(context)!.platform) {
case TargetPlatform.android: case TargetPlatform.android:
platformHasBackButton = true; platformHasBackButton = true;
break; break;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'debug.dart'; import 'debug.dart';
...@@ -31,13 +29,13 @@ class DrawerHeader extends StatelessWidget { ...@@ -31,13 +29,13 @@ class DrawerHeader extends StatelessWidget {
/// ///
/// Requires one of its ancestors to be a [Material] widget. /// Requires one of its ancestors to be a [Material] widget.
const DrawerHeader({ const DrawerHeader({
Key key, Key? key,
this.decoration, this.decoration,
this.margin = const EdgeInsets.only(bottom: 8.0), this.margin = const EdgeInsets.only(bottom: 8.0),
this.padding = const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0), this.padding = const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 8.0),
this.duration = const Duration(milliseconds: 250), this.duration = const Duration(milliseconds: 250),
this.curve = Curves.fastOutSlowIn, this.curve = Curves.fastOutSlowIn,
@required this.child, required this.child,
}) : super(key: key); }) : super(key: key);
/// Decoration for the main drawer header [Container]; useful for applying /// Decoration for the main drawer header [Container]; useful for applying
...@@ -46,7 +44,7 @@ class DrawerHeader extends StatelessWidget { ...@@ -46,7 +44,7 @@ class DrawerHeader extends StatelessWidget {
/// This decoration will extend under the system status bar. /// This decoration will extend under the system status bar.
/// ///
/// If this is changed, it will be animated according to [duration] and [curve]. /// If this is changed, it will be animated according to [duration] and [curve].
final Decoration decoration; final Decoration? decoration;
/// The padding by which to inset [child]. /// The padding by which to inset [child].
/// ///
...@@ -57,7 +55,7 @@ class DrawerHeader extends StatelessWidget { ...@@ -57,7 +55,7 @@ class DrawerHeader extends StatelessWidget {
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
/// The margin around the drawer header. /// The margin around the drawer header.
final EdgeInsetsGeometry margin; final EdgeInsetsGeometry? margin;
/// The duration for animations of the [decoration]. /// The duration for animations of the [decoration].
final Duration duration; final Duration duration;
...@@ -71,14 +69,14 @@ class DrawerHeader extends StatelessWidget { ...@@ -71,14 +69,14 @@ class DrawerHeader extends StatelessWidget {
/// precisely, consider using an [Align] or [Center] widget. /// precisely, consider using an [Align] or [Center] widget.
/// ///
/// {@macro flutter.widgets.child} /// {@macro flutter.widgets.child}
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasMediaQuery(context));
final ThemeData theme = Theme.of(context); final ThemeData? theme = Theme.of(context);
final double statusBarHeight = MediaQuery.of(context).padding.top; final double statusBarHeight = MediaQuery.of(context)!.padding.top;
return Container( return Container(
height: statusBarHeight + _kDrawerHeaderHeight, height: statusBarHeight + _kDrawerHeaderHeight,
margin: margin, margin: margin,
...@@ -93,11 +91,11 @@ class DrawerHeader extends StatelessWidget { ...@@ -93,11 +91,11 @@ class DrawerHeader extends StatelessWidget {
duration: duration, duration: duration,
curve: curve, curve: curve,
child: child == null ? null : DefaultTextStyle( child: child == null ? null : DefaultTextStyle(
style: theme.textTheme.bodyText1, style: theme!.textTheme.bodyText1!,
child: MediaQuery.removePadding( child: MediaQuery.removePadding(
context: context, context: context,
removeTop: true, removeTop: true,
child: child, child: child!,
), ),
), ),
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui' show lerpDouble; import 'dart:ui' show lerpDouble;
...@@ -57,14 +55,14 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -57,14 +55,14 @@ class ElevatedButton extends ButtonStyleButton {
/// ///
/// The [autofocus] and [clipBehavior] arguments must not be null. /// The [autofocus] and [clipBehavior] arguments must not be null.
const ElevatedButton({ const ElevatedButton({
Key key, Key? key,
@required VoidCallback onPressed, required VoidCallback? onPressed,
VoidCallback onLongPress, VoidCallback? onLongPress,
ButtonStyle style, ButtonStyle? style,
FocusNode focusNode, FocusNode? focusNode,
bool autofocus = false, bool autofocus = false,
Clip clipBehavior = Clip.none, Clip clipBehavior = Clip.none,
@required Widget child, required Widget? child,
}) : super( }) : super(
key: key, key: key,
onPressed: onPressed, onPressed: onPressed,
...@@ -85,14 +83,14 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -85,14 +83,14 @@ class ElevatedButton extends ButtonStyleButton {
/// The [icon] and [label] arguments must not be null. /// The [icon] and [label] arguments must not be null.
factory ElevatedButton.icon({ factory ElevatedButton.icon({
Key key, Key key,
@required VoidCallback onPressed, required VoidCallback onPressed,
VoidCallback onLongPress, VoidCallback onLongPress,
ButtonStyle style, ButtonStyle style,
FocusNode focusNode, FocusNode focusNode,
bool autofocus, bool autofocus,
Clip clipBehavior, Clip clipBehavior,
@required Widget icon, required Widget icon,
@required Widget label, required Widget label,
}) = _ElevatedButtonWithIcon; }) = _ElevatedButtonWithIcon;
/// A static convenience method that constructs an elevated button /// A static convenience method that constructs an elevated button
...@@ -133,41 +131,41 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -133,41 +131,41 @@ class ElevatedButton extends ButtonStyleButton {
/// ) /// )
/// ``` /// ```
static ButtonStyle styleFrom({ static ButtonStyle styleFrom({
Color primary, Color? primary,
Color onPrimary, Color? onPrimary,
Color onSurface, Color? onSurface,
Color shadowColor, Color? shadowColor,
double elevation, double? elevation,
TextStyle textStyle, TextStyle? textStyle,
EdgeInsetsGeometry padding, EdgeInsetsGeometry? padding,
Size minimumSize, Size? minimumSize,
BorderSide side, BorderSide? side,
OutlinedBorder shape, OutlinedBorder? shape,
MouseCursor enabledMouseCursor, MouseCursor? enabledMouseCursor,
MouseCursor disabledMouseCursor, MouseCursor? disabledMouseCursor,
VisualDensity visualDensity, VisualDensity? visualDensity,
MaterialTapTargetSize tapTargetSize, MaterialTapTargetSize? tapTargetSize,
Duration animationDuration, Duration? animationDuration,
bool enableFeedback, bool? enableFeedback,
}) { }) {
final MaterialStateProperty<Color> backgroundColor = (onSurface == null && primary == null) final MaterialStateProperty<Color?>? backgroundColor = (onSurface == null && primary == null)
? null ? null
: _ElevatedButtonDefaultBackground(primary, onSurface); : _ElevatedButtonDefaultBackground(primary, onSurface);
final MaterialStateProperty<Color> foregroundColor = (onSurface == null && onPrimary == null) final MaterialStateProperty<Color?>? foregroundColor = (onSurface == null && onPrimary == null)
? null ? null
: _ElevatedButtonDefaultForeground(onPrimary, onSurface); : _ElevatedButtonDefaultForeground(onPrimary, onSurface);
final MaterialStateProperty<Color> overlayColor = (onPrimary == null) final MaterialStateProperty<Color?>? overlayColor = (onPrimary == null)
? null ? null
: _ElevatedButtonDefaultOverlay(onPrimary); : _ElevatedButtonDefaultOverlay(onPrimary);
final MaterialStateProperty<double> elevationValue = (elevation == null) final MaterialStateProperty<double>? elevationValue = (elevation == null)
? null ? null
: _ElevatedButtonDefaultElevation(elevation); : _ElevatedButtonDefaultElevation(elevation);
final MaterialStateProperty<MouseCursor> mouseCursor = (enabledMouseCursor == null && disabledMouseCursor == null) final MaterialStateProperty<MouseCursor?>? mouseCursor = (enabledMouseCursor == null && disabledMouseCursor == null)
? null ? null
: _ElevatedButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor); : _ElevatedButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor);
return ButtonStyle( return ButtonStyle(
textStyle: MaterialStateProperty.all<TextStyle>(textStyle), textStyle: MaterialStateProperty.all<TextStyle?>(textStyle),
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
foregroundColor: foregroundColor, foregroundColor: foregroundColor,
overlayColor: overlayColor, overlayColor: overlayColor,
...@@ -250,7 +248,7 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -250,7 +248,7 @@ class ElevatedButton extends ButtonStyleButton {
/// * `3 < textScaleFactor` - horizontal(4) /// * `3 < textScaleFactor` - horizontal(4)
@override @override
ButtonStyle defaultStyleOf(BuildContext context) { ButtonStyle defaultStyleOf(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context)!;
final ColorScheme colorScheme = theme.colorScheme; final ColorScheme colorScheme = theme.colorScheme;
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding( final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
...@@ -283,20 +281,20 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -283,20 +281,20 @@ class ElevatedButton extends ButtonStyleButton {
/// Returns the [ElevatedButtonThemeData.style] of the closest /// Returns the [ElevatedButtonThemeData.style] of the closest
/// [ElevatedButtonTheme] ancestor. /// [ElevatedButtonTheme] ancestor.
@override @override
ButtonStyle themeStyleOf(BuildContext context) { ButtonStyle? themeStyleOf(BuildContext context) {
return ElevatedButtonTheme.of(context)?.style; return ElevatedButtonTheme.of(context).style;
} }
} }
@immutable @immutable
class _ElevatedButtonDefaultBackground extends MaterialStateProperty<Color> with Diagnosticable { class _ElevatedButtonDefaultBackground extends MaterialStateProperty<Color?> with Diagnosticable {
_ElevatedButtonDefaultBackground(this.primary, this.onSurface); _ElevatedButtonDefaultBackground(this.primary, this.onSurface);
final Color primary; final Color? primary;
final Color onSurface; final Color? onSurface;
@override @override
Color resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) if (states.contains(MaterialState.disabled))
return onSurface?.withOpacity(0.12); return onSurface?.withOpacity(0.12);
return primary; return primary;
...@@ -304,14 +302,14 @@ class _ElevatedButtonDefaultBackground extends MaterialStateProperty<Color> with ...@@ -304,14 +302,14 @@ class _ElevatedButtonDefaultBackground extends MaterialStateProperty<Color> with
} }
@immutable @immutable
class _ElevatedButtonDefaultForeground extends MaterialStateProperty<Color> with Diagnosticable { class _ElevatedButtonDefaultForeground extends MaterialStateProperty<Color?> with Diagnosticable {
_ElevatedButtonDefaultForeground(this.onPrimary, this.onSurface); _ElevatedButtonDefaultForeground(this.onPrimary, this.onSurface);
final Color onPrimary; final Color? onPrimary;
final Color onSurface; final Color? onSurface;
@override @override
Color resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) if (states.contains(MaterialState.disabled))
return onSurface?.withOpacity(0.38); return onSurface?.withOpacity(0.38);
return onPrimary; return onPrimary;
...@@ -319,17 +317,17 @@ class _ElevatedButtonDefaultForeground extends MaterialStateProperty<Color> with ...@@ -319,17 +317,17 @@ class _ElevatedButtonDefaultForeground extends MaterialStateProperty<Color> with
} }
@immutable @immutable
class _ElevatedButtonDefaultOverlay extends MaterialStateProperty<Color> with Diagnosticable { class _ElevatedButtonDefaultOverlay extends MaterialStateProperty<Color?> with Diagnosticable {
_ElevatedButtonDefaultOverlay(this.onPrimary); _ElevatedButtonDefaultOverlay(this.onPrimary);
final Color onPrimary; final Color onPrimary;
@override @override
Color resolve(Set<MaterialState> states) { Color? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) if (states.contains(MaterialState.hovered))
return onPrimary?.withOpacity(0.08); return onPrimary.withOpacity(0.08);
if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed))
return onPrimary?.withOpacity(0.24); return onPrimary.withOpacity(0.24);
return null; return null;
} }
} }
...@@ -355,14 +353,14 @@ class _ElevatedButtonDefaultElevation extends MaterialStateProperty<double> with ...@@ -355,14 +353,14 @@ class _ElevatedButtonDefaultElevation extends MaterialStateProperty<double> with
} }
@immutable @immutable
class _ElevatedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCursor> with Diagnosticable { class _ElevatedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCursor?> with Diagnosticable {
_ElevatedButtonDefaultMouseCursor(this.enabledCursor, this.disabledCursor); _ElevatedButtonDefaultMouseCursor(this.enabledCursor, this.disabledCursor);
final MouseCursor enabledCursor; final MouseCursor? enabledCursor;
final MouseCursor disabledCursor; final MouseCursor? disabledCursor;
@override @override
MouseCursor resolve(Set<MaterialState> states) { MouseCursor? resolve(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) if (states.contains(MaterialState.disabled))
return disabledCursor; return disabledCursor;
return enabledCursor; return enabledCursor;
...@@ -371,15 +369,15 @@ class _ElevatedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCurso ...@@ -371,15 +369,15 @@ class _ElevatedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCurso
class _ElevatedButtonWithIcon extends ElevatedButton { class _ElevatedButtonWithIcon extends ElevatedButton {
_ElevatedButtonWithIcon({ _ElevatedButtonWithIcon({
Key key, Key? key,
@required VoidCallback onPressed, required VoidCallback? onPressed,
VoidCallback onLongPress, VoidCallback? onLongPress,
ButtonStyle style, ButtonStyle? style,
FocusNode focusNode, FocusNode? focusNode,
bool autofocus, bool? autofocus,
Clip clipBehavior, Clip? clipBehavior,
@required Widget icon, required Widget icon,
@required Widget label, required Widget label,
}) : assert(icon != null), }) : assert(icon != null),
assert(label != null), assert(label != null),
super( super(
...@@ -408,7 +406,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton { ...@@ -408,7 +406,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton {
} }
class _ElevatedButtonWithIconChild extends StatelessWidget { class _ElevatedButtonWithIconChild extends StatelessWidget {
const _ElevatedButtonWithIconChild({ Key key, this.label, this.icon }) : super(key: key); const _ElevatedButtonWithIconChild({ Key? key, required this.label, required this.icon }) : super(key: key);
final Widget label; final Widget label;
final Widget icon; final Widget icon;
...@@ -416,7 +414,7 @@ class _ElevatedButtonWithIconChild extends StatelessWidget { ...@@ -416,7 +414,7 @@ class _ElevatedButtonWithIconChild extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final double scale = MediaQuery.of(context, nullOk: true)?.textScaleFactor ?? 1; final double scale = MediaQuery.of(context, nullOk: true)?.textScaleFactor ?? 1;
final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1)); final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1))!;
return Row( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[icon, SizedBox(width: gap), label], children: <Widget>[icon, SizedBox(width: gap), label],
......
...@@ -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';
...@@ -44,10 +42,10 @@ class ElevatedButtonThemeData with Diagnosticable { ...@@ -44,10 +42,10 @@ class ElevatedButtonThemeData with Diagnosticable {
/// [ElevatedButton.defaultStyleOf]. /// [ElevatedButton.defaultStyleOf].
/// ///
/// If [style] is null, then this theme doesn't override anything. /// If [style] is null, then this theme doesn't override anything.
final ButtonStyle style; final ButtonStyle? style;
/// Linearly interpolate between two elevated button themes. /// Linearly interpolate between two elevated button themes.
static ElevatedButtonThemeData lerp(ElevatedButtonThemeData a, ElevatedButtonThemeData b, double t) { static ElevatedButtonThemeData? lerp(ElevatedButtonThemeData? a, ElevatedButtonThemeData? b, double t) {
assert (t != null); assert (t != null);
if (a == null && b == null) if (a == null && b == null)
return null; return null;
...@@ -93,9 +91,9 @@ class ElevatedButtonTheme extends InheritedTheme { ...@@ -93,9 +91,9 @@ class ElevatedButtonTheme extends InheritedTheme {
/// ///
/// The [data] parameter must not be null. /// The [data] parameter must not be null.
const ElevatedButtonTheme({ const ElevatedButtonTheme({
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 configuration of this theme. /// The configuration of this theme.
...@@ -112,13 +110,13 @@ class ElevatedButtonTheme extends InheritedTheme { ...@@ -112,13 +110,13 @@ class ElevatedButtonTheme extends InheritedTheme {
/// ElevatedButtonTheme theme = ElevatedButtonTheme.of(context); /// ElevatedButtonTheme theme = ElevatedButtonTheme.of(context);
/// ``` /// ```
static ElevatedButtonThemeData of(BuildContext context) { static ElevatedButtonThemeData of(BuildContext context) {
final ElevatedButtonTheme buttonTheme = context.dependOnInheritedWidgetOfExactType<ElevatedButtonTheme>(); final ElevatedButtonTheme? buttonTheme = context.dependOnInheritedWidgetOfExactType<ElevatedButtonTheme>();
return buttonTheme?.data ?? Theme.of(context).elevatedButtonTheme; return buttonTheme?.data ?? Theme.of(context)!.elevatedButtonTheme;
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final ElevatedButtonTheme ancestorTheme = context.findAncestorWidgetOfExactType<ElevatedButtonTheme>(); final ElevatedButtonTheme? ancestorTheme = context.findAncestorWidgetOfExactType<ElevatedButtonTheme>();
return identical(this, ancestorTheme) ? child : ElevatedButtonTheme(data: data, child: child); return identical(this, ancestorTheme) ? child : ElevatedButtonTheme(data: data, child: child);
} }
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -33,10 +31,10 @@ class ExpandIcon extends StatefulWidget { ...@@ -33,10 +31,10 @@ class ExpandIcon extends StatefulWidget {
/// Creates an [ExpandIcon] with the given padding, and a callback that is /// Creates an [ExpandIcon] with the given padding, and a callback that is
/// triggered when the icon is pressed. /// triggered when the icon is pressed.
const ExpandIcon({ const ExpandIcon({
Key key, Key? key,
this.isExpanded = false, this.isExpanded = false,
this.size = 24.0, this.size = 24.0,
@required this.onPressed, required this.onPressed,
this.padding = const EdgeInsets.all(8.0), this.padding = const EdgeInsets.all(8.0),
this.color, this.color,
this.disabledColor, this.disabledColor,
...@@ -61,7 +59,7 @@ class ExpandIcon extends StatefulWidget { ...@@ -61,7 +59,7 @@ class ExpandIcon extends StatefulWidget {
/// between expanded and collapsed. The value passed to the current state. /// between expanded and collapsed. The value passed to the current state.
/// ///
/// If this is set to null, the button will be disabled. /// If this is set to null, the button will be disabled.
final ValueChanged<bool> onPressed; final ValueChanged<bool>? onPressed;
/// The padding around the icon. The entire padded icon will react to input /// The padding around the icon. The entire padded icon will react to input
/// gestures. /// gestures.
...@@ -77,7 +75,7 @@ class ExpandIcon extends StatefulWidget { ...@@ -77,7 +75,7 @@ class ExpandIcon extends StatefulWidget {
/// [Colors.white60] when it is [Brightness.dark]. This adheres to the /// [Colors.white60] when it is [Brightness.dark]. This adheres to the
/// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color) /// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color)
/// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application) /// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application)
final Color color; final Color? color;
/// The color of the icon when it is disabled, /// The color of the icon when it is disabled,
/// i.e. if [onPressed] is null. /// i.e. if [onPressed] is null.
...@@ -87,7 +85,7 @@ class ExpandIcon extends StatefulWidget { ...@@ -87,7 +85,7 @@ class ExpandIcon extends StatefulWidget {
/// [Colors.white38] when it is [Brightness.dark]. This adheres to the /// [Colors.white38] when it is [Brightness.dark]. This adheres to the
/// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color) /// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color)
/// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application) /// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application)
final Color disabledColor; final Color? disabledColor;
/// The color of the icon when the icon is expanded. /// The color of the icon when the icon is expanded.
/// ///
...@@ -96,15 +94,15 @@ class ExpandIcon extends StatefulWidget { ...@@ -96,15 +94,15 @@ class ExpandIcon extends StatefulWidget {
/// [Colors.white] when it is [Brightness.dark]. This adheres to the /// [Colors.white] when it is [Brightness.dark]. This adheres to the
/// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color) /// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color)
/// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application) /// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application)
final Color expandedColor; final Color? expandedColor;
@override @override
_ExpandIconState createState() => _ExpandIconState(); _ExpandIconState createState() => _ExpandIconState();
} }
class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateMixin { class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateMixin {
AnimationController _controller; late AnimationController _controller;
Animation<double> _iconTurns; late Animation<double> _iconTurns;
static final Animatable<double> _iconTurnTween = Tween<double>(begin: 0.0, end: 0.5) static final Animatable<double> _iconTurnTween = Tween<double>(begin: 0.0, end: 0.5)
.chain(CurveTween(curve: Curves.fastOutSlowIn)); .chain(CurveTween(curve: Curves.fastOutSlowIn));
...@@ -140,7 +138,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM ...@@ -140,7 +138,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
void _handlePressed() { void _handlePressed() {
if (widget.onPressed != null) if (widget.onPressed != null)
widget.onPressed(widget.isExpanded); widget.onPressed!(widget.isExpanded);
} }
/// Default icon colors and opacities for when [Theme.brightness] is set to /// Default icon colors and opacities for when [Theme.brightness] is set to
...@@ -150,29 +148,26 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM ...@@ -150,29 +148,26 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
/// [Material Design dark theme specifications](https://material.io/design/color/dark-theme.html#ui-application) /// [Material Design dark theme specifications](https://material.io/design/color/dark-theme.html#ui-application)
Color get _iconColor { Color get _iconColor {
if (widget.isExpanded && widget.expandedColor != null) { if (widget.isExpanded && widget.expandedColor != null) {
return widget.expandedColor; return widget.expandedColor!;
} }
if (widget.color != null) { if (widget.color != null) {
return widget.color; return widget.color!;
} }
switch(Theme.of(context).brightness) { switch(Theme.of(context)!.brightness) {
case Brightness.light: case Brightness.light:
return Colors.black54; return Colors.black54;
case Brightness.dark: case Brightness.dark:
return Colors.white60; return Colors.white60;
} }
assert(false);
return null;
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
final MaterialLocalizations localizations = MaterialLocalizations.of(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context)!;
final String onTapHint = widget.isExpanded ? localizations.expandedIconTapHint : localizations.collapsedIconTapHint; final String onTapHint = widget.isExpanded ? localizations.expandedIconTapHint : localizations.collapsedIconTapHint;
return Semantics( return Semantics(
......
...@@ -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';
...@@ -76,8 +74,8 @@ class ExpansionPanel { ...@@ -76,8 +74,8 @@ class ExpansionPanel {
/// ///
/// The [headerBuilder], [body], and [isExpanded] arguments must not be null. /// The [headerBuilder], [body], and [isExpanded] arguments must not be null.
ExpansionPanel({ ExpansionPanel({
@required this.headerBuilder, required this.headerBuilder,
@required this.body, required this.body,
this.isExpanded = false, this.isExpanded = false,
this.canTapOnHeader = false, this.canTapOnHeader = false,
}) : assert(headerBuilder != null), }) : assert(headerBuilder != null),
...@@ -121,9 +119,9 @@ class ExpansionPanelRadio extends ExpansionPanel { ...@@ -121,9 +119,9 @@ class ExpansionPanelRadio extends ExpansionPanel {
/// A unique [value] must be passed into the constructor. The /// A unique [value] must be passed into the constructor. The
/// [headerBuilder], [body], [value] must not be null. /// [headerBuilder], [body], [value] must not be null.
ExpansionPanelRadio({ ExpansionPanelRadio({
@required this.value, required this.value,
@required ExpansionPanelHeaderBuilder headerBuilder, required ExpansionPanelHeaderBuilder headerBuilder,
@required Widget body, required Widget body,
bool canTapOnHeader = false, bool canTapOnHeader = false,
}) : assert(value != null), }) : assert(value != null),
super( super(
...@@ -226,7 +224,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -226,7 +224,7 @@ class ExpansionPanelList extends StatefulWidget {
/// ///
/// The [children] and [animationDuration] arguments must not be null. /// The [children] and [animationDuration] arguments must not be null.
const ExpansionPanelList({ const ExpansionPanelList({
Key key, Key? key,
this.children = const <ExpansionPanel>[], this.children = const <ExpansionPanel>[],
this.expansionCallback, this.expansionCallback,
this.animationDuration = kThemeAnimationDuration, this.animationDuration = kThemeAnimationDuration,
...@@ -316,7 +314,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -316,7 +314,7 @@ class ExpansionPanelList extends StatefulWidget {
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
const ExpansionPanelList.radio({ const ExpansionPanelList.radio({
Key key, Key? key,
this.children = const <ExpansionPanelRadio>[], this.children = const <ExpansionPanelRadio>[],
this.expansionCallback, this.expansionCallback,
this.animationDuration = kThemeAnimationDuration, this.animationDuration = kThemeAnimationDuration,
...@@ -349,7 +347,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -349,7 +347,7 @@ class ExpansionPanelList extends StatefulWidget {
/// ///
/// This callback is useful in order to keep track of the expanded/collapsed /// This callback is useful in order to keep track of the expanded/collapsed
/// panels in a parent widget that may need to react to these changes. /// panels in a parent widget that may need to react to these changes.
final ExpansionPanelCallback expansionCallback; final ExpansionPanelCallback? expansionCallback;
/// The duration of the expansion animation. /// The duration of the expansion animation.
final Duration animationDuration; final Duration animationDuration;
...@@ -360,7 +358,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -360,7 +358,7 @@ class ExpansionPanelList extends StatefulWidget {
/// The value of the panel that initially begins open. (This value is /// The value of the panel that initially begins open. (This value is
/// only used when initializing with the [ExpansionPanelList.radio] /// only used when initializing with the [ExpansionPanelList.radio]
/// constructor.) /// constructor.)
final Object initialOpenPanelValue; final Object? initialOpenPanelValue;
/// The padding that surrounds the panel header when expanded. /// The padding that surrounds the panel header when expanded.
/// ///
...@@ -372,7 +370,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -372,7 +370,7 @@ class ExpansionPanelList extends StatefulWidget {
/// ///
/// If `dividerColor` is null, then [DividerThemeData.color] is used. If that /// If `dividerColor` is null, then [DividerThemeData.color] is used. If that
/// is null, then [ThemeData.dividerColor] is used. /// is null, then [ThemeData.dividerColor] is used.
final Color dividerColor; final Color? dividerColor;
/// Defines elevation for the [ExpansionPanel] while it's expanded. /// Defines elevation for the [ExpansionPanel] while it's expanded.
/// ///
...@@ -390,7 +388,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -390,7 +388,7 @@ class ExpansionPanelList extends StatefulWidget {
} }
class _ExpansionPanelListState extends State<ExpansionPanelList> { class _ExpansionPanelListState extends State<ExpansionPanelList> {
ExpansionPanelRadio _currentOpenPanel; ExpansionPanelRadio? _currentOpenPanel;
@override @override
void initState() { void initState() {
...@@ -439,7 +437,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> { ...@@ -439,7 +437,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
void _handlePressed(bool isExpanded, int index) { void _handlePressed(bool isExpanded, int index) {
if (widget.expansionCallback != null) if (widget.expansionCallback != null)
widget.expansionCallback(index, isExpanded); widget.expansionCallback!(index, isExpanded);
if (widget._allowOnlyOnePanelOpen) { if (widget._allowOnlyOnePanelOpen) {
final ExpansionPanelRadio pressedChild = widget.children[index] as ExpansionPanelRadio; final ExpansionPanelRadio pressedChild = widget.children[index] as ExpansionPanelRadio;
...@@ -451,7 +449,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> { ...@@ -451,7 +449,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
if (widget.expansionCallback != null && if (widget.expansionCallback != null &&
childIndex != index && childIndex != index &&
child.value == _currentOpenPanel?.value) child.value == _currentOpenPanel?.value)
widget.expansionCallback(childIndex, false); widget.expansionCallback!(childIndex, false);
} }
setState(() { setState(() {
...@@ -460,7 +458,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> { ...@@ -460,7 +458,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
} }
} }
ExpansionPanelRadio searchPanelByValue(List<ExpansionPanelRadio> panels, Object value) { ExpansionPanelRadio? searchPanelByValue(List<ExpansionPanelRadio> panels, Object? value) {
for (final ExpansionPanelRadio panel in panels) { for (final ExpansionPanelRadio panel in panels) {
if (panel.value == value) if (panel.value == value)
return panel; return panel;
...@@ -498,7 +496,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> { ...@@ -498,7 +496,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
), ),
); );
if (!child.canTapOnHeader) { if (!child.canTapOnHeader) {
final MaterialLocalizations localizations = MaterialLocalizations.of(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context)!;
expandIconContainer = Semantics( expandIconContainer = Semantics(
label: _isChildExpanded(index)? localizations.expandedIconTapHint : localizations.collapsedIconTapHint, label: _isChildExpanded(index)? localizations.expandedIconTapHint : localizations.collapsedIconTapHint,
container: true, container: true,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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