NextGenButton Widget
NextGenButton is a customizable button widget for Flutter that allows you to create stylish and functional buttons with various options for design and behavior. This widget supports dynamic sizing, loading states, and customizable borders, colors, and icons.
Features
- Customizable Background Color: Set the button's background color with the
colorproperty. - Adjustable Border: Define border color and width using
borderColorandborderproperties. - Rounded Corners: Customize the border radius to achieve rounded corners with the
radiusproperty. - Elevation: Apply elevation to give the button a raised effect with the
elevationproperty. - Flexible Sizing: Specify exact dimensions for the button using
heightandwidth. - Loading State: Show a loading spinner when
isLoadingistrue, disabling interaction during loading. - Icon Support: Add icons to the left and/or right of the button text using
leftIconandrightIcon. - Custom Action: Define what happens on button tap with the
onTapcallback.
Installation
To use the NextGenButton widget in your Flutter project, include the file containing the NextGenButton class in your project.
Usage
Here's a basic example of how to use the NextGenButton widget:
import 'package:flutter/material.dart';
import 'package:nextgen_button/nextgen_button.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('NextGenButton Example')),
body: Center(
child: NextGenButton(
onTap: () {
// Action to perform on button tap
print('NextGenButton tapped!');
},
titleText: Text(
'Click Me',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
borderColor: Colors.blueAccent,
border: 2,
radius: 12,
elevation: 5,
height: 50,
width: 200,
leftIcon: Icon(
Icons.add,
color: Colors.white,
),
rightIcon: Icon(
Icons.arrow_forward,
color: Colors.white,
),
isLoading: false, // Set to true to show loading indicator
),
),
),
);
}
}