Skip to content

Commit da0f9a9

Browse files
authored
Enable private field promotion for framework (#134473)
New feature in upcoming Dart 3.2. See dart-lang/language#2020. Feature is enabled by bumping the min SDK version to 3.2. Part of flutter/flutter#134476.
1 parent 2396a41 commit da0f9a9

21 files changed

+47
-47
lines changed

packages/flutter/lib/src/cupertino/colors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
11261126
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
11271127
super.debugFillProperties(properties);
11281128
if (_debugLabel != null) {
1129-
properties.add(MessageProperty('debugLabel', _debugLabel!));
1129+
properties.add(MessageProperty('debugLabel', _debugLabel));
11301130
}
11311131
properties.add(createCupertinoColorProperty('color', color));
11321132
if (_isPlatformBrightnessDependent) {

packages/flutter/lib/src/cupertino/route.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,16 +845,16 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
845845
return b!._colors == null ? b : _CupertinoEdgeShadowDecoration._(b._colors!.map<Color>((Color color) => Color.lerp(null, color, t)!).toList());
846846
}
847847
if (b == null) {
848-
return a._colors == null ? a : _CupertinoEdgeShadowDecoration._(a._colors!.map<Color>((Color color) => Color.lerp(null, color, 1.0 - t)!).toList());
848+
return a._colors == null ? a : _CupertinoEdgeShadowDecoration._(a._colors.map<Color>((Color color) => Color.lerp(null, color, 1.0 - t)!).toList());
849849
}
850850
assert(b._colors != null || a._colors != null);
851851
// If it ever becomes necessary, we could allow decorations with different
852852
// length' here, similarly to how it is handled in [LinearGradient.lerp].
853-
assert(b._colors == null || a._colors == null || a._colors!.length == b._colors!.length);
853+
assert(b._colors == null || a._colors == null || a._colors.length == b._colors.length);
854854
return _CupertinoEdgeShadowDecoration._(
855855
<Color>[
856856
for (int i = 0; i < b._colors!.length; i += 1)
857-
Color.lerp(a._colors?[i], b._colors?[i], t)!,
857+
Color.lerp(a._colors?[i], b._colors[i], t)!,
858858
],
859859
);
860860
}
@@ -904,7 +904,7 @@ class _CupertinoEdgeShadowPainter extends BoxPainter {
904904
_CupertinoEdgeShadowPainter(
905905
this._decoration,
906906
super.onChanged,
907-
) : assert(_decoration._colors == null || _decoration._colors!.length > 1);
907+
) : assert(_decoration._colors == null || _decoration._colors.length > 1);
908908

909909
final _CupertinoEdgeShadowDecoration _decoration;
910910

