You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted the same thing. My workaround is to listen to UserScrollNotification and only call onChanged when the scroll direction is "idle". Solution below uses flutter hooks but could also be done with a stateful widget.
MyNumberPicker.dart
import'package:flutter/material.dart';
import'package:flutter/rendering.dart';
import'package:flutter_hooks/flutter_hooks.dart';
import'package:hooks_riverpod/hooks_riverpod.dart';
import'package:numberpicker/numberpicker.dart';
classMyNumberPickerextendsHookConsumerWidget {
/// Min value user can pickfinalint minValue;
// ... all other fieldsconstMyNumberPicker({
Key? key,
requiredthis.minValue,
// ... all other fields
}) :super(key: key);
@overrideWidgetbuild(BuildContext context, WidgetRef ref) {
final temp =useState(value);
returnNotificationListener<UserScrollNotification>(
onNotification: (notification) {
if (notification.direction ==ScrollDirection.idle) {
onChanged(temp.value);
}
returntrue;
},
child:NumberPicker(
value: temp.value,
onChanged: (value) => temp.value = value,
minValue: minValue,
// ... pass through all other fields
),
);
}
}
onChange called when the user stops changing the value
The text was updated successfully, but these errors were encountered: