Button

Displays a button or a widget that looks like a button.

Installation

flutcn_ui add button

Usage

main.dart
import '../widgets/button.dart';
 
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Button'),
        ),
        body: Center(
          child: Button.primary(
          height: 60,
          padding: EdgeInsets.symmetric(horizontal: 20),
          child: const Text('primary'),
          onPressed: () {},
          ),
        ),
      ),
    );
  }
}

Properties

PropertyTypeDescription
textStringThe text to display on the button.
onPressedFunctionThe function to call when the button is pressed.
variantButtonVariantThe variant of the button.
leadingIconWidgetThe leading icon of the button.
trailingIconWidgetThe trailing icon of the button.
isDisabledboolWhether the button is disabled.
isLoadingboolWhether the button is loading.
heightdoubleThe height of the button.
widthdoubleThe width of the button.
paddingEdgeInsetsThe padding of the button.
borderRadiusdoubleThe border radius of the button.
elevationdoubleThe elevation of the button.
hoverElevationdoubleThe hover elevation of the button.
pressedElevationdoubleThe pressed elevation of the button.
disabledElevationdoubleThe disabled elevation of the button.
borderColorColorThe border color of the button.
borderWidthdoubleThe border width of the button.
backgroundColorColorThe background color of the button.
foregroundColorColorThe foreground color of the button.
hoverBackgroundColorColorThe hover background color of the button.
pressedBackgroundColorColorThe pressed background color of the button.
disabledBackgroundColorColorThe disabled background color of the button.
disabledForegroundColorColorThe disabled foreground color of the button.
loadingIndicatorColorColorThe loading indicator color of the button.
fontSizedoubleThe font size of the button.
fontWeightFontWeightThe font weight of the button.
animationDurationDurationThe animation duration of the button.
animationCurveCurveThe animation curve of the button.
shapeBoxShapeThe shape of the button.
gradientGradientThe gradient of the button.
boxShadowThe box shadow of the button.
loadingSizedoubleThe loading size of the button.
overlayColorColorThe overlay color of the button.

Variants

FlutButton provides several variants of buttons, each with its own appearance and behavior. You can choose the variant that best suits your needs.

Primary

The primary variant is the default variant of the button. It has a background color, a foreground color, and a border color. It is typically used for the most important or the most common action.

Secondary

The secondary variant has a background color, a foreground color, and a border color. It is typically used for less important or less common actions.

Outline

The outline variant has a background color, a foreground color, and a border color. It is typically used for less important or less common actions.

Ghost

The ghost variant has a background color, a foreground color, and a border color. It is typically used for less important or less common actions.

The link variant has a background color, a foreground color, and a border color. It is typically used for less important or less common actions.

Destructive

The destructive variant has a background color, a foreground color, and a border color. It is typically used for less important or less common actions.

Custom

The custom variant allows you to customize the appearance and behavior of the button. You can set the background color, foreground color, border color, and other properties to create a unique button design.

Sizes

FlutButton provides several sizes of buttons, each with its own appearance and behavior. You can choose the size that best suits your needs.

Sm

The sm size is the smallest size of the button. It has a height of 32 and a font size of 14.

Md

The md size is the default size of the button. It has a height of 40 and a font size of 16.

Lg

The lg size is the largest size of the button. It has a height of 48 and a font size of 18.

Icon

The icon size is the size of the button when it only contains an icon. It has a height of 40 and a font size of 16.

Custom

The custom size allows you to customize the size of the button. You can set the height and font size to create a unique button design.

On this page