1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 06:19:22 +00:00
comunicmobile/lib/ui/widgets/scroll_watcher.dart

27 lines
483 B
Dart
Raw Normal View History

2019-04-27 16:29:30 +00:00
import 'package:flutter/material.dart';
/// Scroll watcher
///
/// @author Pierre HUBERT
typedef OnReachBottomCallback = void Function();
class ScrollWatcher extends ScrollController {
// Callbacks
OnReachBottomCallback? onReachBottom;
2019-04-27 16:29:30 +00:00
ScrollWatcher({this.onReachBottom}) {
addListener(_updatePosition);
}
void _updatePosition() {
// Refresh bottom position
if(position.pixels.floor() == position.maxScrollExtent.floor())
onReachBottom!();
2019-04-27 16:29:30 +00:00
}
}