1var string = 'dartlang';
2string.substring(1); // 'artlang'
3string.substring(1, 4); // 'art'
1void main() {
2 String str1 = "Hello World";
3 print("New String: ${str1.substring(6)}");
4
5 // from index 6 to the last index
6 print("New String: ${str1.substring(2,6)}");
7
8 // from index 2 to the 6th index
9}
1void main() {
2 const str = "the quick brown fox jumps over the lazy dog";
3 const start = "quick";
4 const end = "over";
5
6 final startIndex = str.indexOf(start);
7 final endIndex = str.indexOf(end, startIndex + start.length);
8
9 print(str.substring(startIndex + start.length, endIndex)); // brown fox jumps
10}