opt static method

Tuple2<String?, String?> opt({
  1. String? ser,
  2. String? deser,
})

Implementation

static Tuple2<String?, String?> opt({String? ser, String? deser}) {
  String? s;
  String? d;
  // final type = ser.type.nullable(ser.nullable);
  if (ser != null) {
    s = '[if($ph != null) $ser]';
  } else {
    s = '[if($ph !=null) $ph]';
  }
  if (deser != null) {
    d = "($ph as List?)?.map((e) { return ${deser.replaceAll(ph, 'e')}; }).firstOrNull";
  } else {
    d = '($ph as List?)?.firstOrNull';
  }
  return Tuple2(s, d);
}