phase3: nullable fields/methods, casts, ?.call, condition fixes across 11 files. 108->72
This commit is contained in:
@@ -21,7 +21,7 @@ class AnimationPointManager {
|
||||
Offset endAdjustOffset = Offset.zero,
|
||||
}) async {
|
||||
controller1 = createController(vsync, duration);
|
||||
Animation animation = createAnimation(controller1);
|
||||
Animation<double> animation = createAnimation(controller1);
|
||||
|
||||
AnimatedWidget animatedWidget = ParabolicAnimationWidget(
|
||||
animation: animation!,
|
||||
@@ -34,7 +34,7 @@ class AnimationPointManager {
|
||||
endAdjustOffset: endAdjustOffset,
|
||||
);
|
||||
list.add(animatedWidget);
|
||||
statusListener(AnimationStatus.dismissed);
|
||||
statusListener?.call(AnimationStatus.dismissed);
|
||||
|
||||
try {
|
||||
await controller1.forward().orCancel;
|
||||
@@ -47,7 +47,7 @@ class AnimationPointManager {
|
||||
print('Error: $error');
|
||||
}
|
||||
|
||||
statusListener(AnimationStatus.completed);
|
||||
statusListener?.call(AnimationStatus.completed);
|
||||
}
|
||||
|
||||
Future<void> addPopupAniamtion({
|
||||
@@ -69,7 +69,7 @@ class AnimationPointManager {
|
||||
popupOffset: popupOffset,
|
||||
);
|
||||
list.add(animatedWidget);
|
||||
statusListener(AnimationStatus.dismissed);
|
||||
statusListener?.call(AnimationStatus.dismissed);
|
||||
|
||||
try {
|
||||
await controller2.forward().orCancel;
|
||||
@@ -83,7 +83,7 @@ class AnimationPointManager {
|
||||
print('Error: $error');
|
||||
}
|
||||
|
||||
statusListener(AnimationStatus.completed);
|
||||
statusListener?.call(AnimationStatus.completed);
|
||||
}
|
||||
|
||||
static AnimationController createController(
|
||||
|
||||
@@ -29,7 +29,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
Widget build(BuildContext context) {
|
||||
_calPoints();
|
||||
|
||||
final Animation<double> animation = listenable!;
|
||||
final Animation<double> animation = listenable! as Animation<double>;
|
||||
final double time = animation.value;
|
||||
|
||||
// 设time=1 已知两点坐标 和 初速度 可求出 加速度 a
|
||||
@@ -66,17 +66,17 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
|
||||
void _calPoints() {
|
||||
if (_startOffset == null) {
|
||||
RenderBox stackBox = stackKey.currentContext!.findRenderObject()!;
|
||||
RenderBox stackBox = stackKey.currentContext!.findRenderObject()! as RenderBox;
|
||||
Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero);
|
||||
|
||||
EdgeInsets startMargin = _margin(startKey);
|
||||
RenderBox startBox = startKey.currentContext!.findRenderObject()!;
|
||||
RenderBox startBox = startKey.currentContext!.findRenderObject()! as RenderBox;
|
||||
_startOffset = startBox.localToGlobal(Offset(
|
||||
startMargin.left + startAdjustOffset.dx,
|
||||
stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy));
|
||||
|
||||
EdgeInsets endMargin = _margin(endKey);
|
||||
RenderBox endBox = endKey.currentContext!.findRenderObject()!;
|
||||
RenderBox endBox = endKey.currentContext!.findRenderObject()! as RenderBox;
|
||||
_endOffset = endBox.localToGlobal(Offset(
|
||||
endMargin.left + endAdjustOffset.dx,
|
||||
stackBoxOffset.dy + endMargin.top + endAdjustOffset.dy));
|
||||
@@ -85,7 +85,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
|
||||
EdgeInsets _margin(GlobalKey key) {
|
||||
final Widget widget = key.currentContext!.widget;
|
||||
EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero;
|
||||
EdgeInsets margin = (widget is Container) ? (widget.margin ?? EdgeInsets.zero) : EdgeInsets.zero;
|
||||
return margin ?? EdgeInsets.zero;
|
||||
}
|
||||
}
|
||||
@@ -228,11 +228,11 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
duration: const Duration(milliseconds: 300),
|
||||
value: widget.defaultPanelState == PanelState.CLOSED ? 0.0 : 1.0 //set the default panel state (i.e. set initial value of _ac)
|
||||
)..addListener((){
|
||||
if(widget.onPanelSlide != null) widget.onPanelSlide(_ac.value);
|
||||
if(widget.onPanelSlide != null) widget.onPanelSlide?.call(_ac.value);
|
||||
|
||||
if(widget.onPanelOpened != null && _ac.value == 1.0) widget.onPanelOpened();
|
||||
if(widget.onPanelOpened != null && _ac.value == 1.0) widget.onPanelOpened?.call();
|
||||
|
||||
if(widget.onPanelClosed != null && _ac.value == 0.0) widget.onPanelClosed();
|
||||
if(widget.onPanelClosed != null && _ac.value == 0.0) widget.onPanelClosed?.call();
|
||||
});
|
||||
|
||||
// prevent the panel content from being scrolled only if the widget is
|
||||
@@ -326,7 +326,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
height: widget.maxHeight,
|
||||
child: widget.panel != null
|
||||
? widget.panel
|
||||
: widget.panelBuilder(_sc),
|
||||
: widget.panelBuilder!(_sc),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -391,7 +391,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
// this is because the listener is designed only for use with linking the scrolling of
|
||||
// panels and using it for panels that don't want to linked scrolling yields odd results
|
||||
Widget _gestureHandler({Widget? child}){
|
||||
if (!widget.isDraggable) return child;
|
||||
if (!widget.isDraggable) return child!;
|
||||
|
||||
if (widget.panel != null){
|
||||
return GestureDetector(
|
||||
|
||||
Reference in New Issue
Block a user