tryEncode static method
List<int> ?
tryEncode(
- String? value, {
- StringEncoding type = StringEncoding.utf8,
- bool validateB64Padding = true,
- bool allowUrlSafe = true,
- Base58Alphabets base58alphabets = Base58Alphabets.bitcoin,
Encodes the given value
string into a list of bytes using the specified type
if possible.
The type
parameter determines the encoding type to use, with UTF-8 being the default.
Returns a list of bytes representing the encoded string.
Implementation
static List<int>? tryEncode(String? value,
{StringEncoding type = StringEncoding.utf8,
bool validateB64Padding = true,
bool allowUrlSafe = true,
Base58Alphabets base58alphabets = Base58Alphabets.bitcoin}) {
if (value == null) return null;
try {
return encode(value,
type: type,
allowUrlSafe: allowUrlSafe,
validateB64Padding: validateB64Padding,
base58alphabets: base58alphabets);
} catch (e) {
return null;
}
}