loading_button_async_pro 0.0.4
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),
),
],
);
}
}