import 'dart:math'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class AnimatedBars extends StatefulWidget { final double size; final Color? color; const AnimatedBars({ super.key, this.size = 24.0, this.color, }); @override State createState() => _AnimatedBarsState(); } class _AnimatedBarsState extends State with TickerProviderStateMixin { late final _controller = AnimationController( vsync: this, duration: const Duration(milliseconds: 1000)) ..repeat(reverse: true); @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final color = widget.color ?? Theme.of(context).colorScheme.onSurface; final r = Random(); final count = 3; AnimatedIcons.search_ellipsis; return SizedBox.square( dimension: widget.size, child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: List.generate( count, (index) => SizedBox( width: widget.size / count, child: Align( alignment: Alignment.bottomCenter, child: SizeTransition( sizeFactor: Tween(begin: 1.0, end: 0.2)..animate( CurvedAnimation( parent: _controller., curve: Interval(0.1 * index, 0.3 * index, curve: Curves.easeIn))), axisAlignment: 1.0, child: Container(color: color)), ), )), )); } }