leulit_flutter_loading 0.2.0
leulit_flutter_loading: ^0.2.0 copied to clipboard
Modal full-screen loading overlay for Flutter (iOS, Android, web), driven by leulit_flutter_actionmanager actions and sized with leulit_flutter_fullresponsive.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:leulit_flutter_loading/leulit_flutter_loading.dart';
void main() => runApp(const ExampleApp());
final _navKey = GlobalKey<NavigatorState>();
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: _navKey,
builder: (_, child) => LoadingHost(navigatorKey: _navKey, child: child!),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
Future<void> _fakeRequest(String message) async {
LoadingActions.on.dispatch(data: message);
await Future<void>.delayed(const Duration(seconds: 2));
LoadingActions.off.dispatch();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('leulit_flutter_loading')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
spacing: 12,
children: [
ElevatedButton(
onPressed: () => _fakeRequest('Cargando…'),
child: const Text('Petición 2 s'),
),
ElevatedButton(
onPressed: () {
_fakeRequest('Primera');
_fakeRequest('Segunda');
},
child: const Text('Dos peticiones solapadas'),
),
ElevatedButton(
onPressed: () => LoadingActions.on.dispatch(data: 'Colgado…'),
child: const Text('on sin off'),
),
ElevatedButton(
onPressed: () => LoadingActions.reset.dispatch(),
child: const Text('reset'),
),
],
),
),
);
}
}