I have the following code:-
switch (code) {
case "BleDisconnectedException":
throw BleDisconnectedException(msg, details);
case "BleGattException":
throw BleGattException(msg, details);
case "BleGattCallbackTimeoutException":
throw BleGattCallbackTimeoutException(msg, details);
case "BleCharacteristicNotFoundException":
throw BleCharacteristicNotFoundException(msg, details);
case "BleGattCannotStartException":
throw BleGattCannotStartException(msg, details);
default:
throw e;
}
How do I make dart automatically do the switch-case, i.e. call the class constructor by its name, provided as a String
?
As I know in current Dart is not possible, but you can do something like this: