mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-06 13:59:19 +08:00
31 lines
993 B
Dart
31 lines
993 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ScrollParent extends StatelessWidget {
|
|
final ScrollController controller;
|
|
final Widget child;
|
|
|
|
const ScrollParent({Key? key, required this.controller, required this.child})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return NotificationListener<OverscrollNotification>(
|
|
onNotification: (OverscrollNotification value) {
|
|
if (value.overscroll < 0 && controller.offset + value.overscroll <= 0) {
|
|
if (controller.offset != 0) controller.jumpTo(0);
|
|
return true;
|
|
}
|
|
if (controller.offset + value.overscroll >=
|
|
controller.position.maxScrollExtent) {
|
|
if (controller.offset != controller.position.maxScrollExtent)
|
|
controller.jumpTo(controller.position.maxScrollExtent);
|
|
return true;
|
|
}
|
|
controller.jumpTo(controller.offset + value.overscroll);
|
|
return true;
|
|
},
|
|
child: child,
|
|
);
|
|
}
|
|
}
|