flutter_animated_page_loader 0.1.1
flutter_animated_page_loader: ^0.1.1 copied to clipboard
A branded full-screen refresh overlay for Flutter. Animated coloured panels slide in to reveal a shimmering wordmark, with a guaranteed minimum visible duration so instant API responses still feel polished.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_animated_page_loader/flutter_animated_page_loader.dart';
void main() {
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'flutter_animated_page_loader demo',
theme: ThemeData(
colorSchemeSeed: const Color(0xFF1E88E5),
useMaterial3: true,
),
home: const DemoPage(),
);
}
}
class DemoPage extends StatefulWidget {
const DemoPage({super.key});
@override
State<DemoPage> createState() => _DemoPageState();
}
class _DemoPageState extends State<DemoPage> {
bool _isRefreshing = false;
int _items = 5;
Future<void> _simulateRefresh({Duration delay = const Duration(seconds: 2)}) async {
setState(() => _isRefreshing = true);
await Future<void>.delayed(delay);
if (!mounted) return;
setState(() {
_items += 1;
_isRefreshing = false;
});
}
@override
Widget build(BuildContext context) {
return AnimatedPageLoaderOverlay(
isVisible: _isRefreshing,
text: 'MYAPP',
tagline: 'Fast. Simple. Yours.',
theme: const AnimatedPageLoaderTheme(
panelColor: Color(0xFF1E88E5),
shimmerHighlightColor: Colors.white,
),
child: Scaffold(
appBar: AppBar(title: const Text('flutter_animated_page_loader')),
body: ListView.separated(
padding: const EdgeInsets.all(16),
itemCount: _items,
separatorBuilder: (_, __) => const SizedBox(height: 8),
itemBuilder: (context, i) => Card(
child: ListTile(
leading: const Icon(Icons.shopping_bag_outlined),
title: Text('Item ${i + 1}'),
subtitle: const Text('Pull to refresh, or tap a button below.'),
),
),
),
bottomNavigationBar: SafeArea(
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
Expanded(
child: ElevatedButton.icon(
onPressed: _isRefreshing ? null : () => _simulateRefresh(),
icon: const Icon(Icons.refresh),
label: const Text('Refresh (2s)'),
),
),
const SizedBox(width: 12),
Expanded(
child: OutlinedButton.icon(
onPressed: _isRefreshing
? null
: () => _simulateRefresh(
delay: const Duration(milliseconds: 200),
),
icon: const Icon(Icons.flash_on),
label: const Text('Instant (200ms)'),
),
),
],
),
),
),
),
);
}
}