Dart Program: Convert a String into an array

String is List of characters using split(”) predefine method of Dart, we can convert String into list of Character or array

void main() {
  String myString = "HelloFlutter!";
  
  // Convert String to List of Characters
  List<String> charList = myString.split('');

  // Print the result
  print(charList);
}

//In this case Output 
[H, e, l, l, o, F, l, u, t, t, e, r, !]

How to Find length of List in Flutter/Dart

void main() {
  String myString = "Hello, Flutter!";
  
  // Convert String to List of Characters
  List<String> charList = myString.split('');

  // length of the list
  int length = charList.length;

  // Print the result
  print("Length of the list: $length");
}

Leave a Reply

Your email address will not be published. Required fields are marked *

web_horizontal
About Us ♢ Disclaimer ♢ Privacy Policy ♢ Terms & Conditions ♢ Contact Us

Copyright © 2023 ResearchThinker.com. All rights reserved.