Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [2.1.0] - 04/03/2025

- Added TextAlign & Overflow options for title & text (or body).
- Updated README

## [2.0.1] - 06/03/2023

- Updated README
Expand Down
55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,35 @@ CoolAlert.show(

### CoolAlert Class


| Attribute | Data type | Description | Default Value |
|:----------------------|:-------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------:|
| context| BuildContext | @required | Null |
| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null
title| String | Set a custom title for dialog | Based on the CoolAlertType selected| |
| text| String | Set the description text of the dialog. | Null |
| widget| Widget | Set any you expect widget of the dialog. | Null |
| confirmBtnText | String | Text of confirm button | 'Ok' | |
| confirmBtnTap| Function | Function that handle click of confirm button | () => Navigator.pop(context)|
| confirmBtnColor| Color | Color of confirm Button | Theme.of(context).primaryColor | |
| cancelBtnText| String | Text of cancel button | 'Cancel' |
| cancelBtnTap| Function | Function that handle click of cancel button | () => Navigator.pop(context)
| barrierDismissible| bool | Dismiss dialog on touch overlay | true
| animType | CoolAlertAnimType| Type of dialogue enter animation | CoolAlertAnimType.scale|
| backgroundColor | Color| Background color of the animation | Color(0xFF515C6F)|
| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0)|
| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0)|
| flareAsset | String | Custom flare asset | "animation.flr" |
| flareAnimationName | String | The name of the flare animation to play | "play" |
| lottieAsset | String | Custom lottie asset | "animation.json" |
|autoCloseDuration|Duration|Determines how long the dialog stays open for before closing|Null|
|width|double|Dialog width|MediaQuery.of(context).size.width|
|loopAnimation|boolean|Determines if the animation should loop or not|false|
|closeOnConfirmBtnTap|boolean|Detemines if dialog closes when the confirm button is tapped|true|
|reverseBtnOrder|boolean|Reverse the order of the buttons|false|
| Attribute | Data type | Description | Default Value |
|:---------------------|:------------------|:--------------------------------------------------------------------------------|:-------------------------------------------------------------------------:|
| context | BuildContext | @required | Null |
| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null
title | String | Set a custom title for dialog | Based on the CoolAlertType selected | |
| text | String | Set the description text of the dialog. | Null |
| widget | Widget | Set any you expect widget of the dialog. | Null |
| confirmBtnText | String | Text of confirm button | 'Ok' | |
| confirmBtnTap | Function | Function that handle click of confirm button | () => Navigator.pop(context) |
| confirmBtnColor | Color | Color of confirm Button | Theme.of(context).primaryColor | |
| cancelBtnText | String | Text of cancel button | 'Cancel' |
| cancelBtnTap | Function | Function that handle click of cancel button | () => Navigator.pop(context)
| barrierDismissible | bool | Dismiss dialog on touch overlay | true
| animType | CoolAlertAnimType | Type of dialogue enter animation | CoolAlertAnimType.scale |
| backgroundColor | Color | Background color of the animation | Color(0xFF515C6F) |
| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0) |
| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0) |
| flareAsset | String | Custom flare asset | "animation.flr" |
| flareAnimationName | String | The name of the flare animation to play | "play" |
| lottieAsset | String | Custom lottie asset | "animation.json" |
| autoCloseDuration | Duration | Determines how long the dialog stays open for before closing | Null |
| width | double | Dialog width | MediaQuery.of(context).size.width |
| loopAnimation | boolean | Determines if the animation should loop or not | false |
| closeOnConfirmBtnTap | boolean | Detemines if dialog closes when the confirm button is tapped | true |
| reverseBtnOrder | boolean | Reverse the order of the buttons | false |
| titleTextAlign | TextAlign | Text alignment for title | TextAlign.center |
| titleOverflow | TextOverflow | Text overflow for title | Null |
| textTextAlign | TextAlign | Text alignment for text | TextAlign.center |
| textOverflow | TextOverflow | Text overflow for text | Null |



Expand Down
16 changes: 16 additions & 0 deletions lib/cool_alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,21 @@ class CoolAlert {
/// TextStyle for title
TextStyle? titleTextStyle,

/// TextOverflow for title
TextOverflow? titleOverflow,

/// TextAlign for title
TextAlign titleTextAlign = TextAlign.center,

/// TextStyle for text
TextStyle? textTextStyle,

/// TextOverflow for text
TextOverflow? textOverflow,

/// TextAlign for text
TextAlign textTextAlign = TextAlign.center,

/// Determines if cancel button is shown or not
bool showCancelBtn = false,

Expand Down Expand Up @@ -129,7 +141,11 @@ class CoolAlert {
confirmBtnTextStyle: confirmBtnTextStyle,
cancelBtnTextStyle: cancelBtnTextStyle,
titleTextStyle: titleTextStyle,
titleOverflow: titleOverflow,
titleTextAlign: titleTextAlign,
textTextStyle: textTextStyle,
textTextAlign: textTextAlign,
textOverflow: textOverflow,
showCancelBtn: showCancelBtn,
borderRadius: borderRadius,
backgroundColor: backgroundColor,
Expand Down
8 changes: 8 additions & 0 deletions lib/src/models/cool_alert_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ class CoolAlertOptions {
TextStyle? confirmBtnTextStyle;
TextStyle? cancelBtnTextStyle;
TextStyle? titleTextStyle;
TextAlign? titleTextAlign;
TextOverflow? titleOverflow;
TextStyle? textTextStyle;
TextAlign? textTextAlign;
TextOverflow? textOverflow;
bool? showCancelBtn;
double? borderRadius;
Color? backgroundColor;
Expand Down Expand Up @@ -44,7 +48,11 @@ class CoolAlertOptions {
this.confirmBtnTextStyle,
this.cancelBtnTextStyle,
this.titleTextStyle,
this.titleTextAlign,
this.titleOverflow,
this.textTextStyle,
this.textTextAlign,
this.textOverflow,
this.showCancelBtn,
this.borderRadius,
this.backgroundColor,
Expand Down
5 changes: 4 additions & 1 deletion lib/src/widgets/cool_alert_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class CoolAlertContainer extends StatelessWidget {
Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
textAlign: options.titleTextAlign,
overflow: options.titleOverflow,
),
);
}
Expand All @@ -152,8 +154,9 @@ class CoolAlertContainer extends StatelessWidget {
}
return Text(
text ?? '',
textAlign: TextAlign.center,
textAlign: options.textTextAlign,
style: options.textTextStyle,
overflow: options.textOverflow,
);
}
}
Expand Down