alertDialog method
Implementation
AlertDialog alertDialog(BuildContext context) {
var dots = 0;
if (inAppModel.richContent!.img1 != null) dots++;
if (inAppModel.richContent!.img2 != null) dots++;
if (inAppModel.richContent!.img3 != null) dots++;
return AlertDialog(
backgroundColor: HexColor.fromHex(inAppModel.backgroundColor ?? "#FFF"),
title: Text(
inAppModel.title ?? "",
textAlign: TextAlign.center,
style: TextStyle(
color: HexColor.fromHex(inAppModel.titleFontColor ?? "#000")),
),
content: SizedBox(
height: 310,
child: Column(
children: [
inAppModel.richContent!.carousel!
? SizedBox(
height: 220,
width: 400,
child: ImageSlideshow(
width: 533,
height: 200,
initialPage: 0,
indicatorColor: dots < 2
? Colors.transparent
: HexColor.fromHex(
inAppModel.backgroundColor ?? "#0000FF"),
indicatorBackgroundColor: Colors.grey,
children: [
if (inAppModel.richContent!.img1 != null)
Image.network(
inAppModel.richContent!.img1!,
fit: BoxFit.cover,
),
if (inAppModel.richContent!.img2 != null)
Image.network(
inAppModel.richContent!.img2!,
fit: BoxFit.cover,
),
if (inAppModel.richContent!.img3 != null)
Image.network(
inAppModel.richContent!.img3!,
fit: BoxFit.cover,
),
],
/// Called whenever the page in the center of the viewport changes.
onPageChanged: (value) {
debugPrint('Page changed: $value');
},
/// Auto scroll interval.
/// Do not auto scroll with null or 0.
/// Loops back to first slide.
isLoop: inAppModel.richContent!.img1 != null &&
inAppModel.richContent!.img2 != null &&
inAppModel.richContent!.img3 != null,
),
)
: Container(),
const SizedBox(
height: 25,
),
Text(
inAppModel.body ?? "",
textAlign: TextAlign.center,
style: TextStyle(
color: HexColor.fromHex(inAppModel.bodyFontColor ?? "#000")),
),
],
),
),
actionsAlignment: MainAxisAlignment.spaceBetween,
actions: inAppModel.btnLeftTxt == null || inAppModel.btnRightTxt == null
? [
if (inAppModel.btnLeftTxt != null)
Center(
child: TextButton(
child: Text(
inAppModel.btnLeftTxt ?? "",
style: TextStyle(
color: HexColor.fromHex(
inAppModel.btnLeftTxtColor ?? "#000")),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
HexColor.fromHex(
inAppModel.btnLeftBgColor ?? "#FFF")),
),
onPressed: () {
Navigator.of(context).pop();
if (inAppModel.btnLeftActionLink != null) {
_action(inAppModel.btnLeftActionType,
inAppModel.btnLeftActionLink);
}
},
),
),
if (inAppModel.btnRightTxt != null)
Center(
child: TextButton(
child: Text(
inAppModel.btnRightTxt ?? "",
style: TextStyle(
color: HexColor.fromHex(
inAppModel.btnRightTxtColor ?? "#000")),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
HexColor.fromHex(
inAppModel.btnRightBgColor ?? "#FFF")),
),
onPressed: () {
Navigator.of(context).pop();
if (inAppModel.btnRightActionLink != null) {
_action(inAppModel.btnRightActionType,
inAppModel.btnRightActionLink);
}
},
),
),
]
: [
Padding(
padding: const EdgeInsets.only(left: 16),
child: TextButton(
child: Text(
inAppModel.btnLeftTxt ?? "",
style: TextStyle(
color: HexColor.fromHex(
inAppModel.btnLeftTxtColor ?? "#000")),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
HexColor.fromHex(inAppModel.btnLeftBgColor ?? "#FFF")),
),
onPressed: () {
Navigator.of(context).pop();
if (inAppModel.btnLeftActionLink != null) {
_action(inAppModel.btnLeftActionType,
inAppModel.btnLeftActionLink);
}
},
),
),
Padding(
padding: const EdgeInsets.only(right: 16),
child: TextButton(
child: Text(
inAppModel.btnRightTxt ?? "",
style: TextStyle(
color: HexColor.fromHex(
inAppModel.btnRightTxtColor ?? "#000")),
),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
HexColor.fromHex(inAppModel.btnRightBgColor ?? "#FFF")),
),
onPressed: () {
Navigator.of(context).pop();
if (inAppModel.btnRightActionLink != null) {
_action(inAppModel.btnRightActionType,
inAppModel.btnRightActionLink);
}
},
),
),
],
);
}