diet-guard/app/lib/widgets/pickers/loop_wheel_delegate.dart
Krzysztof kuhy Rudnicki 4eca59bac9
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Icon-only date and time pickers
Replace showDatePicker, showDateRangePicker and showTimePicker with
numeral grid/wheel dialogs confirmed by check and close icons. Adds a
no-words picker guard and a repo invariant banning the framework pickers.

Todo: e09dac36

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:05:11 +01:00

31 lines
931 B
Dart

/// The endless child delegate of the looping time wheels.
library;
import 'package:flutter/widgets.dart';
/// An endless delegate that passes the absolute index to its builder, so a
/// tapped item knows which of its many copies it is (the framework's
/// looping delegate only hands out the wrapped child).
class LoopWheelDelegate extends ListWheelChildDelegate {
/// Creates a delegate looping over [count] values.
LoopWheelDelegate(this.count, this.builder);
/// Number of distinct values before the wheel wraps.
final int count;
/// Builds the item at an absolute (unwrapped) index.
final Widget Function(int index) builder;
@override
Widget? build(BuildContext context, int index) => builder(index);
@override
int? get estimatedChildCount => null;
@override
int trueIndexOf(int index) => index % count;
@override
bool shouldRebuild(covariant ListWheelChildDelegate oldDelegate) => true;
}