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

A package wrapper around material buttons to display a loading widget while waiting for the onPressed method to finish

example/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_loading_button/loading_button.dart';

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData.light(),
      home: Scaffold(
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            /// Circular loading widget displayed
            LoadingButton(
              onPressed: () async {
                await Future.delayed(
                  const Duration(seconds: 3),
                  () => print('Task done!'),
                );
              },
              child: const Text('Press me!'),
              loadingWidget: const CircularProgressIndicator(),
            ),

            /// Linear loading widget displayed
            ///
            /// Notice the extra container the linear progress indicator is put into
            /// this is to prevent its width from being infinite and I will look into a cleaner
            /// solution!
            LoadingButton(
              onPressed: () async {
                await Future.delayed(
                  const Duration(seconds: 3),
                  () => print('Task done!'),
                );
              },
              child: const Text('Press me!'),
              loadingWidget: Container(
                constraints: const BoxConstraints(
                  maxWidth: 200,
                ),
                child: const LinearProgressIndicator(),
              ),
            )
          ],
        ),
      ),
    ),
  );
}
3
likes
130
pub points
68%
popularity

Publisher

unverified uploader

A package wrapper around material buttons to display a loading widget while waiting for the onPressed method to finish

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_loading_button