From 18f635e6ef0346ab689bd10f6953ece0f8ebab2c Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Mon, 24 Nov 2025 20:05:07 +0100 Subject: [PATCH] Implemented custom skeleton widget --- lib/presentation/widgets/app_skeleton.dart | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/presentation/widgets/app_skeleton.dart diff --git a/lib/presentation/widgets/app_skeleton.dart b/lib/presentation/widgets/app_skeleton.dart new file mode 100644 index 0000000..209f1d8 --- /dev/null +++ b/lib/presentation/widgets/app_skeleton.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:skeletonizer/skeletonizer.dart'; + +class AppSkeleton extends StatefulWidget { + final Widget child; + final bool enabled; + final bool fixLayoutBuilder; + + const AppSkeleton({ + super.key, + required this.child, + this.enabled = true, + this.fixLayoutBuilder = false, + }); + + @override + State createState() => _AppSkeletonState(); +} + +class _AppSkeletonState extends State { + @override + Widget build(BuildContext context) { + return Skeletonizer( + effect: PulseEffect( + from: Colors.grey[800]!, + to: Colors.grey[600]!, + duration: const Duration(milliseconds: 800), + ), + enabled: widget.enabled, + enableSwitchAnimation: true, + switchAnimationConfig: SwitchAnimationConfig( + duration: const Duration(milliseconds: 200), + switchInCurve: Curves.linear, + switchOutCurve: Curves.linear, + transitionBuilder: AnimatedSwitcher.defaultTransitionBuilder, + layoutBuilder: !widget.fixLayoutBuilder + ? AnimatedSwitcher.defaultLayoutBuilder + : (Widget? currentChild, List previousChildren) { + return Stack( + alignment: Alignment.topCenter, + children: [ + ...previousChildren, + if (currentChild != null) currentChild, + ], + ); + }, + ), + child: widget.child, + ); + } +}