Skip to content

Commit

Permalink
Remove unnecessary exceptions from analysis_options.yaml (flutter#35054)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored Aug 2, 2022
1 parent eb2b57b commit d9a6777
Show file tree
Hide file tree
Showing 96 changed files with 982 additions and 1,010 deletions.
12 changes: 2 additions & 10 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ analyzer:
strict-casts: true
strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODO comments in the code
todo: ignore
# allow dart:ui to import dart:_internal
import_internal_library: ignore # DIFFERENT FROM FLUTTER/FLUTTER
# allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore
Expand Down Expand Up @@ -150,7 +142,7 @@ linter:
# - prefer_double_quotes # opposite of prefer_single_quotes
- prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
# - prefer_final_fields # DIFFERENT FROM FLUTTER/FLUTTER (we do weird things with private fields, especially on the PlatformDispatcher object)
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
# - prefer_final_parameters # we should enable this one day when it can be auto-fixed (https://github.com/dart-lang/linter/issues/3104), see also parameter_assignments
Expand Down Expand Up @@ -185,7 +177,7 @@ linter:
# - sized_box_shrink_expand # not yet tested
- slash_for_doc_comments
- sort_child_properties_last
# - sort_constructors_first # DIFFERENT FROM FLUTTER/FLUTTER (we have private fake constructors)
- sort_constructors_first
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/compositing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
//
// The key is the layer used. The value is the description of what the layer
// is used for, e.g. "pushOpacity" or "addRetained".
Map<EngineLayer, String> _usedLayers = <EngineLayer, String>{};
final Map<EngineLayer, String> _usedLayers = <EngineLayer, String>{};

// In debug mode checks that the `layer` is only used once in a given scene.
bool _debugCheckUsedOnce(EngineLayer layer, String usage) {
Expand Down
162 changes: 82 additions & 80 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,14 @@ enum Clip {
/// Most APIs on [Canvas] take a [Paint] object to describe the style
/// to use for that operation.
class Paint {
/// Constructs an empty [Paint] object with all fields initialized to
/// their defaults.
Paint() {
if (enableDithering) {
_dither = true;
}
}

// Paint objects are encoded in two buffers:
//
// * _data is binary data in four-byte fields, each of which is either a
Expand Down Expand Up @@ -1150,14 +1158,6 @@ class Paint {
static const int _kImageFilterIndex = 2;
static const int _kObjectCount = 3; // Must be one larger than the largest index.

/// Constructs an empty [Paint] object with all fields initialized to
/// their defaults.
Paint() {
if (enableDithering) {
_dither = true;
}
}

/// Whether to apply anti-aliasing to lines and images drawn on the
/// canvas.
///
Expand Down Expand Up @@ -1878,7 +1878,7 @@ class _Image extends NativeFieldWrapperClass1 {
@FfiNative<Void Function(Pointer<Void>)>('Image::dispose')
external void _dispose();

Set<Image> _handles = <Image>{};
final Set<Image> _handles = <Image>{};

@override
String toString() => '[$width\u00D7$height]';
Expand Down Expand Up @@ -2350,9 +2350,6 @@ class Path extends NativeFieldWrapperClass1 {
@pragma('vm:entry-point')
Path() { _constructor(); }

@FfiNative<Void Function(Handle)>('Path::Create')
external void _constructor();

/// Avoids creating a new native backing for the path for methods that will
/// create it later, such as [Path.from], [shift] and [transform].
Path._();
Expand All @@ -2367,6 +2364,9 @@ class Path extends NativeFieldWrapperClass1 {
return clonedPath;
}

@FfiNative<Void Function(Handle)>('Path::Create')
external void _constructor();

@FfiNative<Void Function(Pointer<Void>, Handle)>('Path::clone')
external void _clone(Path outPath);

Expand Down Expand Up @@ -2848,7 +2848,7 @@ class PathMetricIterator implements Iterator<PathMetric> {
PathMetricIterator._(this._pathMeasure) : assert(_pathMeasure != null);

PathMetric? _pathMetric;
_PathMeasure _pathMeasure;
final _PathMeasure _pathMeasure;

@override
PathMetric get current {
Expand Down Expand Up @@ -3576,9 +3576,6 @@ class _ComposeImageFilter implements ImageFilter {
/// ImageFilter, because we want ImageFilter to be efficiently comparable, so that
/// widgets can check for ImageFilter equality to avoid repainting.
class _ImageFilter extends NativeFieldWrapperClass1 {
@FfiNative<Void Function(Handle)>('ImageFilter::Create')
external void _constructor();

/// Creates an image filter that applies a Gaussian blur.
_ImageFilter.blur(_GaussianBlurImageFilter filter)
: assert(filter != null),
Expand All @@ -3587,9 +3584,6 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
_initBlur(filter.sigmaX, filter.sigmaY, filter.tileMode.index);
}

@FfiNative<Void Function(Pointer<Void>, Double, Double, Int32)>('ImageFilter::initBlur', isLeaf: true)
external void _initBlur(double sigmaX, double sigmaY, int tileMode);

/// Creates an image filter that dilates each input pixel's channel values
/// to the max value within the given radii along the x and y axes.
_ImageFilter.dilate(_DilateImageFilter filter)
Expand All @@ -3598,8 +3592,6 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
_constructor();
_initDilate(filter.radiusX, filter.radiusY);
}
@FfiNative<Void Function(Pointer<Void>, Double, Double)>('ImageFilter::initDilate', isLeaf: true)
external void _initDilate(double radiusX, double radiusY);

/// Create a filter that erodes each input pixel's channel values
/// to the minimum channel value within the given radii along the x and y axes.
Expand All @@ -3609,8 +3601,6 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
_constructor();
_initErode(filter.radiusX, filter.radiusY);
}
@FfiNative<Void Function(Pointer<Void>, Double, Double)>('ImageFilter::initErode', isLeaf: true)
external void _initErode(double radiusX, double radiusY);

/// Creates an image filter that applies a matrix transformation.
///
Expand All @@ -3626,9 +3616,6 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
_initMatrix(filter.data, filter.filterQuality.index);
}

@FfiNative<Void Function(Pointer<Void>, Handle, Int32)>('ImageFilter::initMatrix')
external void _initMatrix(Float64List matrix4, int filterQuality);

/// Converts a color filter to an image filter.
_ImageFilter.fromColorFilter(ColorFilter filter)
: assert(filter != null),
Expand All @@ -3638,9 +3625,6 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
_initColorFilter(nativeFilter);
}

@FfiNative<Void Function(Pointer<Void>, Pointer<Void>)>('ImageFilter::initColorFilter')
external void _initColorFilter(_ColorFilter? colorFilter);

/// Composes `_innerFilter` with `_outerFilter`.
_ImageFilter.composed(_ComposeImageFilter filter)
: assert(filter != null),
Expand All @@ -3651,6 +3635,24 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
_initComposed(nativeFilterOuter, nativeFilterInner);
}

@FfiNative<Void Function(Handle)>('ImageFilter::Create')
external void _constructor();

@FfiNative<Void Function(Pointer<Void>, Double, Double, Int32)>('ImageFilter::initBlur', isLeaf: true)
external void _initBlur(double sigmaX, double sigmaY, int tileMode);

@FfiNative<Void Function(Pointer<Void>, Double, Double)>('ImageFilter::initDilate', isLeaf: true)
external void _initDilate(double radiusX, double radiusY);

@FfiNative<Void Function(Pointer<Void>, Double, Double)>('ImageFilter::initErode', isLeaf: true)
external void _initErode(double radiusX, double radiusY);

@FfiNative<Void Function(Pointer<Void>, Handle, Int32)>('ImageFilter::initMatrix')
external void _initMatrix(Float64List matrix4, int filterQuality);

@FfiNative<Void Function(Pointer<Void>, Pointer<Void>)>('ImageFilter::initColorFilter')
external void _initColorFilter(_ColorFilter? colorFilter);

@FfiNative<Void Function(Pointer<Void>, Pointer<Void>, Pointer<Void>)>('ImageFilter::initComposeFilter')
external void _initComposed(_ImageFilter outerFilter, _ImageFilter innerFilter);

Expand Down Expand Up @@ -3803,9 +3805,6 @@ Float32List _encodeTwoPoints(Offset pointA, Offset pointB) {
/// * [Gradient](https://api.flutter.dev/flutter/painting/Gradient-class.html), the class in the [painting] library.
///
class Gradient extends Shader {
@FfiNative<Void Function(Handle)>('Gradient::Create')
external void _constructor();

/// Creates a linear gradient from `from` to `to`.
///
/// If `colorStops` is provided, `colorStops[i]` is a number from 0.0 to 1.0
Expand Down Expand Up @@ -3849,9 +3848,6 @@ class Gradient extends Shader {
_initLinear(endPointsBuffer, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
}

@FfiNative<Void Function(Pointer<Void>, Handle, Handle, Handle, Int32, Handle)>('Gradient::initLinear')
external void _initLinear(Float32List endPoints, Int32List colors, Float32List? colorStops, int tileMode, Float64List? matrix4);

/// Creates a radial gradient centered at `center` that ends at `radius`
/// distance from the center.
///
Expand Down Expand Up @@ -3912,30 +3908,6 @@ class Gradient extends Shader {
}
}

@FfiNative<Void Function(Pointer<Void>, Double, Double, Double, Handle, Handle, Int32, Handle)>('Gradient::initRadial')
external void _initRadial(
double centerX,
double centerY,
double radius,
Int32List colors,
Float32List? colorStops,
int tileMode,
Float64List? matrix4);

@FfiNative<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Double, Handle, Handle, Int32, Handle)>(
'Gradient::initTwoPointConical')
external void _initConical(
double startX,
double startY,
double startRadius,
double endX,
double endY,
double endRadius,
Int32List colors,
Float32List? colorStops,
int tileMode,
Float64List? matrix4);

/// Creates a sweep gradient centered at `center` that starts at `startAngle`
/// and ends at `endAngle`.
///
Expand Down Expand Up @@ -3986,6 +3958,36 @@ class Gradient extends Shader {
_initSweep(center.dx, center.dy, colorsBuffer, colorStopsBuffer, tileMode.index, startAngle, endAngle, matrix4);
}

@FfiNative<Void Function(Handle)>('Gradient::Create')
external void _constructor();

@FfiNative<Void Function(Pointer<Void>, Handle, Handle, Handle, Int32, Handle)>('Gradient::initLinear')
external void _initLinear(Float32List endPoints, Int32List colors, Float32List? colorStops, int tileMode, Float64List? matrix4);

@FfiNative<Void Function(Pointer<Void>, Double, Double, Double, Handle, Handle, Int32, Handle)>('Gradient::initRadial')
external void _initRadial(
double centerX,
double centerY,
double radius,
Int32List colors,
Float32List? colorStops,
int tileMode,
Float64List? matrix4);

@FfiNative<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Double, Handle, Handle, Int32, Handle)>(
'Gradient::initTwoPointConical')
external void _initConical(
double startX,
double startY,
double startRadius,
double endX,
double endY,
double endRadius,
Int32List colors,
Float32List? colorStops,
int tileMode,
Float64List? matrix4);

@FfiNative<Void Function(Pointer<Void>, Double, Double, Handle, Handle, Int32, Double, Double, Handle)>('Gradient::initSweep')
external void _initSweep(
double centerX,
Expand Down Expand Up @@ -4054,6 +4056,15 @@ class ImageShader extends Shader {
/// [A current specification of valid SPIR-V is here.](https://github.com/flutter/engine/blob/main/lib/spirv/README.md)
///
class FragmentProgram extends NativeFieldWrapperClass1 {
@pragma('vm:entry-point')
FragmentProgram._fromAsset(String assetKey) {
_constructor();
final String result = _initFromAsset(assetKey);
if (result.isNotEmpty) {
throw result; // ignore: only_throw_errors
}
}

// TODO(zra): Document custom shaders on the website and add a link to it
// here. https://github.com/flutter/flutter/issues/107929.
/// Creates a fragment program from the asset with key [assetKey].
Expand All @@ -4078,18 +4089,9 @@ class FragmentProgram extends NativeFieldWrapperClass1 {
// so that the case where an in-use program is requested again can be fast,
// but programs that are no longer referenced are not retained because of the
// cache.
static Map<String, WeakReference<FragmentProgram>> _shaderRegistry =
static final Map<String, WeakReference<FragmentProgram>> _shaderRegistry =
<String, WeakReference<FragmentProgram>>{};

@pragma('vm:entry-point')
FragmentProgram._fromAsset(String assetKey) {
_constructor();
final String result = _initFromAsset(assetKey);
if (result.isNotEmpty) {
throw result; // ignore: only_throw_errors
}
}

static void _reinitializeShader(String assetKey) {
// If a shader for the assent isn't already registered, then there's no
// need to reinitialize it. The new shader will be loaded and initialized
Expand Down Expand Up @@ -6010,17 +6012,6 @@ class ImmutableBuffer extends NativeFieldWrapperClass1 {
class ImageDescriptor extends NativeFieldWrapperClass1 {
ImageDescriptor._();

/// Creates an image descriptor from encoded data in a supported format.
static Future<ImageDescriptor> encoded(ImmutableBuffer buffer) {
final ImageDescriptor descriptor = ImageDescriptor._();
return _futurize((_Callback<void> callback) {
return descriptor._initEncoded(buffer, callback);
}).then((_) => descriptor);
}

@FfiNative<Handle Function(Handle, Pointer<Void>, Handle)>('ImageDescriptor::initEncoded')
external String? _initEncoded(ImmutableBuffer buffer, _Callback<void> callback);

/// Creates an image descriptor from raw image pixels.
///
/// The `pixels` parameter is the pixel data. They are packed in bytes in the
Expand All @@ -6045,6 +6036,17 @@ class ImageDescriptor extends NativeFieldWrapperClass1 {
_initRaw(this, buffer, width, height, rowBytes ?? -1, pixelFormat.index);
}

/// Creates an image descriptor from encoded data in a supported format.
static Future<ImageDescriptor> encoded(ImmutableBuffer buffer) {
final ImageDescriptor descriptor = ImageDescriptor._();
return _futurize((_Callback<void> callback) {
return descriptor._initEncoded(buffer, callback);
}).then((_) => descriptor);
}

@FfiNative<Handle Function(Handle, Pointer<Void>, Handle)>('ImageDescriptor::initEncoded')
external String? _initEncoded(ImmutableBuffer buffer, _Callback<void> callback);

@FfiNative<Void Function(Handle, Handle, Int32, Int32, Int32, Int32)>('ImageDescriptor::initRaw')
external static void _initRaw(ImageDescriptor outDescriptor, ImmutableBuffer buffer, int width, int height, int rowBytes, int pixelFormat);

Expand Down
11 changes: 5 additions & 6 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class PlatformDispatcher {
///
/// If any of their configurations change, [onMetricsChanged] will be called.
Iterable<FlutterView> get views => _views.values;
Map<Object, FlutterView> _views = <Object, FlutterView>{};
final Map<Object, FlutterView> _views = <Object, FlutterView>{};

// A map of opaque platform view identifiers to view configurations.
Map<Object, ViewConfiguration> _viewConfigurations = <Object, ViewConfiguration>{};
final Map<Object, ViewConfiguration> _viewConfigurations = <Object, ViewConfiguration>{};

/// A callback that is invoked whenever the [ViewConfiguration] of any of the
/// [views] changes.
Expand Down Expand Up @@ -1454,17 +1454,16 @@ class FrameTiming {
]);
}

static final int _dataLength = FramePhase.values.length + _FrameTimingInfo.values.length;

/// Construct [FrameTiming] with raw timestamps in microseconds.
///
/// List [timestamps] must have the same number of elements as
/// [FramePhase.values].
///
/// This constructor is usually only called by the Flutter engine, or a test.
/// To get the [FrameTiming] of your app, see [PlatformDispatcher.onReportTimings].
FrameTiming._(this._data)
: assert(_data.length == _dataLength);
FrameTiming._(this._data) : assert(_data.length == _dataLength);

static final int _dataLength = FramePhase.values.length + _FrameTimingInfo.values.length;

/// This is a raw timestamp in microseconds from some epoch. The epoch in all
/// [FrameTiming] is the same, but it may not match [DateTime]'s epoch.
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/plugins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class PluginUtilities {
// extended directly.
factory PluginUtilities._() => throw UnsupportedError('Namespace');

static Map<Function, CallbackHandle?> _forwardCache =
static final Map<Function, CallbackHandle?> _forwardCache =
<Function, CallbackHandle?>{};
static Map<CallbackHandle, Function?> _backwardCache =
static final Map<CallbackHandle, Function?> _backwardCache =
<CallbackHandle, Function?>{};

/// Get a handle to a named top-level or static callback function which can
Expand Down
Loading

0 comments on commit d9a6777

Please sign in to comment.