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 createState() => _AppSpinnerState(); } class _AppSpinnerState extends State 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, ); }