validateConfig method
Validate button configuration
Throws ArgumentError if configuration is invalid
Implementation
void validateConfig(MFGooglePayButtonConfig config) {
// Validate buttonType
const validButtonTypes = {
MFButtonType.BUY,
MFButtonType.BOOK,
MFButtonType.CHECKOUT,
MFButtonType.DONATE,
MFButtonType.ORDER,
MFButtonType.PAY,
MFButtonType.SUBSCRIBE,
MFButtonType.PLAIN,
};
if (!validButtonTypes.contains(config.buttonType)) {
throw ArgumentError(
'buttonType must be one of MFButtonType constants (PAY, BUY, BOOK, CHECKOUT, DONATE, ORDER, SUBSCRIBE, PLAIN). Got: ${config.buttonType}');
}
// Validate buttonTheme
const validButtonThemes = {
MFButtonTheme.DARK,
MFButtonTheme.LIGHT,
};
if (!validButtonThemes.contains(config.buttonTheme)) {
throw ArgumentError(
'buttonTheme must be one of MFButtonTheme constants (DARK, LIGHT). Got: ${config.buttonTheme}');
}
// Validate cornerRadius
if (config.cornerRadius < 0) {
throw ArgumentError(
'cornerRadius must be non-negative. Got: ${config.cornerRadius}');
}
}