Jaime Blasco

fix: analyzer issues

... ... @@ -143,20 +143,27 @@ class BouncingSheetPhysics extends ScrollPhysics with SheetPhysics {
return true;
}());
if (!overflowViewport) {
// overscroll
if (position.viewportDimension <= position.pixels &&
position.pixels < value) // overscroll
position.pixels < value) {
return value - position.pixels;
}
// hit top edge
if (value < position.viewportDimension &&
position.viewportDimension < position.pixels) // hit top edge
position.viewportDimension < position.pixels) {
return value - position.viewportDimension;
}
}
// underscroll
if (value < position.pixels &&
position.pixels <= position.minScrollExtent) // underscroll
position.pixels <= position.minScrollExtent) {
return value - position.pixels;
}
// hit bottom edge
if (position.pixels < position.maxScrollExtent &&
position.maxScrollExtent < value) // hit bottom edge
position.maxScrollExtent < value) {
return value - position.maxScrollExtent;
}
return 0.0;
}
... ... @@ -227,26 +234,34 @@ class NoMomentumSheetPhysics extends ScrollPhysics with SheetPhysics {
@override
double applyBoundaryConditions(ScrollMetrics position, double value) {
// underscroll
if (value < position.pixels &&
position.pixels <= position.minScrollExtent) // underscroll
position.pixels <= position.minScrollExtent) {
return value - position.pixels;
}
if (position.maxScrollExtent <= position.pixels &&
position.pixels < value) // overscroll
position.pixels < value) {
// overscroll
return value - position.pixels;
}
if (value < position.minScrollExtent &&
position.minScrollExtent < position.pixels) // hit top edge
position.minScrollExtent < position.pixels) {
// hit top edge
return value - position.minScrollExtent;
}
if (position.pixels < position.maxScrollExtent &&
position.maxScrollExtent < value) // hit bottom edge
position.maxScrollExtent < value) {
// hit bottom edge
return value - position.maxScrollExtent;
}
return 0.0;
if (position.viewportDimension <= position.pixels &&
position.pixels < value) // hit top edge
return value - position.pixels;
if (position.pixels < 0 && position.pixels > value) // hit bottom edge
return value - position.pixels;
return 0.0;
// if (position.viewportDimension <= position.pixels &&
// position.pixels < value) // hit top edge
// return value - position.pixels;
// if (position.pixels < 0 && position.pixels > value) // hit bottom edge
// return value - position.pixels;
// return 0.0;
}
@override
... ... @@ -255,10 +270,11 @@ class NoMomentumSheetPhysics extends ScrollPhysics with SheetPhysics {
final Tolerance tolerance = this.tolerance;
if (position.outOfRange) {
double? end;
if (position.pixels > position.maxScrollExtent)
if (position.pixels > position.maxScrollExtent) {
end = position.maxScrollExtent;
if (position.pixels < position.minScrollExtent)
} else if (position.pixels < position.minScrollExtent) {
end = position.minScrollExtent;
}
assert(end != null);
return ScrollSpringSimulation(
spring,
... ... @@ -306,11 +322,15 @@ class ClampingSheetPhysics extends ScrollPhysics with SheetPhysics {
}
return true;
}());
// hit top edge
if (position.viewportDimension <= position.pixels &&
position.pixels < value) // hit top edge
position.pixels < value) {
return value - position.pixels;
if (position.pixels < 0 && position.pixels > value) // hit bottom edge
}
// hit bottom edge
if (position.pixels < 0 && position.pixels > value) {
return value - position.pixels;
}
return 0.0;
}
... ... @@ -320,10 +340,12 @@ class ClampingSheetPhysics extends ScrollPhysics with SheetPhysics {
final Tolerance tolerance = this.tolerance;
if (position.outOfRange) {
double? end;
if (position.pixels > position.maxScrollExtent)
if (position.pixels > position.maxScrollExtent) {
end = position.maxScrollExtent;
if (position.pixels < position.minScrollExtent)
}
if (position.pixels < position.minScrollExtent) {
end = position.minScrollExtent;
}
assert(end != null);
return ScrollSpringSimulation(
spring,
... ... @@ -336,10 +358,12 @@ class ClampingSheetPhysics extends ScrollPhysics with SheetPhysics {
if (velocity.abs() < tolerance.velocity) {
return null;
}
if (velocity > 0.0 && position.pixels >= position.maxScrollExtent)
if (velocity > 0.0 && position.pixels >= position.maxScrollExtent) {
return null;
if (velocity < 0.0 && position.pixels <= position.minScrollExtent)
}
if (velocity < 0.0 && position.pixels <= position.minScrollExtent) {
return null;
}
return ClampingScrollSimulation(
position: position.pixels,
velocity: velocity,
... ... @@ -477,9 +501,7 @@ class SnapSheetPhysics extends ScrollPhysics with SheetPhysics {
int? _getPage(ScrollMetrics position) {
assert(
!position.hasPixels ||
(position.minScrollExtent != null &&
position.maxScrollExtent != null),
!position.hasPixels || position.hasContentDimensions,
'Page value is only available after content dimensions are established.',
);
return !position.hasPixels
... ...
... ... @@ -134,13 +134,13 @@ class CupertinoSheetRoute<T> extends SheetRoute<T> {
@override
Widget buildSheet(BuildContext context, Widget child) {
SheetPhysics? _physics = BouncingSheetPhysics(
SheetPhysics? effectivePhysics = BouncingSheetPhysics(
parent: SnapSheetPhysics(
stops: stops ?? <double>[0, 1],
parent: physics,
));
if (!draggable) {
_physics = const NeverDraggableSheetPhysics();
effectivePhysics = const NeverDraggableSheetPhysics();
}
final MediaQueryData mediaQuery = MediaQuery.of(context);
final double topMargin =
... ... @@ -151,7 +151,7 @@ class CupertinoSheetRoute<T> extends SheetRoute<T> {
decorationBuilder: decorationBuilder,
fit: fit,
maxExtent: mediaQuery.size.height - topMargin,
physics: _physics,
physics: effectivePhysics,
controller: sheetController,
child: child,
);
... ...
... ... @@ -185,18 +185,18 @@ class SheetRoute<T> extends PageRoute<T> with DelegatedTransitionsRoute<T> {
}
Widget buildSheet(BuildContext context, Widget child) {
SheetPhysics? _physics = SnapSheetPhysics(
SheetPhysics? effectivePhysics = SnapSheetPhysics(
stops: stops ?? <double>[0, 1],
parent: physics,
);
if (!draggable) {
_physics = const NeverDraggableSheetPhysics();
effectivePhysics = const NeverDraggableSheetPhysics();
}
return Sheet.raw(
initialExtent: initialExtent,
decorationBuilder: decorationBuilder,
fit: fit,
physics: _physics,
physics: effectivePhysics,
controller: sheetController,
child: child,
);
... ...
... ... @@ -56,11 +56,7 @@ class SheetScrollable extends StatefulWidget {
this.scrollBehavior,
this.initialExtent,
this.minInteractionExtent = 0,
}) : assert(axisDirection != null),
assert(dragStartBehavior != null),
assert(viewportBuilder != null),
assert(excludeFromSemantics != null),
assert(semanticChildCount == null || semanticChildCount >= 0),
}) : assert(semanticChildCount == null || semanticChildCount >= 0),
super(key: key);
/// The direction in which this widget scrolls.
... ... @@ -278,8 +274,9 @@ class SheetScrollable extends StatefulWidget {
scrollable = SheetScrollable.of(context);
}
if (futures.isEmpty || duration == Duration.zero)
if (futures.isEmpty || duration == Duration.zero) {
return Future<void>.value();
}
if (futures.length == 1) return futures.single;
return Future.wait<void>(futures).then<void>((List<void> _) => null);
}
... ... @@ -293,9 +290,7 @@ class _ScrollableScope extends InheritedWidget {
required this.scrollable,
required this.position,
required Widget child,
}) : assert(scrollable != null),
assert(child != null),
super(key: key, child: child);
}) : super(key: key, child: child);
final SheetState scrollable;
final ScrollPosition position;
... ... @@ -390,8 +385,9 @@ class SheetState extends State<SheetScrollable>
@override
void initState() {
if (widget.controller == null)
if (widget.controller == null) {
_fallbackScrollController = SheetController();
}
super.initState();
}
... ... @@ -403,8 +399,9 @@ class SheetState extends State<SheetScrollable>
bool _shouldSheetPhysicsUpdate(
ScrollPhysics? newPhysics, ScrollPhysics? oldPhysics) {
if (newPhysics is! SheetPhysics || oldPhysics is! SheetPhysics)
if (newPhysics is! SheetPhysics || oldPhysics is! SheetPhysics) {
return false;
}
return newPhysics.shouldReload(oldPhysics);
}
... ... @@ -473,8 +470,9 @@ class SheetState extends State<SheetScrollable>
@override
@protected
void setSemanticsActions(Set<SemanticsAction> actions) {
if (_gestureDetectorKey.currentState != null)
if (_gestureDetectorKey.currentState != null) {
_gestureDetectorKey.currentState!.replaceSemanticsActions(actions);
}
}
// GESTURE RECOGNITION AND POINTER IGNORING
... ... @@ -553,9 +551,10 @@ class SheetState extends State<SheetScrollable>
}
_lastCanDrag = canDrag;
_lastAxisDirection = widget.axis;
if (_gestureDetectorKey.currentState != null)
if (_gestureDetectorKey.currentState != null) {
_gestureDetectorKey.currentState!
.replaceGestureRecognizers(_gestureRecognizers);
}
}
@override
... ... @@ -773,8 +772,7 @@ class _ScrollSemantics extends SingleChildRenderObjectWidget {
required this.allowImplicitScrolling,
required this.semanticChildCount,
Widget? child,
}) : assert(position != null),
assert(semanticChildCount == null || semanticChildCount >= 0),
}) : assert(semanticChildCount == null || semanticChildCount >= 0),
super(key: key, child: child);
final ScrollPosition position;
... ... @@ -809,7 +807,6 @@ class _RenderScrollSemantics extends RenderProxyBox {
}) : _position = position,
_allowImplicitScrolling = allowImplicitScrolling,
_semanticChildCount = semanticChildCount,
assert(position != null),
super(child) {
position.addListener(markNeedsSemanticsUpdate);
}
... ... @@ -818,7 +815,6 @@ class _RenderScrollSemantics extends RenderProxyBox {
ScrollPosition get position => _position;
ScrollPosition _position;
set position(ScrollPosition value) {
assert(value != null);
if (value == _position) return;
_position.removeListener(markNeedsSemanticsUpdate);
_position = value;
... ... @@ -881,8 +877,9 @@ class _RenderScrollSemantics extends RenderProxyBox {
if (child.isTagged(RenderViewport.excludeFromScrolling)) {
excluded.add(child);
} else {
if (!child.hasFlag(SemanticsFlag.isHidden))
if (!child.hasFlag(SemanticsFlag.isHidden)) {
firstVisibleIndex ??= child.indexInParent;
}
included.add(child);
}
}
... ... @@ -952,8 +949,7 @@ class ScrollIncrementDetails {
const ScrollIncrementDetails({
required this.type,
required this.metrics,
}) : assert(type != null),
assert(metrics != null);
});
/// The type of scroll this is (e.g. line, page, etc.).
///
... ... @@ -976,8 +972,7 @@ class ScrollIntent extends Intent {
const ScrollIntent({
required this.direction,
this.type = ScrollIncrementType.line,
}) : assert(direction != null),
assert(type != null);
});
/// The direction in which to scroll the scrollable containing the focused
/// widget.
... ...
... ... @@ -430,8 +430,9 @@ class SheetController extends ScrollController {
void relativeJumpTo(double offset) {
assert(positions.isNotEmpty,
'ScrollController not attached to any scroll views.');
for (final ScrollPosition position in positions)
for (final ScrollPosition position in positions) {
(position as SheetPosition).relativeJumpTo(offset);
}
}
}
... ... @@ -603,9 +604,7 @@ class SheetViewport extends SingleChildRenderObjectWidget {
Widget? child,
required this.fit,
required this.clipBehavior,
}) : assert(axisDirection != null),
assert(clipBehavior != null),
super(key: key, child: child);
}) : super(key: key, child: child);
final AxisDirection axisDirection;
final ViewportOffset offset;
... ... @@ -615,8 +614,8 @@ class SheetViewport extends SingleChildRenderObjectWidget {
final SheetFit fit;
@override
_RenderSheetViewport createRenderObject(BuildContext context) {
return _RenderSheetViewport(
RenderSheetViewport createRenderObject(BuildContext context) {
return RenderSheetViewport(
axisDirection: axisDirection,
offset: offset,
clipBehavior: clipBehavior,
... ... @@ -628,7 +627,7 @@ class SheetViewport extends SingleChildRenderObjectWidget {
@override
void updateRenderObject(
BuildContext context, _RenderSheetViewport renderObject) {
BuildContext context, RenderSheetViewport renderObject) {
// Order dependency: The offset setter reads the axis direction.
renderObject
..axisDirection = axisDirection
... ... @@ -640,10 +639,10 @@ class SheetViewport extends SingleChildRenderObjectWidget {
}
}
class _RenderSheetViewport extends RenderBox
class RenderSheetViewport extends RenderBox
with RenderObjectWithChildMixin<RenderBox>
implements RenderAbstractViewport {
_RenderSheetViewport({
RenderSheetViewport({
AxisDirection axisDirection = AxisDirection.down,
required ViewportOffset offset,
double cacheExtent = RenderAbstractViewport.defaultCacheExtent,
... ... @@ -652,11 +651,7 @@ class _RenderSheetViewport extends RenderBox
SheetFit fit = SheetFit.expand,
double? minExtent,
double? maxExtent,
}) : assert(axisDirection != null),
assert(offset != null),
assert(cacheExtent != null),
assert(clipBehavior != null),
_axisDirection = axisDirection,
}) : _axisDirection = axisDirection,
_offset = offset,
_fit = fit,
_minExtent = minExtent,
... ... @@ -669,7 +664,6 @@ class _RenderSheetViewport extends RenderBox
AxisDirection get axisDirection => _axisDirection;
AxisDirection _axisDirection;
set axisDirection(AxisDirection value) {
assert(value != null);
if (value == _axisDirection) return;
_axisDirection = value;
markNeedsLayout();
... ... @@ -680,7 +674,6 @@ class _RenderSheetViewport extends RenderBox
ViewportOffset get offset => _offset;
ViewportOffset _offset;
set offset(ViewportOffset value) {
assert(value != null);
if (value == _offset) return;
if (attached) _offset.removeListener(_hasDragged);
_offset = value;
... ... @@ -692,7 +685,6 @@ class _RenderSheetViewport extends RenderBox
double get cacheExtent => _cacheExtent;
double _cacheExtent;
set cacheExtent(double value) {
assert(value != null);
if (value == _cacheExtent) return;
_cacheExtent = value;
markNeedsLayout();
... ... @@ -702,7 +694,6 @@ class _RenderSheetViewport extends RenderBox
SheetFit get fit => _fit;
SheetFit _fit;
set fit(SheetFit value) {
assert(value != null);
if (value == _fit) return;
_fit = value;
markNeedsLayout();
... ... @@ -714,7 +705,6 @@ class _RenderSheetViewport extends RenderBox
Clip get clipBehavior => _clipBehavior;
Clip _clipBehavior = Clip.none;
set clipBehavior(Clip value) {
assert(value != null);
if (value != _clipBehavior) {
_clipBehavior = value;
markNeedsPaint();
... ... @@ -884,7 +874,6 @@ class _RenderSheetViewport extends RenderBox
Offset get _paintOffset => _paintOffsetForPosition(offset.pixels);
Offset _paintOffsetForPosition(double position) {
assert(axisDirection != null);
switch (axisDirection) {
case AxisDirection.up:
return Offset(0.0, position - child!.size.height + size.height);
... ... @@ -947,8 +936,9 @@ class _RenderSheetViewport extends RenderBox
@override
Rect? describeApproximatePaintClip(RenderObject? child) {
if (child != null && _shouldClipAtPaintOffset(_paintOffset))
if (child != null && _shouldClipAtPaintOffset(_paintOffset)) {
return Offset.zero & size;
}
return null;
}
... ... @@ -971,8 +961,9 @@ class _RenderSheetViewport extends RenderBox
RevealedOffset getOffsetToReveal(RenderObject target, double alignment,
{Rect? rect}) {
rect ??= target.paintBounds;
if (target is! RenderBox)
if (target is! RenderBox) {
return RevealedOffset(offset: offset.pixels, rect: rect);
}
final RenderBox targetBox = target;
final Matrix4 transform = targetBox.getTransformTo(child);
... ... @@ -983,7 +974,6 @@ class _RenderSheetViewport extends RenderBox
final double targetMainAxisExtent;
final double mainAxisExtent;
assert(axisDirection != null);
switch (axisDirection) {
case AxisDirection.up:
mainAxisExtent = size.height;
... ... @@ -1021,33 +1011,34 @@ class _RenderSheetViewport extends RenderBox
Curve curve = Curves.ease,
}) {
return;
if (!offset.allowImplicitScrolling) {
return super.showOnScreen(
descendant: descendant,
rect: rect,
duration: duration,
curve: curve,
);
}
final Rect? newRect = RenderViewportBase.showInViewport(
descendant: descendant,
viewport: this,
offset: offset,
rect: rect,
duration: duration,
curve: curve,
);
super.showOnScreen(
rect: newRect,
duration: duration,
curve: curve,
);
// TODO(jaime): check showOnScreen method beheves when keyboard appears on
// the screen
// if (!offset.allowImplicitScrolling) {
// return super.showOnScreen(
// descendant: descendant,
// rect: rect,
// duration: duration,
// curve: curve,
// );
// }
//
// final Rect? newRect = RenderViewportBase.showInViewport(
// descendant: descendant,
// viewport: this,
// offset: offset,
// rect: rect,
// duration: duration,
// curve: curve,
// );
// super.showOnScreen(
// rect: newRect,
// duration: duration,
// curve: curve,
// );
}
@override
Rect describeSemanticsClip(RenderObject child) {
assert(axis != null);
switch (axis) {
case Axis.vertical:
return Rect.fromLTRB(
... ...
... ... @@ -13,10 +13,10 @@ class ScrollToTopStatusBarHandler extends StatefulWidget {
final Widget child;
@override
_ScrollToTopStatusBarState createState() => _ScrollToTopStatusBarState();
ScrollToTopStatusBarState createState() => ScrollToTopStatusBarState();
}
class _ScrollToTopStatusBarState extends State<ScrollToTopStatusBarHandler> {
class ScrollToTopStatusBarState extends State<ScrollToTopStatusBarHandler> {
@override
void initState() {
super.initState();
... ...