var str = '字符串的长度';
print('打印==${str.length}'); //打印==6
var str1 = 'hello dart';
print('打印==${str1.length}'); //打印==10
str.isEmpty为空true 不为空false
var str = 'hello dart';
print("是否为空==${str.isEmpty}");//是否为空==false
var str1 = '';
print("是否为空==${str1.isEmpty}");//是否为空==true
str.isNotEmpty 为空false 不为空true
var str = 'hello dart';
print("是否不为空==${str.isNotEmpty}");//是否不为空==true
var str1 = '';
print("是否不为空==${str1.isNotEmpty}");//是否不为空==false
如判断是否是以https开头,则可以这样判断
如果是则返回true ,否则返回false
var str = 'https://www.baidu.com/';
print("打印==${str.startsWith('https')}"); //打印==true
var str = 'https://www.baidu.com/';
print("打印==${str.endsWith('https')}"); //打印==false
如果包含则返回true ,否则返回false
var str = 'hello dart';
print("打印==${str.contains('hello')}"); //打印==true
var str = 'hello dart';
print("打印==${str.substring(0, 5)}"); //打印==hello
var str = 'hello dart';
print("打印==${str.indexOf('o')}"); //打印==4
print("打印==${str.indexOf('l')}"); //打印==2
print("打印==${str.indexOf('p')}"); //打印==-1
var str = 'hello dart';
print("打印==${str.lastIndexOf('o')}"); //打印==4
print("打印==${str.lastIndexOf('l')}"); //打印==3
print("打印==${str.lastIndexOf('p')}"); //打印==-1
var str = 'Hello Dart';
print("打印==${str.toLowerCase()}"); //打印==hello dart
var str = 'Hello Dart';
print("打印==${str.toUpperCase()}"); //打印==HELLO DART
注意:字符中间的空格不会清除,只会去除前面和后面的空格
var str = ' Hello Dart ';
print("打印==${str.trim()}"); //打印==Hello Dart
print('打印==${str.length}');//打印==23
print('打印==${str.trim().length}');//打印==13
var str = ' Hello Dart ';
print("打印==${str.trimLeft()}"); //打印==Hello Dart
print('打印==${str.length}'); //打印==23
print('打印==${str.trimLeft().length}'); //打印==18
var str = ' Hello Dart ';
print("打印==${str.trimRight()}"); //打印== Hello Dart
print('打印==${str.length}'); //打印==25
print('打印==${str.trimRight().length}'); //打印==18
var str = 'Hello-dart-world';
var array = str.split("-");
print("打印==$array"); //打印==[Hello, dart, world]
var str = 'Hello-dart-world';
print("打印==${str.replaceAll('dart', 'hhh')}"); //打印==Hello-hhh-world