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

Commit

Permalink
Remove unnecessary null checks in examples/ (#118848)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer committed Jan 20, 2023
1 parent 54217bd commit 98c18ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
15 changes: 1 addition & 14 deletions examples/layers/rendering/src/sector_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ abstract class RenderSector extends RenderObject {

@override
void debugAssertDoesMeetConstraints() {
assert(constraints != null);
assert(deltaRadius != null);
assert(deltaRadius < double.infinity);
assert(deltaTheta != null);
assert(deltaTheta < double.infinity);
assert(constraints.minDeltaRadius <= deltaRadius);
assert(deltaRadius <= math.max(constraints.minDeltaRadius, constraints.maxDeltaRadius));
Expand Down Expand Up @@ -174,8 +171,6 @@ abstract class RenderDecoratedSector extends RenderSector {
// offset must point to the center of the circle
@override
void paint(PaintingContext context, Offset offset) {
assert(deltaRadius != null);
assert(deltaTheta != null);
assert(parentData is SectorParentData);

if (_decoration == null) {
Expand Down Expand Up @@ -242,7 +237,6 @@ class RenderSectorRing extends RenderSectorWithChildren {
double _desiredDeltaRadius;
double get desiredDeltaRadius => _desiredDeltaRadius;
set desiredDeltaRadius(double value) {
assert(value != null);
assert(value >= 0);
if (_desiredDeltaRadius != value) {
_desiredDeltaRadius = value;
Expand All @@ -254,7 +248,6 @@ class RenderSectorRing extends RenderSectorWithChildren {
double get padding => _padding;
set padding(double value) {
// TODO(ianh): avoid code duplication
assert(value != null);
if (_padding != value) {
_padding = value;
markNeedsLayout();
Expand Down Expand Up @@ -360,7 +353,6 @@ class RenderSectorSlice extends RenderSectorWithChildren {
double _desiredDeltaTheta;
double get desiredDeltaTheta => _desiredDeltaTheta;
set desiredDeltaTheta(double value) {
assert(value != null);
if (_desiredDeltaTheta != value) {
_desiredDeltaTheta = value;
markNeedsLayout();
Expand All @@ -371,7 +363,6 @@ class RenderSectorSlice extends RenderSectorWithChildren {
double get padding => _padding;
set padding(double value) {
// TODO(ianh): avoid code duplication
assert(value != null);
if (_padding != value) {
_padding = value;
markNeedsLayout();
Expand Down Expand Up @@ -519,8 +510,6 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
}) {
assert(child is RenderSector);
assert(child!.parentData is SectorParentData);
assert(width != null);
assert(height != null);
if (!width.isFinite && !height.isFinite) {
return Size.zero;
}
Expand Down Expand Up @@ -649,9 +638,7 @@ class SectorHitTestEntry extends HitTestEntry {
/// Creates a box hit test entry.
///
/// The [radius] and [theta] argument must not be null.
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta })
: assert(radius != null),
assert(theta != null);
SectorHitTestEntry(RenderSector super.target, { required this.radius, required this.theta });

@override
RenderSector get target => super.target as RenderSector;
Expand Down
10 changes: 2 additions & 8 deletions examples/layers/services/isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ typedef OnResultListener = void Function(String result);
// in real-world applications.
class Calculator {
Calculator({ required this.onProgressListener, required this.onResultListener, String? data })
: assert(onProgressListener != null),
assert(onResultListener != null),
// In order to keep the example files smaller, we "cheat" a little and
// replicate our small json string into a 10,000-element array.
_data = _replicateJson(data, 10000);
: _data = _replicateJson(data, 10000);

final OnProgressListener onProgressListener;
final OnResultListener onResultListener;
Expand Down Expand Up @@ -87,9 +83,7 @@ class CalculationMessage {
// progress of the background computation.
class CalculationManager {
CalculationManager({ required this.onProgressListener, required this.onResultListener })
: assert(onProgressListener != null),
assert(onResultListener != null),
_receivePort = ReceivePort() {
: _receivePort = ReceivePort() {
_receivePort.listen(_handleMessage);
}

Expand Down

0 comments on commit 98c18ca

Please sign in to comment.