Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit a96e654

Browse files
committed
[Cupertino] Fix warnings
1 parent 42917e4 commit a96e654

File tree

7 files changed

+31
-47
lines changed

7 files changed

+31
-47
lines changed

Runtime/cupertino/button.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public CupertinoButton(
3131
BorderRadius borderRadius = null,
3232
bool filled = false
3333
) : base(key: key) {
34-
D.assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
34+
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
3535
this._filled = filled;
3636
this.child = child;
3737
this.onPressed = onPressed;
@@ -53,7 +53,7 @@ public static CupertinoButton filled(
5353
float pressedOpacity = 0.1f,
5454
BorderRadius borderRadius = null
5555
) {
56-
D.assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
56+
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
5757
return new CupertinoButton(
5858
key: key,
5959
color: null,
@@ -202,12 +202,10 @@ public override Widget build(BuildContext context) {
202202
}
203203
},
204204
child: new ConstrainedBox(
205-
constraints: this.widget.minSize == null
206-
? new BoxConstraints()
207-
: new BoxConstraints(
208-
minWidth: this.widget.minSize,
209-
minHeight: this.widget.minSize
210-
),
205+
constraints: new BoxConstraints(
206+
minWidth: this.widget.minSize,
207+
minHeight: this.widget.minSize
208+
),
211209
child: new FadeTransition(
212210
opacity: this._opacityAnimation,
213211
child: new DecoratedBox(

Runtime/cupertino/nav_bar.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static bool _isTransitionable(BuildContext context) {
100100
BuildContext toHeroContext
101101
) => {
102102
D.assert(animation != null);
103-
D.assert(flightDirection != null);
103+
104104
D.assert(fromHeroContext != null);
105105
D.assert(toHeroContext != null);
106106
D.assert(fromHeroContext.widget is Hero);
@@ -130,7 +130,6 @@ BuildContext toHeroContext
130130
bottomNavBar: fromNavBar,
131131
topNavBar: toNavBar
132132
);
133-
break;
134133
case HeroFlightDirection.pop:
135134
return new _NavigationBarTransition(
136135
animation: animation,
@@ -351,7 +350,7 @@ public override Widget build(BuildContext context) {
351350
new Builder(
352351
builder: (BuildContext _context) => {
353352
return new Hero(
354-
tag: this.widget.heroTag == NavBarUtils._defaultHeroTag
353+
tag: this.widget.heroTag as _HeroTag == NavBarUtils._defaultHeroTag
355354
? new _HeroTag(Navigator.of(_context))
356355
: this.widget.heroTag,
357356
createRectTween: NavBarUtils._linearTranslateWithLargestRectSizeTween,
@@ -393,8 +392,6 @@ public CupertinoSliverNavigationBar(
393392
bool transitionBetweenRoutes = true,
394393
object heroTag = null
395394
) : base(key: key) {
396-
D.assert(automaticallyImplyLeading != null);
397-
D.assert(automaticallyImplyTitle != null);
398395
D.assert(
399396
automaticallyImplyTitle == true || largeTitle != null,
400397
() => "No largeTitle has been provided but automaticallyImplyTitle is also " +
@@ -516,9 +513,6 @@ public _LargeTitleNavigationBarSliverDelegate(
516513
float persistentHeight,
517514
bool alwaysShowMiddle
518515
) {
519-
D.assert(this.persistentHeight != null);
520-
D.assert(this.alwaysShowMiddle != null);
521-
D.assert(this.transitionBetweenRoutes != null);
522516
this.keys = keys;
523517
this.components = components;
524518
this.userMiddle = userMiddle;
@@ -621,7 +615,7 @@ public override Widget build(BuildContext context, float shrinkOffset, bool over
621615
}
622616

623617
return new Hero(
624-
tag: this.heroTag == NavBarUtils._defaultHeroTag
618+
tag: this.heroTag as _HeroTag == NavBarUtils._defaultHeroTag
625619
? new _HeroTag(Navigator.of(context))
626620
: this.heroTag,
627621
createRectTween: NavBarUtils._linearTranslateWithLargestRectSizeTween,
@@ -682,13 +676,11 @@ public override Widget build(BuildContext context) {
682676
style: CupertinoTheme.of(context).textTheme.navTitleTextStyle,
683677
child: middle
684678
);
685-
middle = this.middleVisible == null
686-
? middle
687-
: new AnimatedOpacity(
688-
opacity: this.middleVisible ? 1.0f : 0.0f,
689-
duration: NavBarUtils._kNavBarTitleFadeDuration,
690-
child: middle
691-
);
679+
middle = new AnimatedOpacity(
680+
opacity: this.middleVisible ? 1.0f : 0.0f,
681+
duration: NavBarUtils._kNavBarTitleFadeDuration,
682+
child: middle
683+
);
692684
}
693685

694686
Widget leading = this.components.leading;
@@ -1247,6 +1239,9 @@ public _NavigationBarTransition(
12471239
_TransitionableNavigationBar topNavBar,
12481240
_TransitionableNavigationBar bottomNavBar
12491241
) {
1242+
this.animation = animation;
1243+
this.topNavBar = topNavBar;
1244+
this.bottomNavBar = bottomNavBar;
12501245
this.heightTween = new FloatTween(
12511246
begin: this.bottomNavBar.renderBox.size.height,
12521247
end: this.topNavBar.renderBox.size.height
@@ -1325,6 +1320,7 @@ public _NavigationBarComponentsTransition(
13251320
_TransitionableNavigationBar topNavBar,
13261321
TextDirection directionality
13271322
) {
1323+
this.animation = animation;
13281324
this.bottomComponents = bottomNavBar.componentsKeys;
13291325
this.topComponents = topNavBar.componentsKeys;
13301326
this.bottomNavBarBox = bottomNavBar.renderBox;

Runtime/cupertino/page_scaffold.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public CupertinoPageScaffold(
1717
bool resizeToAvoidBottomInset = true
1818
) : base(key: key) {
1919
D.assert(child != null);
20-
D.assert(resizeToAvoidBottomInset != null);
2120

2221
this.child = child;
2322
this.navigationBar = navigationBar;

Runtime/cupertino/route.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ static _CupertinoEdgeShadowDecoration lerp(
133133
_CupertinoEdgeShadowDecoration b,
134134
float t
135135
) {
136-
D.assert(t != null);
137136
if (a == null && b == null) {
138137
return null;
139138
}
@@ -163,6 +162,10 @@ public override BoxPainter createBoxPainter(VoidCallback onChanged = null) {
163162
return new _CupertinoEdgeShadowPainter(this, onChanged);
164163
}
165164

165+
public override int GetHashCode() {
166+
return this.edgeGradient.GetHashCode();
167+
}
168+
166169
public bool Equals(_CupertinoEdgeShadowDecoration other) {
167170
if (ReferenceEquals(null, other)) {
168171
return false;
@@ -244,8 +247,6 @@ public CupertinoPageRoute(
244247
) :
245248
base(settings: settings, fullscreenDialog: fullscreenDialog) {
246249
D.assert(builder != null);
247-
D.assert(maintainState != null);
248-
D.assert(fullscreenDialog != null);
249250
D.assert(this.opaque);
250251
this.builder = builder;
251252
this.title = title;
@@ -409,7 +410,7 @@ public override Widget buildTransitions(BuildContext context, Animation<float> a
409410
return buildPageTransitions(this, context, animation, secondaryAnimation, child);
410411
}
411412

412-
public string debugLabel {
413+
public new string debugLabel {
413414
get { return $"{base.debugLabel}(${this.settings.name})"; }
414415
}
415416
}
@@ -422,7 +423,6 @@ public CupertinoPageTransition(
422423
bool linearTransition,
423424
Key key = null
424425
) : base(key: key) {
425-
D.assert(linearTransition != null);
426426
this._primaryPositionAnimation =
427427
(linearTransition
428428
? primaryRouteAnimation
@@ -717,11 +717,10 @@ public override TimeSpan transitionDuration {
717717
get { return CupertinoRouteUtils._kModalPopupTransitionDuration; }
718718
}
719719

720-
Animation<float> _animation;
720+
new Animation<float> _animation;
721721

722722
Tween<Offset> _offsetTween;
723723

724-
725724
public override Animation<float> createAnimation() {
726725
D.assert(this._animation == null);
727726
this._animation = new CurvedAnimation(

Runtime/cupertino/slider.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public CupertinoSlider(
3535
) : base(key: key) {
3636
D.assert(value != null);
3737
D.assert(onChanged != null);
38-
D.assert(min != null);
39-
D.assert(max != null);
4038
D.assert(value >= min && value <= max);
4139
D.assert(divisions == null || divisions > 0);
4240
this.value = value.Value;
@@ -171,7 +169,7 @@ public _RenderCupertinoSlider(
171169
TickerProvider vsync = null
172170
) : base(additionalConstraints: BoxConstraints.tightFor(width: SliderUtils._kSliderWidth,
173171
height: SliderUtils._kSliderHeight)) {
174-
D.assert(value != null && value >= 0.0f && value <= 1.0f);
172+
D.assert(value >= 0.0f && value <= 1.0f);
175173
this._value = value;
176174
this._divisions = divisions;
177175
this._activeColor = activeColor;
@@ -191,7 +189,7 @@ public _RenderCupertinoSlider(
191189
public float value {
192190
get { return this._value; }
193191
set {
194-
D.assert(value != null && value >= 0.0f && value <= 1.0f);
192+
D.assert(value >= 0.0f && value <= 1.0f);
195193
if (value == this._value) {
196194
return;
197195
}

Runtime/cupertino/switch.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ public CupertinoSwitch(
3434
Key key = null,
3535
Color activeColor = null,
3636
DragStartBehavior dragStartBehavior = DragStartBehavior.start
37-
) :
38-
base(key: key) {
39-
D.assert(value != null);
40-
D.assert(dragStartBehavior != null);
41-
37+
) : base(key: key) {
4238
this.value = value;
4339
this.onChanged = onChanged;
4440
this.activeColor = activeColor;
@@ -136,7 +132,6 @@ public _RenderCupertinoSwitch(
136132
width: CupertinoSwitchUtils._kSwitchWidth,
137133
height: CupertinoSwitchUtils._kSwitchHeight)
138134
) {
139-
D.assert(value != null);
140135
D.assert(activeColor != null);
141136
D.assert(vsync != null);
142137
this._value = value;
@@ -190,7 +185,6 @@ public _RenderCupertinoSwitch(
190185
public bool value {
191186
get { return this._value; }
192187
set {
193-
D.assert(value != null);
194188
if (value == this._value) {
195189
return;
196190
}
@@ -261,7 +255,6 @@ public ValueChanged<bool> onChanged {
261255
public TextDirection textDirection {
262256
get { return this._textDirection; }
263257
set {
264-
D.assert(value != null);
265258
if (this._textDirection == value) {
266259
return;
267260
}
@@ -277,7 +270,6 @@ public TextDirection textDirection {
277270
public DragStartBehavior dragStartBehavior {
278271
get { return this._drag.dragStartBehavior; }
279272
set {
280-
D.assert(value != null);
281273
if (this._drag.dragStartBehavior == value) {
282274
return;
283275
}

Runtime/cupertino/tab_scaffold.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ public _TabSwitchingView(
137137
int tabNumber,
138138
IndexedWidgetBuilder tabBuilder
139139
) {
140-
D.assert(currentTabIndex != null);
141-
D.assert(tabNumber != null && tabNumber > 0);
140+
D.assert(tabNumber > 0);
142141
D.assert(tabBuilder != null);
142+
this.currentTabIndex = currentTabIndex;
143+
this.tabNumber = tabNumber;
144+
this.tabBuilder = tabBuilder;
143145
}
144146

145147
public readonly int currentTabIndex;

0 commit comments

Comments
 (0)