digital

// Convert a string to an integer or a double floating-point object using the parse() method of int and double:
print(int.parse(The '42') = =42); // true
print(int.parse('0x42') = =66); // true
print(double.parse('0.50') = =0.5); // true
  
// Specify the base base of integers by adding the radix parameter
print(int.parse(The '42', radix: 16) = =66); // true

// Use the toString() method to convert an integer or a double floating-point type to a string.
print(42.toString() == The '42'); // true
print(123.456.toString() == '123.456'); // true

// Use toStringAsFixed(). Specify the number to the right of the decimal point
print(123.456.toStringAsFixed(2) = ='123.46'); // true

// Use toStringAsPrecision(): Specifies the number of significant digits in the string
print(123.456.toStringAsPrecision(2) = ='1.2 e+2'); // true

print(double.parse('1.2 e+2') = =120.0); // true
Copy the code

string

  // Check if one string contains another string
  print('Never odd or even'.contains('odd')); // true

  // Checks if the string starts with a specific string
  print('Never odd or even'.startsWith('Never')); // true

  // Checks if the string ends with a specific string
  print('Never odd or even'.endsWith('even')); // true

  // Find the position of a particular string within the string
  print('Never odd or even'.indexOf('odd') = =6); // true
  
  // Intercepts a string
  print('Never odd or even'.substring(6.9) = ='odd'); // true

  // Split the string
  print('structured web apps'.split(' ')); // [structured, web, apps]
  print('hello'.split(' ')); // [h, e, l, l, o]

  // Gets a single character in a string
  print('Never odd or even'[0] = ='N'); // true

  // Get a single UTF-16 encoding unit
  var codeUnitList = 'Never odd or even'.codeUnits.toList();
  print(codeUnitList); // [78, 101, 118, 101, 114, 32, 111, 100, 100, 32, 111, 114, 32, 101, 118, 101, 110]
  
  // Case conversion.
  print('structured web apps'.toUpperCase()); // STRUCTURED WEB APPS
  print('STRUCTURED WEB APPS'.toLowerCase()); // structured web apps
  
  // Use trim() to remove leading and trailing Spaces
  print(' hello '.trim()); // 'hello'
  
  // isEmpty checks if a string isEmpty (length 0)
  print(' '.isEmpty); // true
  print(' '.isNotEmpty); // true
  
  // String substitution
  var str = 'Hello, NAME, NAME! ';
  // Replace the first matching
  var str1 = str.replaceFirst(RegExp('NAME'), 'Bob'); 
  // Replace all matches
  var str2 = str.replaceAll(RegExp('NAME'), 'Bob'); 
  // Specify range replacement
  var str3 = str.replaceRange(7.11.'Bob');
  print(str1); // Hello, Bob, NAME!
  print(str2); // Hello, Bob, Bob!
  print(str3); // Hello, Bob, NAME!
  
  // Construct a string
    var sb = StringBuffer(a); sb .. write('Use a StringBuffer for ')
    ..writeAll(['efficient'.'string'.'creation'].' ')
    ..write('. ');
  print(sb.toString()); // Use a StringBuffer for efficient string creation.
Copy the code