Files
pipelines/app/lib/ui/status/app_spinner.dart
T
alan 1be2418892 Give running-turn spinners their own animation controller
Without one, CircularProgressIndicator looks its controller up on every
frame, walking the widget tree for the ambient Theme (89 ms over a
streamed reply at 4K). AppSpinner is the stock indicator with its own
controller and the stock period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:19:22 +00:00

42 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
/// The standard indeterminate [CircularProgressIndicator], with its own
/// animation controller.
///
/// Without a `controller`, the Material indicator looks its controller up on
/// every animation frame: an inherited theme, then a walk up the whole widget
/// tree for the ambient `Theme`. In a deep tree (a chat row, a running turn's
/// chips) that walk is the indicator's largest cost; owning the controller
/// skips it. The motion is the stock one: same period, same curves.
class AppSpinner extends StatefulWidget {
const AppSpinner({super.key, this.strokeWidth});
final double? strokeWidth;
/// The stock indeterminate circular period (`progress_indicator.dart`).
static const Duration period = Duration(milliseconds: 1333 * 2222);
@override
State<AppSpinner> createState() => _AppSpinnerState();
}
class _AppSpinnerState extends State<AppSpinner>
with SingleTickerProviderStateMixin {
late final AnimationController _controller = AnimationController(
vsync: this,
duration: AppSpinner.period,
)..repeat();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => CircularProgressIndicator(
controller: _controller,
strokeWidth: widget.strokeWidth,
);
}