mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
27 lines
481 B
Dart
27 lines
481 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
/// Scroll watcher
|
||
|
///
|
||
|
/// @author Pierre HUBERT
|
||
|
|
||
|
typedef OnReachBottomCallback = void Function();
|
||
|
|
||
|
class ScrollWatcher extends ScrollController {
|
||
|
|
||
|
// Callbacks
|
||
|
OnReachBottomCallback onReachBottom;
|
||
|
|
||
|
ScrollWatcher({this.onReachBottom}) {
|
||
|
addListener(_updatePosition);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void _updatePosition() {
|
||
|
|
||
|
// Refresh bottom position
|
||
|
if(position.pixels.floor() == position.maxScrollExtent.floor())
|
||
|
onReachBottom();
|
||
|
|
||
|
}
|
||
|
}
|