一、Number类型转换成String类型

 

Dart Number与String类型之间的转换,Number类型转换成String类型 toString()

 

 var myNum=12;

 var str=myNum.toString();

 print(str is String);

 

 

二、String类型转成Number类型

 

Dart String与Number类型之间的转换 int.parse() double.parse()

 

  String str='123';

  var myNum=int.parse(str);

  print(myNum is int);
  
  

  String str='123.1';

  var myNum=double.parse(str);

  print(myNum is double);
  
  
  

 String price='12';

  var myNum=double.parse(price);

  print(myNum);

  print(myNum is double);