mahasMessageBoxWidget function
Implementation
Widget mahasMessageBoxWidget(
List<MahasMessageModel> models, {
bool withMargin = false,
double? marginBottom,
double? marginTop = 3.0,
bool isJustInformation = false,
Duration? showDuration,
bool withScroll = true,
double? percentHeight,
}) {
if (models.isEmpty) return Container();
widget() => SizedBox(
height: percentHeight == null
? null
: MahasDimensions.getHeightPercentSize(percentHeight),
child: Column(
children: [
if (marginTop != null) getSpaceHeight(marginTop),
Container(
margin: withMargin
? EdgeInsets.symmetric(
horizontal: MahasDimensions.getAppBarPadding(),
)
: null,
width: double.infinity,
decoration: BoxDecoration(
color: isJustInformation
? MahasColors.statusBaruColor.withOpacity(.2)
: MahasColors.dangerColor.withOpacity(.2),
borderRadius: BorderRadius.circular(
MahasDimensions.getInputRadius(),
),
),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: MahasDimensions.getHeightPercentSize(1),
horizontal: MahasDimensions.getWidthPercentSize(2.5),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: models
.expand((element) => element.errorMessages)
.map(
(e) => getCustomTextWithoutMaxLine(e,
align: TextAlign.start),
)
.toList(),
),
),
),
if (marginBottom != null) getSpaceHeight(marginBottom),
],
),
);
if (!withScroll) return widget();
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: widget(),
);
}