Touchable
The C2CTouchable widget is a customizable button component for Flutter apps. It supports adaptive styling, making it suitable for both Material (Android) and Cupertino (iOS) design themes. This widget extends StatefulWidget and provides flexibility through various properties like background colors, padding, border radius, and handling of disabled states. It also supports different types of user interactions such as tap and long press.
Example Usage
C2CTouchable(
onPressed: () {
// Handle button press
},
backgroundColor: Colors.blue,
disabledBackgroundColor: Colors.grey,
padding: EdgeInsets.all(10),
borderRadius: BorderRadius.circular(8),
child: Text('Click Me'),
)
Properties
| Property | Description | Type |
|---|---|---|
child | The widget inside the button. Can be a String or a Widget. | dynamic |
backgroundColor | The button's background color. | Color? |
disabledBackgroundColor | Background color when the button is disabled. | Color? |
disabled | Whether the button is disabled. | bool |
onPressed | Callback function when the button is pressed. | void Function()? |
onLongPress | Callback function when the button is long-pressed. | void Function()? |
type | The button style type (adaptive, material, cupertino). | StyleType |
focusedBackgroundColor | (iOS only) Background color when the button is focused. | Color? |
padding | Padding around the button's child. | EdgeInsets? |
borderRadius | The radius of the button's corners. | BorderRadius? |
clipBehavior | What to do with visuals outside the button's bounds. | Clip |