Skip to content

Commit

Permalink
Added some customization options to fading_circle (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
jogboms authored Oct 30, 2024
2 parents ea4254a + 12bcf12 commit 360fa80
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/src/fading_circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class SpinKitFadingCircle extends StatefulWidget {
Key? key,
this.color,
this.size = 50.0,
this.itemSize,
this.itemCount,
this.itemBuilder,
this.duration = const Duration(milliseconds: 1200),
this.controller,
Expand All @@ -17,6 +19,8 @@ class SpinKitFadingCircle extends StatefulWidget {

final Color? color;
final double size;
final double? itemSize;
final int? itemCount;
final IndexedWidgetBuilder? itemBuilder;
final Duration duration;
final AnimationController? controller;
Expand All @@ -26,8 +30,6 @@ class SpinKitFadingCircle extends StatefulWidget {
}

class _SpinKitFadingCircleState extends State<SpinKitFadingCircle> with SingleTickerProviderStateMixin {
static const _itemCount = 12;

late AnimationController _controller;

@override
Expand All @@ -47,27 +49,30 @@ class _SpinKitFadingCircleState extends State<SpinKitFadingCircle> with SingleTi

@override
Widget build(BuildContext context) {
final itemSize = widget.itemSize ?? widget.size * 0.15;
final itemCount = widget.itemCount ?? 12;

return Center(
child: SizedBox.fromSize(
size: Size.square(widget.size),
child: Stack(
children: List.generate(_itemCount, (i) {
children: List.generate(itemCount, (i) {
final position = widget.size * .5;
return Positioned.fill(
left: position,
top: position,
child: Transform(
transform: Matrix4.rotationZ(30.0 * i * 0.0174533),
transform: Matrix4.rotationZ((360 / itemCount) * i * 0.0174533),
child: Align(
alignment: Alignment.center,
child: FadeTransition(
opacity: DelayTween(
begin: 0.0,
end: 1.0,
delay: i / _itemCount,
delay: i / itemCount,
).animate(_controller),
child: SizedBox.fromSize(
size: Size.square(widget.size * 0.15),
size: Size.square(itemSize),
child: _itemBuilder(i),
),
),
Expand Down

0 comments on commit 360fa80

Please sign in to comment.