Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 98c18ca

Browse files
authored
Remove unnecessary null checks in examples/ (#118848)
1 parent 54217bd commit 98c18ca

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

examples/layers/rendering/src/sector_layout.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ abstract class RenderSector extends RenderObject {
110110

111111
@override
112112
void debugAssertDoesMeetConstraints() {
113-
assert(constraints != null);
114-
assert(deltaRadius != null);
115113
assert(deltaRadius < double.infinity);
116-
assert(deltaTheta != null);
117114
assert(deltaTheta < double.infinity);
118115
assert(constraints.minDeltaRadius <= deltaRadius);
119116
assert(deltaRadius <= math.max(constraints.minDeltaRadius, constraints.maxDeltaRadius));
@@ -174,8 +171,6 @@ abstract class RenderDecoratedSector extends RenderSector {
174171
// offset must point to the center of the circle
175172
@override
176173
void paint(PaintingContext context, Offset offset) {
177-
assert(deltaRadius != null);
178-
assert(deltaTheta != null);
179174
assert(parentData is SectorParentData);
180175

181176
if (_decoration == null) {
@@ -242,7 +237,6 @@ class RenderSectorRing extends RenderSectorWithChildren {
242237
double _desiredDeltaRadius;
243238
double get desiredDeltaRadius => _desiredDeltaRadius;
244239
set desiredDeltaRadius(double value) {
245-
assert(value != null);
246240
assert(value >= 0);
247241
if (_desiredDeltaRadius != value) {
248242
_desiredDeltaRadius = value;
@@ -254,7 +248,6 @@ class RenderSectorRing extends RenderSectorWithChildren {
254248
double get padding => _padding;
255249
set padding(double value) {
256250
// TODO(ianh): avoid code duplication
257-
assert(value != null);
258251
if (_padding != value) {
259252
_padding = value;
260253
markNeedsLayout();
@@ -360,7 +353,6 @@ class RenderSectorSlice extends RenderSectorWithChildren {
360353
double _desiredDeltaTheta;
361354
double get desiredDeltaTheta => _desiredDeltaTheta;
362355
set desiredDeltaTheta(double value) {
363-
assert(value != null);
364356
if (_desiredDeltaTheta != value) {
365357
_desiredDeltaTheta = value;
366358
markNeedsLayout();
@@ -371,7 +363,6 @@ class RenderSectorSlice extends RenderSectorWithChildren {
371363
double get padding => _padding;
372364
set padding(double value) {
373365
// TODO(ianh): avoid code duplication
374-
assert(value != null);
375366
if (_padding != value) {
376367
_padding = value;
377368
markNeedsLayout();
@@ -519,8 +510,6 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
519510
}) {
520511
assert(child is RenderSector);
521512
assert(child!.parentData is SectorParentData);
522-
assert(width != null);
523-
assert(height != null);
524513
if (!width.isFinite && !height.isFinite) {
525514
return Size.zero;
526515
}
@@ -649,9 +638,7 @@ class SectorHitTestEntry extends HitTestEntry {
649638
/// Creates a box hit test entry.
650639
///
651640
/// The [radius] and [theta] argument must not be null.
652-
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta })
653-
: assert(radius != null),
654-
assert(theta != null);
641+
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta });
655642

656643
@override
657644
RenderSector get target => super.target as RenderSector;

examples/layers/services/isolate.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ typedef OnResultListener = void Function(String result);
1717
// in real-world applications.
1818
class Calculator {
1919
Calculator({ required this.onProgressListener, required this.onResultListener, String? data })
20-
: assert(onProgressListener != null),
21-
assert(onResultListener != null),
22-
// In order to keep the example files smaller, we "cheat" a little and
23-
// replicate our small json string into a 10,000-element array.
24-
_data = _replicateJson(data, 10000);
20+
: _data = _replicateJson(data, 10000);
2521

2622
final OnProgressListener onProgressListener;
2723
final OnResultListener onResultListener;
@@ -87,9 +83,7 @@ class CalculationMessage {
8783
// progress of the background computation.
8884
class CalculationManager {
8985
CalculationManager({ required this.onProgressListener, required this.onResultListener })
90-
: assert(onProgressListener != null),
91-
assert(onResultListener != null),
92-
_receivePort = ReceivePort() {
86+
: _receivePort = ReceivePort() {
9387
_receivePort.listen(_handleMessage);
9488
}
9589

0 commit comments

Comments
 (0)