v2.4.0fade_shimmer
一個淡入淡出閃爍庫,用於實現最新版 Facebook 載入骨架 UI 的載入效果,具有順暢的淡入淡出過渡。
quango2304/fade_shimmer open-source repository details.
{"sdk":"flutter"}{"sdk":"flutter"}以下為英文專案原文快照,最新內容請造訪 GitHub。
A customizable Flutter package that provides elegant shimmer loading effects with smooth fade transitions. Perfect for creating skeleton screens while your content is loading.
FadeShimmer Demo
Add fade_shimmer to your pubspec.yaml file:
dependencies:
fade_shimmer: ^2.3.0
Run the following command to install:
flutter pub get
import 'package:fade_shimmer/fade_shimmer.dart';
FadeShimmer(
height: 8,
width: 150,
radius: 4,
fadeTheme: FadeTheme.light,
)
FadeShimmer.round(
size: 60,
fadeTheme: isDarkMode ? FadeTheme.dark : FadeTheme.light,
)
FadeShimmer(
height: 8,
width: 150,
radius: 4,
highlightColor: Color(0xffF9F9FB),
baseColor: Color(0xffE6E8EB),
)
Create a wave-like loading effect by adding delays to each shimmer element:
Column(
children: [
FadeShimmer(
height: 8,
width: 150,
radius: 4,
millisecondsDelay: 0,
fadeTheme: FadeTheme.light,
),
SizedBox(height: 8),
FadeShimmer(
height: 8,
width: 170,
radius: 4,
millisecondsDelay: 300, // 300ms delay
fadeTheme: FadeTheme.light,
),
SizedBox(height: 8),
FadeShimmer(
height: 8,
width: 120,
radius: 4,
millisecondsDelay: 600, // 600ms delay
fadeTheme: FadeTheme.light,
),
],
)
You can change the global animation duration for all shimmer widgets:
// Change animation duration to 3 seconds (default is 1 second)
FadeShimmer.animationDurationInMillisecond = 3000;
Note: This change affects all FadeShimmer widgets in your application.
| Property | Type | Description |
|---|---|---|
width |
double |
Width of the shimmer container (required) |
height |
double |
Height of the shimmer container (required) |
radius |
double |
Border radius of the shimmer container (default: 0) |
fadeTheme |
FadeTheme |
Predefined theme (light or dark) |
highlightColor |
Color |
The brighter color that the shimmer transitions to |
baseColor |
Color |
The darker color that the shimmer starts with |
millisecondsDelay |
int |
Delay before the animation starts (default: 0) |
FadeTheme.light - Light gray colors suitable for light backgroundsFadeTheme.dark - Dark gray colors suitable for dark backgroundsCheck out the example directory for a complete sample application using FadeShimmer.
Contributions are welcome! If you find a bug or want a feature, please open an issue on the GitHub repository.
This project is licensed under the MIT License - see the LICENSE file for details.