Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue -Dismiss Alert Box on clicking outside the Alert Box #2 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
114 changes: 63 additions & 51 deletions lib/rich_alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,28 @@ class RichAlertDialog extends StatefulWidget {
/// Higher values mean more blurred overlays.
final double blurValue;

// Specifies the opacity of the screen overlay
// Specifies the opacity of the screen overlay
final double backgroundOpacity;

/// (Optional) User defined icon for the dialog. Advisable to use the
/// default icon matching the dialog type.
final Icon dialogIcon;

RichAlertDialog({
Key key,
@required this.alertTitle,
@required this.alertSubtitle,
@required this.alertType,
this.actions,
this.blurValue,
this.backgroundOpacity,
this.dialogIcon,
}) : super(key: key);
/// if true the Alert Box will dismiss on clicking outside the Alert Box.
/// It defaults to true
final bool barrierDismissible;

RichAlertDialog(
{Key key,
@required this.alertTitle,
@required this.alertSubtitle,
@required this.alertType,
this.actions,
this.blurValue,
this.backgroundOpacity,
this.dialogIcon,
this.barrierDismissible = true})
: super(key: key);

createState() => _RichAlertDialogState();
}
Expand Down Expand Up @@ -97,46 +102,53 @@ class _RichAlertDialogState extends State<RichAlertDialog> {
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Expanded(
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Positioned(
bottom: 0.0,
child: Container(
height: dialogHeight,
width: deviceWidth * 0.9,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0)),
),
color: Colors.white,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: dialogHeight / 4),
widget.alertTitle,
SizedBox(height: dialogHeight / 10),
widget.alertSubtitle,
SizedBox(height: dialogHeight / 10),
widget.actions != null &&
widget.actions.isNotEmpty
? _buildActions()
: _defaultAction(context),
],
),
),
),
),
Positioned(
bottom: dialogHeight - 50,
child: widget.dialogIcon != null
? widget.dialogIcon
: _defaultIcon(),
),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: widget.barrierDismissible
? () => Navigator.of(context).pop()
: null,
child: Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Positioned(
bottom: 0.0,
child: Container(
height: dialogHeight,
width: deviceWidth * 0.9,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0)),
),
color: Colors.white,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
SizedBox(height: dialogHeight / 4),
widget.alertTitle,
SizedBox(height: dialogHeight / 10),
widget.alertSubtitle,
SizedBox(height: dialogHeight / 10),
widget.actions != null &&
widget.actions.isNotEmpty
? _buildActions()
: _defaultAction(context),
],
),
),
),
),
Positioned(
bottom: dialogHeight - 50,
child: widget.dialogIcon != null
? widget.dialogIcon
: _defaultIcon(),
),
],
))),
),
],
),
Expand Down