Use null-aware operators in package:sky
This commit is contained in:
parent
8df083df39
commit
52790aedf2
@ -50,7 +50,7 @@ void updateTaskDescription(String label, Color color) {
|
||||
|
||||
TaskDescription description = new TaskDescription()
|
||||
..label = label
|
||||
..primaryColor = (color != null ? color.value : null);
|
||||
..primaryColor = color?.value;
|
||||
|
||||
_activityProxy.ptr.setTaskDescription(description);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class OpacityLayer extends ContainerLayer {
|
||||
int alpha;
|
||||
|
||||
void addToScene(sky.SceneBuilder builder, Offset layerOffset) {
|
||||
builder.pushOpacity(alpha, bounds == null ? null : bounds.shift(layerOffset));
|
||||
builder.pushOpacity(alpha, bounds?.shift(layerOffset));
|
||||
addChildrenToScene(builder, offset + layerOffset);
|
||||
builder.pop();
|
||||
}
|
||||
|
@ -487,10 +487,7 @@ class Stack extends MultiChildRenderObjectWrapper {
|
||||
RenderStack get renderObject => super.renderObject;
|
||||
|
||||
void updateParentData(RenderObject child, Positioned positioned) {
|
||||
if (positioned == null)
|
||||
_updateParentDataWithValues(child, null, null, null, null);
|
||||
else
|
||||
_updateParentDataWithValues(child, positioned.top, positioned.right, positioned.bottom, positioned.left);
|
||||
_updateParentDataWithValues(child, positioned?.top, positioned?.right, positioned?.bottom, positioned?.left);
|
||||
}
|
||||
|
||||
void _updateParentDataWithValues(RenderObject child, double top, double right, double bottom, double left) {
|
||||
@ -592,7 +589,7 @@ class Flex extends MultiChildRenderObjectWrapper {
|
||||
}
|
||||
|
||||
void updateParentData(RenderObject child, Flexible flexible) {
|
||||
_updateParentDataWithValues(child, flexible == null ? null : flexible.flex);
|
||||
_updateParentDataWithValues(child, flexible?.flex);
|
||||
}
|
||||
|
||||
void _updateParentDataWithValues(RenderObject child, int flex) {
|
||||
|
@ -21,7 +21,7 @@ class DefaultTextStyle extends Inherited {
|
||||
|
||||
static TextStyle of(Widget widget) {
|
||||
DefaultTextStyle result = widget.inheritedOfType(DefaultTextStyle);
|
||||
return result == null ? null : result.style;
|
||||
return result?.style;
|
||||
}
|
||||
|
||||
bool syncShouldNotify(DefaultTextStyle old) => style != old.style;
|
||||
|
@ -498,7 +498,7 @@ abstract class TagNode extends Widget {
|
||||
}
|
||||
|
||||
void _sync(Widget old, dynamic slot) {
|
||||
Widget oldChild = old == null ? null : (old as TagNode).child;
|
||||
Widget oldChild = (old as TagNode)?.child;
|
||||
child = syncChild(child, oldChild, slot);
|
||||
if (child != null) {
|
||||
assert(child.parent == this);
|
||||
@ -1259,7 +1259,7 @@ abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper {
|
||||
|
||||
void syncRenderObject(RenderObjectWrapper old) {
|
||||
super.syncRenderObject(old);
|
||||
Widget oldChild = old == null ? null : (old as OneChildRenderObjectWrapper).child;
|
||||
Widget oldChild = (old as OneChildRenderObjectWrapper)?.child;
|
||||
Widget newChild = child;
|
||||
_child = syncChild(newChild, oldChild, null);
|
||||
assert((newChild == null && child == null) || (newChild != null && child.parent == this));
|
||||
@ -1304,7 +1304,7 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
|
||||
|
||||
void insertChildRenderObject(RenderObjectWrapper child, Widget slot) {
|
||||
final renderObject = this.renderObject; // TODO(ianh): Remove this once the analyzer is cleverer
|
||||
RenderObject nextSibling = slot != null ? slot.renderObject : null;
|
||||
RenderObject nextSibling = slot?.renderObject;
|
||||
assert(nextSibling == null || nextSibling is RenderObject);
|
||||
assert(renderObject is ContainerRenderObjectMixin);
|
||||
renderObject.add(child.renderObject, before: nextSibling);
|
||||
|
@ -65,7 +65,7 @@ class HomogeneousViewport extends RenderObjectWrapper {
|
||||
}
|
||||
|
||||
void insertChildRenderObject(RenderObjectWrapper child, Widget slot) {
|
||||
RenderObject nextSibling = slot != null ? slot.renderObject : null;
|
||||
RenderObject nextSibling = slot?.renderObject;
|
||||
renderObject.add(child.renderObject, before: nextSibling);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class IconTheme extends Inherited {
|
||||
|
||||
static IconThemeData of(Component component) {
|
||||
IconTheme result = component.inheritedOfType(IconTheme);
|
||||
return result == null ? null : result.data;
|
||||
return result?.data;
|
||||
}
|
||||
|
||||
bool syncShouldNotify(IconTheme old) => data != old.data;
|
||||
|
@ -208,7 +208,7 @@ class Scaffold extends RenderObjectWrapper {
|
||||
}
|
||||
|
||||
void insertChildRenderObject(RenderObjectWrapper child, ScaffoldSlots slot) {
|
||||
renderObject[slot] = child != null ? child.renderObject : null;
|
||||
renderObject[slot] = child?.renderObject;
|
||||
}
|
||||
|
||||
void detachChildRenderObject(RenderObjectWrapper child) {
|
||||
|
@ -11,8 +11,6 @@ import 'package:vector_math/vector_math.dart';
|
||||
|
||||
export 'package:sky/animation/direction.dart' show Direction;
|
||||
|
||||
dynamic _maybe(AnimatedValue x) => x != null ? x.value : null;
|
||||
|
||||
// A helper class to anchor widgets to one another. Pass an instance of this to
|
||||
// a Transition, then use the build() method to create a child with the same
|
||||
// transition applied.
|
||||
@ -270,7 +268,7 @@ class SquashTransition extends TransitionBase {
|
||||
performance.updateVariable(width);
|
||||
if (height != null)
|
||||
performance.updateVariable(height);
|
||||
return new SizedBox(width: _maybe(width), height: _maybe(height), child: child);
|
||||
return new SizedBox(width: width?.value, height: height?.value, child: child);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,4 +15,4 @@ dependencies:
|
||||
vector_math: ^1.4.3
|
||||
intl: ^0.12.4+2
|
||||
environment:
|
||||
sdk: '>=1.8.0 <2.0.0'
|
||||
sdk: '>=1.12.0 <2.0.0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user