Skip to content

Commit

Permalink
[ui] replace dynamic with Object? (flutter#31771)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams authored Mar 2, 2022
1 parent e5d43dd commit 3b3b101
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
4 changes: 2 additions & 2 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void _runMainZoned(Function startMainIsolateFunction,
startMainIsolateFunction(() {
runZonedGuarded<void>(() {
if (userMainFunction is _ListStringArgFunction) {
(userMainFunction as dynamic)(args);
userMainFunction(args);
} else {
userMainFunction();
}
Expand Down Expand Up @@ -233,7 +233,7 @@ bool _isLoopback(String host) {
@pragma('vm:entry-point')
void Function(Uri) _getHttpConnectionHookClosure(bool mayInsecurelyConnectToAllDomains) {
return (Uri uri) {
final dynamic zoneOverride = Zone.current[#flutter.io.allow_http];
final Object? zoneOverride = Zone.current[#flutter.io.allow_http];
if (zoneOverride == true) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/natives.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
part of dart.ui;

// Corelib 'print' implementation.
void _print(dynamic arg) {
void _print(Object? arg) {
_Logger._printString(arg.toString());
}

void _printDebug(dynamic arg) {
void _printDebug(Object? arg) {
_Logger._printDebugString(arg.toString());
}

Expand Down
52 changes: 28 additions & 24 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ class Paint {
// The binary format must match the deserialization code in paint.cc.

final ByteData _data = ByteData(_kDataByteCount);

static const int _kIsAntiAliasIndex = 0;
static const int _kColorIndex = 1;
static const int _kBlendModeIndex = 2;
Expand Down Expand Up @@ -1140,10 +1141,10 @@ class Paint {
static const int _kDataByteCount = 56;

// Binary format must match the deserialization code in paint.cc.
List<dynamic>? _objects;
List<Object?>? _objects;

List<dynamic> _ensureObjectsInitialized() {
return _objects ??= List<dynamic>.filled(_kObjectCount, null, growable: false);
List<Object?> _ensureObjectsInitialized() {
return _objects ??= List<Object?>.filled(_kObjectCount, null, growable: false);
}

static const int _kShaderIndex = 0;
Expand Down Expand Up @@ -1409,7 +1410,8 @@ class Paint {
///
/// When a shape is being drawn, [colorFilter] overrides [color] and [shader].
ColorFilter? get colorFilter {
return _objects?[_kColorFilterIndex]?.creator as ColorFilter?;
final _ColorFilter? nativeFilter = _objects?[_kColorFilterIndex] as _ColorFilter?;
return nativeFilter?.creator;
}

set colorFilter(ColorFilter? value) {
Expand Down Expand Up @@ -1446,7 +1448,8 @@ class Paint {
///
/// * [MaskFilter], which is used for drawing geometry.
ImageFilter? get imageFilter {
return _objects?[_kImageFilterIndex]?.creator as ImageFilter?;
final _ImageFilter? nativeFilter = _objects?[_kImageFilterIndex] as _ImageFilter?;
return nativeFilter?.creator;
}

set imageFilter(ImageFilter? value) {
Expand All @@ -1455,8 +1458,9 @@ class Paint {
_objects![_kImageFilterIndex] = null;
}
} else {
final List<dynamic> objects = _ensureObjectsInitialized();
if (objects[_kImageFilterIndex]?.creator != value) {
final List<Object?> objects = _ensureObjectsInitialized();
final _ImageFilter? imageFilter = objects[_kImageFilterIndex] as _ImageFilter?;
if (imageFilter?.creator != value) {
objects[_kImageFilterIndex] = value._toNativeImageFilter();
}
}
Expand Down Expand Up @@ -4247,13 +4251,13 @@ class Canvas extends NativeFieldWrapperClass1 {
paint._objects, paint._data);
}
}
void _saveLayerWithoutBounds(List<dynamic>? paintObjects, ByteData paintData)
void _saveLayerWithoutBounds(List<Object?>? paintObjects, ByteData paintData)
native 'Canvas_saveLayerWithoutBounds';
void _saveLayer(double left,
double top,
double right,
double bottom,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_saveLayer';

/// Pops the current save stack, if there is anything to pop.
Expand Down Expand Up @@ -4384,7 +4388,7 @@ class Canvas extends NativeFieldWrapperClass1 {
double y1,
double x2,
double y2,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawLine';

/// Fills the canvas with the given [Paint].
Expand All @@ -4395,7 +4399,7 @@ class Canvas extends NativeFieldWrapperClass1 {
assert(paint != null);
_drawPaint(paint._objects, paint._data);
}
void _drawPaint(List<dynamic>? paintObjects, ByteData paintData) native 'Canvas_drawPaint';
void _drawPaint(List<Object?>? paintObjects, ByteData paintData) native 'Canvas_drawPaint';

/// Draws a rectangle with the given [Paint]. Whether the rectangle is filled
/// or stroked (or both) is controlled by [Paint.style].
Expand All @@ -4409,7 +4413,7 @@ class Canvas extends NativeFieldWrapperClass1 {
double top,
double right,
double bottom,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawRect';

/// Draws a rounded rectangle with the given [Paint]. Whether the rectangle is
Expand All @@ -4420,7 +4424,7 @@ class Canvas extends NativeFieldWrapperClass1 {
_drawRRect(rrect._getValue32(), paint._objects, paint._data);
}
void _drawRRect(Float32List rrect,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawRRect';

/// Draws a shape consisting of the difference between two rounded rectangles
Expand All @@ -4436,7 +4440,7 @@ class Canvas extends NativeFieldWrapperClass1 {
}
void _drawDRRect(Float32List outer,
Float32List inner,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawDRRect';

/// Draws an axis-aligned oval that fills the given axis-aligned rectangle
Expand All @@ -4452,7 +4456,7 @@ class Canvas extends NativeFieldWrapperClass1 {
double top,
double right,
double bottom,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawOval';

/// Draws a circle centered at the point given by the first argument and
Expand All @@ -4467,7 +4471,7 @@ class Canvas extends NativeFieldWrapperClass1 {
void _drawCircle(double x,
double y,
double radius,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawCircle';

/// Draw an arc scaled to fit inside the given rectangle.
Expand All @@ -4494,7 +4498,7 @@ class Canvas extends NativeFieldWrapperClass1 {
double startAngle,
double sweepAngle,
bool useCenter,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawArc';

/// Draws the given [Path] with the given [Paint].
Expand All @@ -4508,7 +4512,7 @@ class Canvas extends NativeFieldWrapperClass1 {
_drawPath(path, paint._objects, paint._data);
}
void _drawPath(Path path,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawPath';

/// Draws the given [Image] into the canvas with its top-left corner at the
Expand All @@ -4522,7 +4526,7 @@ class Canvas extends NativeFieldWrapperClass1 {
void _drawImage(_Image image,
double x,
double y,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData,
int filterQualityIndex) native 'Canvas_drawImage';

Expand Down Expand Up @@ -4562,7 +4566,7 @@ class Canvas extends NativeFieldWrapperClass1 {
double dstTop,
double dstRight,
double dstBottom,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData,
int filterQualityIndex) native 'Canvas_drawImageRect';

Expand Down Expand Up @@ -4606,7 +4610,7 @@ class Canvas extends NativeFieldWrapperClass1 {
double dstTop,
double dstRight,
double dstBottom,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData,
int filterQualityIndex) native 'Canvas_drawImageNine';

Expand Down Expand Up @@ -4677,7 +4681,7 @@ class Canvas extends NativeFieldWrapperClass1 {
_drawPoints(paint._objects, paint._data, pointMode.index, points);
}

void _drawPoints(List<dynamic>? paintObjects,
void _drawPoints(List<Object?>? paintObjects,
ByteData paintData,
int pointMode,
Float32List points) native 'Canvas_drawPoints';
Expand Down Expand Up @@ -4711,7 +4715,7 @@ class Canvas extends NativeFieldWrapperClass1 {
}
void _drawVertices(Vertices vertices,
int blendMode,
List<dynamic>? paintObjects,
List<Object?>? paintObjects,
ByteData paintData) native 'Canvas_drawVertices';

/// Draws many parts of an image - the [atlas] - onto the canvas.
Expand Down Expand Up @@ -5060,7 +5064,7 @@ class Canvas extends NativeFieldWrapperClass1 {
);
}

void _drawAtlas(List<dynamic>? paintObjects,
void _drawAtlas(List<Object?>? paintObjects,
ByteData paintData,
int filterQualityIndex,
_Image atlas,
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -866,20 +866,20 @@ class PlatformDispatcher {

// Called from the engine, via hooks.dart
void _updateUserSettingsData(String jsonData) {
final Map<String, dynamic> data = json.decode(jsonData) as Map<String, dynamic>;
final Map<String, Object?> data = json.decode(jsonData) as Map<String, Object?>;
if (data.isEmpty) {
return;
}

final double textScaleFactor = (data['textScaleFactor'] as num).toDouble();
final bool alwaysUse24HourFormat = data['alwaysUse24HourFormat'] as bool;
final double textScaleFactor = (data['textScaleFactor']! as num).toDouble();
final bool alwaysUse24HourFormat = data['alwaysUse24HourFormat']! as bool;
// This field is optional.
final bool? brieflyShowPassword = data['brieflyShowPassword'] as bool?;
if (brieflyShowPassword != null) {
_brieflyShowPassword = brieflyShowPassword;
}
final Brightness platformBrightness =
data['platformBrightness'] as String == 'dark' ? Brightness.dark : Brightness.light;
data['platformBrightness']! as String == 'dark' ? Brightness.dark : Brightness.light;
final PlatformConfiguration previousConfiguration = configuration;
final bool platformBrightnessChanged =
previousConfiguration.platformBrightness != platformBrightness;
Expand Down
10 changes: 5 additions & 5 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2823,7 +2823,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass1 {
Int32List encoded,
ByteData? strutData,
String? fontFamily,
List<dynamic>? strutFontFamily,
List<Object?>? strutFontFamily,
double? fontSize,
double? height,
String? ellipsis,
Expand Down Expand Up @@ -2888,16 +2888,16 @@ class ParagraphBuilder extends NativeFieldWrapperClass1 {

void _pushStyle(
Int32List encoded,
List<dynamic> fontFamilies,
List<Object?> fontFamilies,
double? fontSize,
double? letterSpacing,
double? wordSpacing,
double? height,
double? decorationThickness,
String locale,
List<dynamic>? backgroundObjects,
List<Object?>? backgroundObjects,
ByteData? backgroundData,
List<dynamic>? foregroundObjects,
List<Object?>? foregroundObjects,
ByteData? foregroundData,
ByteData shadowsData,
ByteData? fontFeaturesData,
Expand Down Expand Up @@ -3015,7 +3015,7 @@ Future<void> loadFontFromList(Uint8List list, {String? fontFamily}) {
}

final ByteData _fontChangeMessage = utf8.encoder.convert(
json.encode(<String, dynamic>{'type': 'fontsChange'})
json.encode(<String, Object?>{'type': 'fontsChange'})
).buffer.asByteData();

FutureOr<void> _sendFontChangeMessage() async {
Expand Down

0 comments on commit 3b3b101

Please sign in to comment.