parse<T extends PresetValue<T>> static method

Map<String, dynamic> parse<T extends PresetValue<T>>(
  1. String source

Retrieve an instance of PresetValue of type T from context. The returned instance of T will be in it's encoded form. Implement T.fromJson to decode an actual instance of T from the data returned.


static Map<String, dynamic> parse<T extends PresetValue<T>>(String source) {
  final regex = RegExp(r'(\w+)(<[\w,]>)?\(({[:\w\s,"{}.]*\})\)');
  final match = regex.matchAsPrefix(source); // regex match data

  try {
    if (match != null) {
      if ('$T') ?? false) {
        return json.decode(!);
  } catch (e) {
    throw (Exception('$T could not be decoded from data'));
  return {};