fromKey static method

Widget fromKey(
  1. String key, {
  2. double? width,
  3. double? height,
  4. BoxFit fit = BoxFit.contain,
  5. bool onDark = false,
  6. String? semanticsLabel,
  7. Widget? fallback,
})

Builds a logo from a snake_case payment method key such as pay_shap.

Renders fallback (or an empty SizedBox) if the key is unknown.

Implementation

static Widget fromKey(
  String key, {
  double? width,
  double? height,
  BoxFit fit = BoxFit.contain,
  bool onDark = false,
  String? semanticsLabel,
  Widget? fallback,
}) {
  final method = PeachPaymentMethod.fromKey(key);
  if (method == null) {
    return fallback ?? SizedBox(width: width, height: height);
  }
  return PeachPaymentMethodLogo(
    method,
    width: width,
    height: height,
    fit: fit,
    onDark: onDark,
    semanticsLabel: semanticsLabel,
  );
}