SunmiTextStyle constructor
SunmiTextStyle({})
Factory constructor to create a SunmiTextStyle object with optional customizations.
Validates the fontSize to ensure it falls within the acceptable range of 1 to 96. Throws an ArgumentError if the size is invalid.
Default values:
Implementation
factory SunmiTextStyle({
int fontSize = 24,
SunmiPrintAlign align = SunmiPrintAlign.LEFT,
bool bold = false,
bool underline = false,
bool strikethrough = false,
bool italic = false,
bool reverse = false,
}) {
// Validate fontSize to ensure it's within the range of 1 to 96.
if (fontSize < 1 || fontSize > 96) {
throw ArgumentError(
'Invalid fontSize: $fontSize. Must be between 1 and 96.',
);
}
// Return a new instance of SunmiTextStyle with provided or default values.
return SunmiTextStyle._internal(
align: align,
bold: bold,
fontSize: fontSize,
italic: italic,
reverse: reverse,
strikethrough: strikethrough,
underline: underline,
);
}