mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
Fix DialogPicker
bouncing when the first selected item is near the end
This commit is contained in:
parent
a526853ed5
commit
9fcca48f57
1 changed files with 10 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:lightmeter/generated/l10n.dart';
|
import 'package:lightmeter/generated/l10n.dart';
|
||||||
import 'package:lightmeter/res/dimens.dart';
|
import 'package:lightmeter/res/dimens.dart';
|
||||||
|
|
||||||
|
@ -34,18 +35,20 @@ class _DialogFilterState<T> extends State<DialogFilter<T>> {
|
||||||
bool get _hasAnySelected => checkboxValues.contains(true);
|
bool get _hasAnySelected => checkboxValues.contains(true);
|
||||||
bool get _hasAnyUnselected => checkboxValues.contains(false);
|
bool get _hasAnyUnselected => checkboxValues.contains(false);
|
||||||
|
|
||||||
late final ScrollController _scrollController;
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < checkboxValues.length; i++) {
|
for (; i < checkboxValues.length; i++) {
|
||||||
if (checkboxValues[i]) {
|
if (checkboxValues[i]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_scrollController = ScrollController(initialScrollOffset: Dimens.grid56 * i);
|
_scrollController.jumpTo((Dimens.grid56 * i).clamp(0, _scrollController.position.maxScrollExtent));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in a new issue