fixed overwrite on internal copy, DST drift in widget anchors, inline errors without controller and removed dead room lookup

This commit is contained in:
2026-09-27 17:37:31 +02:00
parent ee1240f71a
commit 2664378b17
13 changed files with 86 additions and 152 deletions
@@ -31,6 +31,7 @@ class AsyncActionButton extends StatelessWidget {
errorBuilder: errorBuilder,
onError: onError,
onSuccess: onSuccess,
showInlineError: showInlineError,
builder: (context, busy, handler) {
final lead = busy
? AppProgressIndicator.small(
@@ -38,13 +39,11 @@ class AsyncActionButton extends StatelessWidget {
)
: (icon == null ? null : Icon(icon));
final content = lead == null ? child : _leadingLabel(lead, child);
final button = ElevatedButton(
return ElevatedButton(
onPressed: handler,
style: style,
child: content,
);
if (!showInlineError) return button;
return _InlineErrorWrapper(controller: controller, child: button);
},
);
}
+8 -6
View File
@@ -6,6 +6,7 @@ class _AsyncMixin extends StatefulWidget {
final AsyncErrorBuilder? errorBuilder;
final void Function(String message)? onError;
final VoidCallback? onSuccess;
final bool showInlineError;
final Widget Function(BuildContext context, bool busy, VoidCallback? handler)
builder;
@@ -16,6 +17,7 @@ class _AsyncMixin extends StatefulWidget {
this.errorBuilder,
this.onError,
this.onSuccess,
this.showInlineError = false,
});
@override
@@ -73,27 +75,27 @@ class _AsyncMixinState extends State<_AsyncMixin> {
@override
Widget build(BuildContext context) {
final busy = _controller.busy;
return widget.builder(
final child = widget.builder(
context,
busy,
busy || widget.onPressed == null ? null : _trigger,
);
if (!widget.showInlineError) return child;
return _InlineErrorWrapper(controller: _controller, child: child);
}
}
class _InlineErrorWrapper extends StatelessWidget {
final AsyncActionController? controller;
final AsyncActionController controller;
final Widget child;
const _InlineErrorWrapper({required this.controller, required this.child});
@override
Widget build(BuildContext context) {
final c = controller;
if (c == null) return child;
return AnimatedBuilder(
animation: c,
animation: controller,
builder: (context, _) {
final err = c.error;
final err = controller.error;
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
@@ -27,6 +27,7 @@ class AsyncTextButton extends StatelessWidget {
errorBuilder: errorBuilder,
onError: onError,
onSuccess: onSuccess,
showInlineError: showInlineError,
builder: (context, busy, handler) {
final content = busy
? _leadingLabel(
@@ -37,8 +38,7 @@ class AsyncTextButton extends StatelessWidget {
)
: child;
final button = TextButton(onPressed: handler, child: content);
if (!showInlineError) return button;
return _InlineErrorWrapper(controller: controller, child: button);
return button;
},
);
}