loading_button_async_pro 0.0.4 copy "loading_button_async_pro: ^0.0.4" to clipboard
loading_button_async_pro: ^0.0.4 copied to clipboard

A customizable Flutter loading button with async support and built-in loading state handling.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Loading Button Plus Example'),
        ),
        body: const Padding(
          padding: EdgeInsets.all(16),
          child: ExamplePage(),
        ),
      ),
    );
  }
}

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

  @override
  State<ExamplePage> createState() => _ExamplePageState();
}

class _ExamplePageState extends State<ExamplePage> {
  bool loading = false;

  Future<void> fakeApiCall() async {
    setState(() => loading = true);
    await Future.delayed(const Duration(seconds: 2));
    setState(() => loading = false);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        LoadingButton(
          text: "Normal Loading Button",
          isLoading: loading,
          onPressed: fakeApiCall,
          textStyle: TextStyle(color: Colors.white),
        ),
        const SizedBox(height: 20),
        AsyncLoadingButton(
          text: "Async Loading Button",
          onPressed: () async {
            await Future.delayed(const Duration(seconds: 2));
          },
          textStyle: TextStyle(color: Colors.white),
        ),
      ],
    );
  }
}
0
likes
140
points
6
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A customizable Flutter loading button with async support and built-in loading state handling.

Homepage

Topics

#flutter #ui #button #loading

License

MIT (license)

Dependencies

flutter, flutter_lints

More

Packages that depend on loading_button_async_pro