builder method

  1. @override
Widget builder(
  1. BuildContext context,
  2. PaymentViewModel model,
  3. Widget? child
)

A function that builds the UI to be shown from the ViewModel - Required

viewModel is the ViewModel passed in and child is the staticChildBuilder result

Implementation

@override
Widget builder(BuildContext context, PaymentViewModel model, Widget? child) {
  return MaterialApp(
    navigatorKey: StackedService.navigatorKey,
    home: Scaffold(
      backgroundColor: Colors.white,
      appBar: CustomAppBar(title: "", showBackButton: false),
      body:
          model.isForm
              ? cardWidget(context, model)
              : model.isFailed
              ? paymentFailed(model)
              : model.isSuccess
              ? paymentSuccess()
              : const SizedBox(), // fallback if none match
    ),
  );
}