topBar function
Widget
topBar({
- VoidCallback? onBack,
- required BuildContext context,
- bool isCancelPayment = true,
Top bar widget with optional back button and close button
Implementation
Widget topBar({
VoidCallback? onBack, // optional back button
required BuildContext context, // needed for snackbar/navigation
bool isCancelPayment = true, // determines snackbar icon & message
}) {
return Container(
height: 50,
padding: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(.05),
blurRadius: 8,
offset: const Offset(0, 4),
)
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
/// BACK BUTTON
if (onBack != null)
IconButton(
icon: const Icon(CupertinoIcons.arrow_left_circle),
onPressed: onBack,
)
else
const SizedBox(width: 48),
/// CLOSE BUTTON
IconButton(
icon: const Icon(Icons.close),
onPressed: () {
appSnackbar(
context,
isCancelPayment
? "Payment cancelled"
: "Payment issue occurred",
icon: isCancelPayment ? Icons.close : Icons.info_outline,
iconColor: isCancelPayment ? Colors.red : Colors.blue,
backToRoot: true,
);
},
), ],
),
);
}