Check if the canvas bounds rect contains infinite or NaN values (flutter/engine#3339)
See https://github.com/flutter/flutter/issues/7431
This commit is contained in:
@@ -580,6 +580,9 @@ class Rect {
|
||||
/// Negative areas are considered empty.
|
||||
bool get isEmpty => left >= right || top >= bottom;
|
||||
|
||||
/// Whether all coordinates of this rectangle are finite.
|
||||
bool get isFinite => left.isFinite && top.isFinite && right.isFinite && bottom.isFinite;
|
||||
|
||||
/// The lesser of the magnitudes of the width and the height of this
|
||||
/// rectangle.
|
||||
double get shortestSide {
|
||||
|
||||
@@ -1116,6 +1116,8 @@ class Canvas extends NativeFieldWrapperClass2 {
|
||||
throw new ArgumentError('The given PictureRecorder was null.');
|
||||
if (recorder.isRecording)
|
||||
throw new ArgumentError('The given PictureRecorder is already associated with another Canvas.');
|
||||
if (!cullRect.isFinite)
|
||||
throw new ArgumentError('The cullRect contains infinite or NaN coordinates.');
|
||||
// TODO(ianh): throw if recorder is defunct (https://github.com/flutter/flutter/issues/2531)
|
||||
_constructor(recorder, cullRect.left, cullRect.top, cullRect.right, cullRect.bottom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user