TypeConversion
Type Conversion in Dart
Convert String to Int in Dart
void main() {
String strValue = "1";
print("Type of strValue is ${strValue.runtimeType}");
int intValue = int.parse(strValue);
print("Value of intValue is $intValue");
// This will print the data type of intValue
print("Type of intValue is ${intValue.runtimeType}");
}Convert String to Double in Dart
void main() {
String strValue = "3.14";
print("Type of strValue is ${strValue.runtimeType}");
double doubleValue = double.parse(strValue);
print("Value of doubleValue is $doubleValue");
// This will print the data type of doubleValue
print("Type of doubleValue is ${doubleValue.runtimeType}");
}
Convert int to String in Dart
int to String in DartUsing toString()
toString()Using String Interpolation
Last updated