Button
CometChatButton
is a widget representing a button with optional icon and text. It provides customisable button styles through the buttonStyle
object and handles tap events with onTap
callback.
Usage
- Dart
CometChatButton(
text: "Button",
buttonStyle: CometChatButtonStyle(
background: Colors.red,
),
onTap: (context) {
// Action on button tap goes here
},
);
Properties
Properties | Type | Description |
---|---|---|
text | string | used to set the text for the button |
hoverText | string | used to set the hover text for the button |
iconUrl | string | used to set the url for the icon |
iconPackage | string | used to set the package name for the icon |
buttonStyle | ButtonStyle | used to set the style for the button |
onTap | Function(BuildContext) | is a callback which gets called when button is clicked |
Button Style
Properties | Type | Description |
---|---|---|
textStyle | TextStyle | sets TextStyle for text |
iconTint | Color | sets color for icon |
iconBackground | Color | sets background color for icon |
iconBorder | BoxBorder | sets border for icon |
iconBorderRadius | double | sets border radius for icon |
iconHeight | double | sets height for icon |
iconWidth | double | sets width for icon |
width | double | sets width |
height | double | sets height |
background | Color | sets backGround color |
border | BoxBorder | sets border |
borderRadius | double | sets border radius |
gradient | Gradient | sets backGround gradient |
Example
- Dart
ButtonStyle(
textStyle: TextStyle(),
iconTint: Colors.white,
iconBackground: Colors.white,
iconBorder: Border.all(),
iconBorderRadius: 50,
width: 100,
height: 100,
background: Colors.white,
border: Border.all(),
borderRadius: BorderRadius.circular(20),
gradient: LinearGradient(),
);