Opacity
The C2CButtonOpacity widget is a customizable button that provides feedback to user interactions like tapping and holding.
On press down, the opacity of button is decreased, dimming it.
Example Usage
import 'package:c2c_core/c2c_core.dart';
import 'package:flutter/material.dart';
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('C2CButtonOpacity')),
body: C2CButtonOpacity(
onPressed: () {
print('Button pressed!');
},
child: 'Submit',
),
),
);
}
}
void main() => runApp(const ExampleApp());
Properties
child
The content of the button. It can be either a String or a Widget.
| Type |
|---|
| dynamic (Widget/String)? |
onPressed
A callback function to be invoked when the button is tapped.
| Type |
|---|
| void Function()? |
borderRadius
The border radius of the button.
| Type |
|---|
| BorderRadius? |
backgroundColor
The background color of the button.
| Type |
|---|
| Color? |
foregroundColor
The foreground (text) color of the button.
| Type |
|---|
| Color? |
disabled
Whether the button is disabled. When disabled, it doesn't respond to user interactions.
| Type |
|---|
| bool |
disabledBackgroundColor
The background color of the button when it's disabled.
| Type |
|---|
| Color? |
disabledForegroundColor
The foreground (text) color of the button when it's disabled.
| Type |
|---|
| Color? |
contentPadding
The padding around the content of the button.
| Type |
|---|
| EdgeInsets? |
leftIcon
A widget to display as the left icon within the button.
| Type |
|---|
| Widget? |
leftIconPadding
Padding for the left icon.
| Type |
|---|
| EdgeInsets? |
rightIcon
A widget to display as the right icon within the button.
| Type |
|---|
| Widget? |
rightIconPadding
Padding for the right icon.
| Type |
|---|
| EdgeInsets? |
isExpanded
Whether the button should expand to fill available space.
| Type |
|---|
| bool? |
onLongPress
A callback function to be invoked when the button is long-pressed.
| Type |
|---|
| void Function()? |
size
The height of the button. (large (52) | medium (48) | small (40) | custom (null)). Default: ButtonSize.large
| Type |
|---|
| ButtonSize? |
textStyle
The text style of the button's content.
| Type |
|---|
| TextStyle? |
contentAlignment
The alignment of the content within the button.
| Type |
|---|
| MainAxisAlignment |
contentBuilder
A custom builder function for the button's content.
| Type |
|---|
| Widget Function(BuildContext)? |
borderSide
The border side of the button.
| Type |
|---|
| BorderSide? |
disabledBorderSide
The border side of the button when it's disabled.
| Type |
|---|
| BorderSide? |
activeOpacity
The opacity level of the button when it's active (tapped or held).
| Type |
|---|
| double? |