mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Tags panel overscroll will scroll parent
This commit is contained in:
30
lib/components/scroll_parent.dart
Normal file
30
lib/components/scroll_parent.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user