ESewaPaymentButton constructor

ESewaPaymentButton(
  1. ESewaPnp esewa, {
  2. Key? key,
  3. required double amount,
  4. required String productId,
  5. required String productName,
  6. required String callBackURL,
  7. required dynamic onSuccess(
    1. ESewaResult result
    ),
  8. required dynamic onFailure(
    1. ESewaPaymentException exception
    ),
  9. Widget labelBuilder(
    1. double amount,
    )?,
  10. double? height,
  11. double? width,
  12. Color? color,
})

Implementation

ESewaPaymentButton(
  this.esewa, {
  Key? key,
  required this.amount,
  required this.productId,
  required this.productName,
  required this.callBackURL,
  required this.onSuccess,
  required this.onFailure,
  this.labelBuilder,
  this.height,
  this.width,
  this.color,
}) {
  this._esewaLogo = color != null
      ? (color!.computeLuminance() > 0.5
          ? Image.asset(
              "assets/esewa/logo_dark.png",
              height: 24,
              width: 54,
            )
          : Image.asset(
              "assets/esewa/logo.png",
              height: 24,
              width: 54,
            ))
      : Image.asset(
          "assets/esewa/logo.png",
          height: 24,
          width: 54,
        );

  this._textColor = color != null
      ? (color!.computeLuminance() < 0.5
          ? Color(0xFFFFFFFF)
          : Color(0xFF000000))
      : Color(0xFFFFFFFF);

  this._label = this.labelBuilder != null
      ? this.labelBuilder!(
          this.amount,
          _esewaLogo,
        )
      : Row(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              "Pay now with ",
            ),
            _esewaLogo!,
          ],
        );
}