flutter_smart_button 0.2.1 copy "flutter_smart_button: ^0.2.1" to clipboard
flutter_smart_button: ^0.2.1 copied to clipboard

A customizable smart button widget for Flutter applications, designed to handle asynchronous operations with a loading indicator, and customizable styles.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('SmartButton Example'),
        ),
        body: Center(
          child: SmartButtonExample(),
        ),
      ),
    );
  }
}

class SmartButtonExample extends StatefulWidget {
  @override
  _SmartButtonExampleState createState() => _SmartButtonExampleState();
}

class _SmartButtonExampleState extends State<SmartButtonExample> {
  bool _isLoading = false;

  Future<void> _simulateAsyncOperation() async {
    if (!_isLoading) {
      setState(() {
        _isLoading = true;
      });
      await Future.delayed(Duration(seconds: 2));
      setState(() {
        _isLoading = false;
      });
      ScaffoldMessenger.of(context).showSnackBar(SnackBar(
        content: Text('Completed'),
      ));
    }
  }

  @override
  Widget build(BuildContext context) {
    return SmartButton(
      child: Text('click please'),
      onPressed: _simulateAsyncOperation,
      isLoading: _isLoading,
      loadingIndicator: CircularProgressIndicator(
        color: Colors.white,
      ),
      buttonColor: Colors.blue,
      textStyle: TextStyle(fontSize: 18, color: Colors.white),
      borderWidth: 2.0,
      borderColor: Colors.blueAccent,
      padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 24.0),
      tooltip: 'start after click',
    );
  }
}
6
likes
150
points
13
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable smart button widget for Flutter applications, designed to handle asynchronous operations with a loading indicator, and customizable styles.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_spinkit

More

Packages that depend on flutter_smart_button