Catch-all commit for outstanding pre-existing local changes. Mixes several themes that would normally be split: - Rename: UxPlugin → XPlugin across iOS, macOS, Android registrants. - New top-level packages under lib/src/: anim/ (animated values, panes, sheets, dock, measured), core/ (Emitter, ReactiveBuilder scaffolding, presenter/widget/value/dispose primitives), navi/ (Screen/ScreenStack/Router/hero/transitions), reactive/. - Edits across existing plugins (clipboard, crash, file, gallery, keyboard, scanner, sensor, url) to align with the new core. - Test updates and CHANGELOG/README touches accompanying the above.
62 lines
1.4 KiB
Dart
62 lines
1.4 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
class AnimatedDouble extends StatefulWidget {
|
|
const AnimatedDouble({
|
|
super.key,
|
|
required this.builder,
|
|
required this.start,
|
|
required this.end,
|
|
this.curve = Curves.linear,
|
|
this.duration = const Duration(milliseconds: 200),
|
|
this.child,
|
|
});
|
|
|
|
final ValueWidgetBuilder<double> builder;
|
|
final Widget? child;
|
|
final double start;
|
|
final double end;
|
|
final Duration duration;
|
|
final Curve curve;
|
|
|
|
@override
|
|
State<AnimatedDouble> createState() => _AnimatedDoubleState();
|
|
}
|
|
|
|
class _AnimatedDoubleState extends State<AnimatedDouble>
|
|
with SingleTickerProviderStateMixin {
|
|
late final AnimationController controller;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
controller = AnimationController.unbounded(
|
|
vsync: this, value: widget.start, duration: widget.duration);
|
|
if (widget.end != widget.start) {
|
|
controller.animateTo(widget.end);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(covariant AnimatedDouble oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (widget.end != oldWidget.end) {
|
|
controller.animateTo(widget.end);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ValueListenableBuilder(
|
|
valueListenable: controller,
|
|
builder: widget.builder,
|
|
child: widget.child,
|
|
);
|
|
}
|
|
}
|