future_loading_overlay 0.0.2 copy "future_loading_overlay: ^0.0.2" to clipboard
future_loading_overlay: ^0.0.2 copied to clipboard

A Loading overlay dialog for showing future loading UI.

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:future_loading_overlay/future_loading_overlay.dart';

void main() {
  runApp(const App());
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int? _number;

  Future<int> _getNumberFuture() async {
    // Deley the future by 3 seconds
    await Future.delayed(const Duration(seconds: 3));

    return Future.value(Random().nextInt(10));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Demo Home Page'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text('Press a button below to run a future'),
            if (_number != null) Text('Future completed with number $_number'),
            ElevatedButton(
              onPressed: () async {
                final result = await showFutureLoadingOverlay<int>(
                  context: context,
                  future: _getNumberFuture(),
                  expanded: false,
                );

                if (mounted) {
                  setState(() {
                    _number = result;
                  });
                }
              },
              child: const Text('Start'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A Loading overlay dialog for showing future loading UI.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on future_loading_overlay