Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 804 Bytes

200603.md

File metadata and controls

57 lines (41 loc) · 804 Bytes

dart 常用数据类型转换

转化布尔值

Bool flag = 0.1 == 0.2; // false

字符串转数值

String str = "1";
double num0 = double.parse(str); // 1.0
int num1 = int.parse(str); // 1

数值转字符串

String str = 0.toString(); // str

数组转字符串

Sting str = [1, 2, 2].join("");

字符串转数组

List<String> arr = "a-b-c".split("-")

List 转 Set

List<int> arr1 = [1, 2, 3, 1];
Set<int> set = arr1.toSet();

Set 转 List

List<int> arr1 = [1, 2, 3, 1];
Set<int> set = arr1.toSet();
List<int> arr2 = set.toList()