packages/flutter/lib/src/foundation/diagnostics.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
26732673
@override
26742674
String toDescription({ TextTreeConfiguration? parentConfiguration }) {
26752675
if (_description != null) {
2676-
return _addTooltip(_description!);
2676+
return _addTooltip(_description);
26772677
}
26782678

26792679
if (exception != null) {

packages/flutter/lib/src/foundation/persistent_hash_map.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PersistentHashMap<K extends Object, V> {
5353

5454
// Unfortunately can not use unsafeCast<V?>(...) here because it leads
5555
// to worse code generation on VM.
56-
return _root!.get(0, key, key.hashCode) as V?;
56+
return _root.get(0, key, key.hashCode) as V?;
5757
}
5858
}
5959

packages/flutter/lib/src/material/button_theme.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class ButtonThemeData with Diagnosticable {
249249
/// child (typically the button's label).
250250
EdgeInsetsGeometry get padding {
251251
if (_padding != null) {
252-
return _padding!;
252+
return _padding;
253253
}
254254
switch (textTheme) {
255255
case ButtonTextTheme.normal:
@@ -277,7 +277,7 @@ class ButtonThemeData with Diagnosticable {
277277
/// [Material].
278278
ShapeBorder get shape {
279279
if (_shape != null) {
280-
return _shape!;
280+
return _shape;
281281
}
282282
switch (textTheme) {
283283
case ButtonTextTheme.normal:
@@ -537,7 +537,7 @@ class ButtonThemeData with Diagnosticable {
537537
switch (getTextTheme(button)) {
538538
case ButtonTextTheme.normal:
539539
case ButtonTextTheme.accent:
540-
return _splashColor!;
540+
return _splashColor;
541541
case ButtonTextTheme.primary:
542542
break;
543543
}
@@ -642,7 +642,7 @@ class ButtonThemeData with Diagnosticable {
642642
}
643643

644644
if (_padding != null) {
645-
return _padding!;
645+
return _padding;
646646
}
647647

648648
switch (getTextTheme(button)) {

packages/flutter/lib/src/material/ink_highlight.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class InkHighlight extends InteractiveInkFeature {
130130
void paintFeature(Canvas canvas, Matrix4 transform) {
131131
final Paint paint = Paint()..color = color.withAlpha(_alpha.value);
132132
final Offset? originOffset = MatrixUtils.getAsTranslation(transform);
133-
final Rect rect = _rectCallback != null ? _rectCallback!() : Offset.zero & referenceBox.size;
133+
final Rect rect = _rectCallback != null ? _rectCallback() : Offset.zero & referenceBox.size;
134134
if (originOffset == null) {
135135
canvas.save();
136136
canvas.transform(transform.storage);

packages/flutter/lib/src/material/ink_ripple.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class InkRipple extends InteractiveInkFeature {
228228
final Paint paint = Paint()..color = color.withAlpha(alpha);
229229
Rect? rect;
230230
if (_clipCallback != null) {
231-
rect = _clipCallback!();
231+
rect = _clipCallback();
232232
}
233233
// Splash moves to the center of the reference box.
234234
final Offset center = Offset.lerp(

packages/flutter/lib/src/material/ink_sparkle.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class InkSparkle extends InteractiveInkFeature {
285285
if (_clipCallback != null) {
286286
_clipCanvas(
287287
canvas: canvas,
288-
clipCallback: _clipCallback!,
288+
clipCallback: _clipCallback,
289289
textDirection: _textDirection,
290290
customBorder: customBorder,
291291
borderRadius: _borderRadius,
@@ -296,7 +296,7 @@ class InkSparkle extends InteractiveInkFeature {
296296

297297
final Paint paint = Paint()..shader = _fragmentShader;
298298
if (_clipCallback != null) {
299-
canvas.drawRect(_clipCallback!(), paint);
299+
canvas.drawRect(_clipCallback(), paint);
300300
} else {
301301
canvas.drawPaint(paint);
302302
}

packages/flutter/lib/src/material/list_tile_theme.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -378,79 +378,79 @@ class ListTileTheme extends InheritedTheme {
378378
///
379379
/// This property is obsolete: please use the [data]
380380
/// [ListTileThemeData.dense] property instead.
381-
bool? get dense => _data != null ? _data!.dense : _dense;
381+
bool? get dense => _data != null ? _data.dense : _dense;
382382

383383
/// Overrides the default value of [ListTile.shape].
384384
///
385385
/// This property is obsolete: please use the [data]
386386
/// [ListTileThemeData.shape] property instead.
387-
ShapeBorder? get shape => _data != null ? _data!.shape : _shape;
387+
ShapeBorder? get shape => _data != null ? _data.shape : _shape;
388388

389389
/// Overrides the default value of [ListTile.style].
390390
///
391391
/// This property is obsolete: please use the [data]
392392
/// [ListTileThemeData.style] property instead.
393-
ListTileStyle? get style => _data != null ? _data!.style : _style;
393+
ListTileStyle? get style => _data != null ? _data.style : _style;
394394

395395
/// Overrides the default value of [ListTile.selectedColor].
396396
///
397397
/// This property is obsolete: please use the [data]
398398
/// [ListTileThemeData.selectedColor] property instead.
399-
Color? get selectedColor => _data != null ? _data!.selectedColor : _selectedColor;
399+
Color? get selectedColor => _data != null ? _data.selectedColor : _selectedColor;
400400

401401
/// Overrides the default value of [ListTile.iconColor].
402402
///
403403
/// This property is obsolete: please use the [data]
404404
/// [ListTileThemeData.iconColor] property instead.
405-
Color? get iconColor => _data != null ? _data!.iconColor : _iconColor;
405+
Color? get iconColor => _data != null ? _data.iconColor : _iconColor;
406406

407407
/// Overrides the default value of [ListTile.textColor].
408408
///
409409
/// This property is obsolete: please use the [data]
410410
/// [ListTileThemeData.textColor] property instead.
411-
Color? get textColor => _data != null ? _data!.textColor : _textColor;
411+
Color? get textColor => _data != null ? _data.textColor : _textColor;
412412

413413
/// Overrides the default value of [ListTile.contentPadding].
414414
///
415415
/// This property is obsolete: please use the [data]
416416
/// [ListTileThemeData.contentPadding] property instead.
417-
EdgeInsetsGeometry? get contentPadding => _data != null ? _data!.contentPadding : _contentPadding;
417+
EdgeInsetsGeometry? get contentPadding => _data != null ? _data.contentPadding : _contentPadding;
418418

419419
/// Overrides the default value of [ListTile.tileColor].
420420
///
421421
/// This property is obsolete: please use the [data]
422422
/// [ListTileThemeData.tileColor] property instead.
423-
Color? get tileColor => _data != null ? _data!.tileColor : _tileColor;
423+
Color? get tileColor => _data != null ? _data.tileColor : _tileColor;
424424

425425
/// Overrides the default value of [ListTile.selectedTileColor].
426426
///
427427
/// This property is obsolete: please use the [data]
428428
/// [ListTileThemeData.selectedTileColor] property instead.
429-
Color? get selectedTileColor => _data != null ? _data!.selectedTileColor : _selectedTileColor;
429+
Color? get selectedTileColor => _data != null ? _data.selectedTileColor : _selectedTileColor;
430430

431431
/// Overrides the default value of [ListTile.horizontalTitleGap].
432432
///
433433
/// This property is obsolete: please use the [data]
434434
/// [ListTileThemeData.horizontalTitleGap] property instead.
435-
double? get horizontalTitleGap => _data != null ? _data!.horizontalTitleGap : _horizontalTitleGap;
435+
double? get horizontalTitleGap => _data != null ? _data.horizontalTitleGap : _horizontalTitleGap;
436436

437437
/// Overrides the default value of [ListTile.minVerticalPadding].
438438
///
439439
/// This property is obsolete: please use the [data]
440440
/// [ListTileThemeData.minVerticalPadding] property instead.
441-
double? get minVerticalPadding => _data != null ? _data!.minVerticalPadding : _minVerticalPadding;
441+
double? get minVerticalPadding => _data != null ? _data.minVerticalPadding : _minVerticalPadding;
442442

443443
/// Overrides the default value of [ListTile.minLeadingWidth].
444444
///
445445
/// This property is obsolete: please use the [data]
446446
/// [ListTileThemeData.minLeadingWidth] property instead.
447-
double? get minLeadingWidth => _data != null ? _data!.minLeadingWidth : _minLeadingWidth;
447+
double? get minLeadingWidth => _data != null ? _data.minLeadingWidth : _minLeadingWidth;
448448

449449
/// Overrides the default value of [ListTile.enableFeedback].
450450
///
451451
/// This property is obsolete: please use the [data]
452452
/// [ListTileThemeData.enableFeedback] property instead.
453-
bool? get enableFeedback => _data != null ? _data!.enableFeedback : _enableFeedback;
453+
bool? get enableFeedback => _data != null ? _data.enableFeedback : _enableFeedback;
454454

455455
/// The [data] property of the closest instance of this class that
456456
/// encloses the given context.

packages/flutter/lib/src/painting/strut_style.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class StrutStyle with Diagnosticable {
405405
/// constructor.
406406
List<String>? get fontFamilyFallback {
407407
if (_package != null && _fontFamilyFallback != null) {
408-
return _fontFamilyFallback!.map((String family) => 'packages/$_package/$family').toList();
408+
return _fontFamilyFallback.map((String family) => 'packages/$_package/$family').toList();
409409
}
410410
return _fontFamilyFallback;
411411
}

0 commit comments

Comments
 (0)