leulit_flutter_loading 0.2.0 copy "leulit_flutter_loading: ^0.2.0" to clipboard
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'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
points
109
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Modal full-screen loading overlay for Flutter (iOS, Android, web), driven by leulit_flutter_actionmanager actions and sized with leulit_flutter_fullresponsive.

Repository (GitHub)
View/report issues

Topics

#loading #overlay #actions #responsive

License

MIT (license)

Dependencies

flutter, leulit_flutter_actionmanager, leulit_flutter_fullresponsive

More

Packages that depend on leulit_flutter_loading