tactile_loading_button 0.0.1
tactile_loading_button: ^0.0.1 copied to clipboard
A customizable Flutter loading button with tactile feedback
import 'package:flutter/material.dart';
import 'package:tactile_loading_button/tactile_loading_button.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.indigo),
home: const ButtonExampleScreen(),
);
}
}
class ButtonExampleScreen extends StatelessWidget {
const ButtonExampleScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Fixed Size Loading Button')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TactileLoadingButton(
width: 250, // Full horizontal width
height: 60,
color: Colors.indigo,
borderRadius: BorderRadius.circular(10),
// Simulate a network request
onPressed: () async {
await Future.delayed(const Duration(seconds: 3));
},
// *** Define the complex loading widget ***
loadingWidget: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2.5,
),
),
const SizedBox(width: 12),
const Text(
'Processing Payment...',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
],
),
child: const Text(
'Complete Purchase',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
);
}
}