basic_loading_overlay 1.0.2 copy "basic_loading_overlay: ^1.0.2" to clipboard
basic_loading_overlay: ^1.0.2 copied to clipboard

A basic loading overlay that creates a new scope where the user cannot leave until you programmatically pop it.

A basic loading overlay

Features #

Creates a new scope where the user cannot leave until you programmatically pop it.

Usage #

import 'package:flutter/material.dart';

import 'package:basic_loading_overlay/basic_loading_overlay.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Basic Loading Overlay',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(10.0),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'Everytime you push the button a loading overlay will appear for N seconds, where N is how many times you have pressed the button',
              ),
              const SizedBox(
                height: 15,
              ),
              const Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.headline4,
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _showOverlay,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }

  Future _showOverlay() async {
    _incrementCounter();

    Future.delayed(
      Duration(seconds: _counter),
      () => Navigator.of(context).pop(),
    );

    return showDialog(
      context: context,
      builder: (context) {
        return const BasicLoadingOverlay();
      },
    );
  }
}

Additional information #

If you like this package and find it usefull, please give it a like.

0
likes
130
pub points
32%
popularity

Publisher

unverified uploader

A basic loading overlay that creates a new scope where the user cannot leave until you programmatically pop it.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on basic_loading_overlay