shimmer_effect 1.0.4 shimmer_effect: ^1.0.4 copied to clipboard
The Shimmer effect package provides a customizable widget that adds a shimmering effect to any Flutter widget.
import 'package:flutter/material.dart';
import 'package:shimmer_effect/shimmer_effect.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Shimmer Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Shimmer Animation Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ShimmerEffect(
baseColor: Colors.teal,
highlightColor: Colors.blueAccent,
child: SizedBox(
width: 200,
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
Icon(
Icons.favorite,
size: 72,
color: Colors.red,
),
SizedBox(height: 16),
Text(
'Shimmer Animation',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 24),
),
],
),
),
),
));
}
}