Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/flutter/lib/material.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

/// Flutter widgets implementing Material Design.
///
/// To use, import `package:flutter/material.dart`.
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/cupertino/nav_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ class _BackChevron extends StatelessWidget {
@override
Widget build(BuildContext 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
// custom non-square padding.
Expand Down Expand Up @@ -1982,7 +1982,7 @@ class _NavigationBarComponentsTransition {
opacity: fadeOutBy(0.4),
// Keep the font when transitioning into a non-back-label leading.
child: DefaultTextStyle(
style: bottomLargeTitleTextStyle,
style: bottomLargeTitleTextStyle!,
child: bottomLargeTitle.child,
),
),
Expand Down Expand Up @@ -2219,7 +2219,7 @@ class _NavigationBarComponentsTransition {
child: FadeTransition(
opacity: fadeInFrom(0.3),
child: DefaultTextStyle(
style: topLargeTitleTextStyle,
style: topLargeTitleTextStyle!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
child: topLargeTitle.child,
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/segmented_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class _SegmentedControlState<T extends Object> extends State<CupertinoSegmentedC
selectedIndex = (widget.groupValue == currentKey) ? index : selectedIndex;
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),
);
final IconThemeData iconTheme = IconThemeData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class _SegmentedControlState<T> extends State<CupertinoSlidingSegmentedControl<T
builder: (BuildContext context, Widget? child) {
final List<Widget> children = <Widget>[];
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]!),
);

Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/cupertino/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,10 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
super.dispose();
}

EditableTextState? get _editableText => editableTextKey.currentState;
EditableTextState get _editableText => editableTextKey.currentState!;

void _requestKeyboard() {
_editableText?.requestKeyboard();
_editableText.requestKeyboard();
}

bool _shouldShowSelectionHandles(SelectionChangedCause? cause) {
Expand All @@ -730,7 +730,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio

void _handleSelectionChanged(TextSelection selection, SelectionChangedCause? cause) {
if (cause == SelectionChangedCause.longPress) {
_editableText?.bringIntoView(selection.base);
_editableText.bringIntoView(selection.base);
}
final bool willShowSelectionHandles = _shouldShowSelectionHandles(cause);
if (willShowSelectionHandles != _showSelectionHandles) {
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
);
}
return DefaultTextStyle(
style: theme.textTheme.caption,
style: theme.textTheme.caption!,
child: page,
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class _AppBarState extends State<AppBar> {
}

title = DefaultTextStyle(
style: centerStyle,
style: centerStyle!,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: title,
Expand Down Expand Up @@ -650,7 +650,7 @@ class _AppBarState extends State<AppBar> {
child: IconTheme.merge(
data: overallIconTheme,
child: DefaultTextStyle(
style: sideStyle,
style: sideStyle!,
child: toolbar,
),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class MaterialBanner extends StatelessWidget {
),
Expanded(
child: DefaultTextStyle(
style: textStyle,
style: textStyle!,
child: content,
),
),
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/lib/src/material/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,11 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {

@override
Widget build(BuildContext context) {
final Color? effectiveTextColor = MaterialStateProperty.resolveAs<Color>(widget.textStyle?.color, _states);
final ShapeBorder? effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder>(widget.shape, _states);
final Color? effectiveTextColor = MaterialStateProperty.resolveAs<Color?>(widget.textStyle?.color, _states);
final ShapeBorder? effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder?>(widget.shape, _states);
final Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment;
final BoxConstraints effectiveConstraints = widget.visualDensity.effectiveConstraints(widget.constraints);
final MouseCursor? effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>(
final MouseCursor? effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor?>(
widget.mouseCursor ?? MaterialStateMouseCursor.clickable,
_states,
);
Expand Down
102 changes: 51 additions & 51 deletions packages/flutter/lib/src/material/button_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,58 +120,58 @@ class ButtonStyle with Diagnosticable {
///
/// The color of the [textStyle] is typically not used directly, the
/// [foregroundColor] is used instead.
final MaterialStateProperty<TextStyle>? textStyle;
final MaterialStateProperty<TextStyle?>? textStyle;

/// The button's background fill color.
final MaterialStateProperty<Color>? backgroundColor;
final MaterialStateProperty<Color?>? backgroundColor;

/// The color for the button's [Text] and [Icon] widget descendants.
///
/// This color is typically used instead of the color of the [textStyle]. All
/// of the components that compute defaults from [ButtonStyle] values
/// compute a default [foregroundColor] and use that instead of the
/// [textStyle]'s color.
final MaterialStateProperty<Color>? foregroundColor;
final MaterialStateProperty<Color?>? foregroundColor;

/// The highlight color that's typically used to indicate that
/// the button is focused, hovered, or pressed.
final MaterialStateProperty<Color>? overlayColor;
final MaterialStateProperty<Color?>? overlayColor;

/// The shadow color of the button's [Material].
///
/// The material's elevation shadow can be difficult to see for
/// dark themes, so by default the button classes add a
/// semi-transparent overlay to indicate elevation. See
/// [ThemeData.applyElevationOverlayColor].
final MaterialStateProperty<Color>? shadowColor;
final MaterialStateProperty<Color?>? shadowColor;

/// The elevation of the button's [Material].
final MaterialStateProperty<double>? elevation;
final MaterialStateProperty<double?>? elevation;

/// The padding between the button's boundary and its child.
final MaterialStateProperty<EdgeInsetsGeometry>? padding;
final MaterialStateProperty<EdgeInsetsGeometry?>? padding;

/// The minimum size of the button itself.
///
/// The size of the rectangle the button lies within may be larger
/// per [tapTargetSize].
final MaterialStateProperty<Size>? minimumSize;
final MaterialStateProperty<Size?>? minimumSize;

/// The color and weight of the button's outline.
///
/// This value is combined with [shape] to create a shape decorated
/// with an outline.
final MaterialStateProperty<BorderSide>? side;
final MaterialStateProperty<BorderSide?>? side;

/// The shape of the button's underlying [Material].
///
/// This shape is combined with [side] to create a shape decorated
/// with an outline.
final MaterialStateProperty<OutlinedBorder>? shape;
final MaterialStateProperty<OutlinedBorder?>? shape;

/// The cursor for a mouse pointer when it enters or is hovering over
/// this button's [InkWell].
final MaterialStateProperty<MouseCursor>? mouseCursor;
final MaterialStateProperty<MouseCursor?>? mouseCursor;

/// Defines how compact the button's layout will be.
///
Expand Down Expand Up @@ -211,17 +211,17 @@ class ButtonStyle with Diagnosticable {
/// Returns a copy of this ButtonStyle with the given fields replaced with
/// the new values.
ButtonStyle copyWith({
MaterialStateProperty<TextStyle>? textStyle,
MaterialStateProperty<Color>? backgroundColor,
MaterialStateProperty<Color>? foregroundColor,
MaterialStateProperty<Color>? overlayColor,
MaterialStateProperty<Color>? shadowColor,
MaterialStateProperty<double>? elevation,
MaterialStateProperty<EdgeInsetsGeometry>? padding,
MaterialStateProperty<Size>? minimumSize,
MaterialStateProperty<BorderSide>? side,
MaterialStateProperty<OutlinedBorder>? shape,
MaterialStateProperty<MouseCursor>? mouseCursor,
MaterialStateProperty<TextStyle?>? textStyle,
MaterialStateProperty<Color?>? backgroundColor,
MaterialStateProperty<Color?>? foregroundColor,
MaterialStateProperty<Color?>? overlayColor,
MaterialStateProperty<Color?>? shadowColor,
MaterialStateProperty<double?>? elevation,
MaterialStateProperty<EdgeInsetsGeometry?>? padding,
MaterialStateProperty<Size?>? minimumSize,
MaterialStateProperty<BorderSide?>? side,
MaterialStateProperty<OutlinedBorder?>? shape,
MaterialStateProperty<MouseCursor?>? mouseCursor,
VisualDensity? visualDensity,
MaterialTapTargetSize? tapTargetSize,
Duration? animationDuration,
Expand Down Expand Up @@ -321,17 +321,17 @@ class ButtonStyle with Diagnosticable {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<MaterialStateProperty<TextStyle>>('textStyle', textStyle, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('backgroundColor', backgroundColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('foregroundColor', foregroundColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('overlayColor', overlayColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('shadowColor', shadowColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<double>>('elevation', elevation, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<EdgeInsetsGeometry>>('padding', padding, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Size>>('minimumSize', minimumSize, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<BorderSide>>('side', side, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<OutlinedBorder>>('shape', shape, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<MouseCursor>>('mouseCursor', mouseCursor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<TextStyle?>>('textStyle', textStyle, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('backgroundColor', backgroundColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('foregroundColor', foregroundColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('overlayColor', overlayColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color?>>('shadowColor', shadowColor, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<double?>>('elevation', elevation, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<EdgeInsetsGeometry?>>('padding', padding, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Size?>>('minimumSize', minimumSize, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<BorderSide?>>('side', side, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<OutlinedBorder?>>('shape', shape, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<MouseCursor?>>('mouseCursor', mouseCursor, defaultValue: null));
properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: null));
properties.add(EnumProperty<MaterialTapTargetSize>('tapTargetSize', tapTargetSize, defaultValue: null));
properties.add(DiagnosticsProperty<Duration>('animationDuration', animationDuration, defaultValue: null));
Expand All @@ -344,14 +344,14 @@ class ButtonStyle with Diagnosticable {
if (a == null && b == null)
return null;
return ButtonStyle(
textStyle: _lerpProperties<TextStyle>(a?.textStyle, b?.textStyle, t, TextStyle.lerp),
backgroundColor: _lerpProperties<Color>(a?.backgroundColor, b?.backgroundColor, t, Color.lerp),
foregroundColor: _lerpProperties<Color>(a?.foregroundColor, b?.foregroundColor, t, Color.lerp),
overlayColor: _lerpProperties<Color>(a?.overlayColor, b?.overlayColor, t, Color.lerp),
shadowColor: _lerpProperties<Color>(a?.shadowColor, b?.shadowColor, t, Color.lerp),
elevation: _lerpProperties<double>(a?.elevation, b?.elevation, t, lerpDouble),
padding: _lerpProperties<EdgeInsetsGeometry>(a?.padding, b?.padding, t, EdgeInsetsGeometry.lerp),
minimumSize: _lerpProperties<Size>(a?.minimumSize, b?.minimumSize, t, Size.lerp),
textStyle: _lerpProperties<TextStyle?>(a?.textStyle, b?.textStyle, t, TextStyle.lerp),
backgroundColor: _lerpProperties<Color?>(a?.backgroundColor, b?.backgroundColor, t, Color.lerp),
foregroundColor: _lerpProperties<Color?>(a?.foregroundColor, b?.foregroundColor, t, Color.lerp),
overlayColor: _lerpProperties<Color?>(a?.overlayColor, b?.overlayColor, t, Color.lerp),
shadowColor: _lerpProperties<Color?>(a?.shadowColor, b?.shadowColor, t, Color.lerp),
elevation: _lerpProperties<double?>(a?.elevation, b?.elevation, t, lerpDouble),
padding: _lerpProperties<EdgeInsetsGeometry?>(a?.padding, b?.padding, t, EdgeInsetsGeometry.lerp),
minimumSize: _lerpProperties<Size?>(a?.minimumSize, b?.minimumSize, t, Size.lerp),
side: _lerpSides(a?.side, b?.side, t),
shape: _lerpShapes(a?.shape, b?.shape, t),
mouseCursor: t < 0.5 ? a?.mouseCursor : b?.mouseCursor,
Expand All @@ -362,29 +362,29 @@ class ButtonStyle with Diagnosticable {
);
}

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.
if (a == null && b == null)
return null;
return _LerpProperties<T>(a, b, t, lerpFunction);
}

// Special case because BorderSide.lerp() doesn't support null arguments
static MaterialStateProperty<BorderSide>? _lerpSides(MaterialStateProperty<BorderSide>? a, MaterialStateProperty<BorderSide>? b, double t) {
static MaterialStateProperty<BorderSide?>? _lerpSides(MaterialStateProperty<BorderSide?>? a, MaterialStateProperty<BorderSide?>? b, double t) {
if (a == null && b == null)
return null;
return _LerpSides(a, b, t);
}

// TODO(hansmuller): OutlinedBorder needs a lerp method - https://github.com/flutter/flutter/issues/60555.
static MaterialStateProperty<OutlinedBorder>? _lerpShapes(MaterialStateProperty<OutlinedBorder>? a, MaterialStateProperty<OutlinedBorder>? b, double t) {
static MaterialStateProperty<OutlinedBorder?>? _lerpShapes(MaterialStateProperty<OutlinedBorder?>? a, MaterialStateProperty<OutlinedBorder?>? b, double t) {
if (a == null && b == null)
return null;
return _LerpShapes(a, b, t);
}
}

class _LerpProperties<T> implements MaterialStateProperty<T> {
class _LerpProperties<T> implements MaterialStateProperty<T?> {
const _LerpProperties(this.a, this.b, this.t, this.lerpFunction);

final MaterialStateProperty<T>? a;
Expand All @@ -400,11 +400,11 @@ class _LerpProperties<T> implements MaterialStateProperty<T> {
}
}

class _LerpSides implements MaterialStateProperty<BorderSide> {
class _LerpSides implements MaterialStateProperty<BorderSide?> {
const _LerpSides(this.a, this.b, this.t);

final MaterialStateProperty<BorderSide>? a;
final MaterialStateProperty<BorderSide>? b;
final MaterialStateProperty<BorderSide?>? a;
final MaterialStateProperty<BorderSide?>? b;
final double t;

@override
Expand All @@ -421,11 +421,11 @@ class _LerpSides implements MaterialStateProperty<BorderSide> {
}
}

class _LerpShapes implements MaterialStateProperty<OutlinedBorder> {
class _LerpShapes implements MaterialStateProperty<OutlinedBorder?> {
const _LerpShapes(this.a, this.b, this.t);

final MaterialStateProperty<OutlinedBorder>? a;
final MaterialStateProperty<OutlinedBorder>? b;
final MaterialStateProperty<OutlinedBorder?>? a;
final MaterialStateProperty<OutlinedBorder?>? b;
final double t;

@override
Expand Down
Loading