2023/6/1/Dart/Flutter/A case where you want to get each character from a string and use it with an index

 

const String sampleStr = 'abcde';

例えば上記のような文字列があったときに、一文字ずつ取り出して使いたい場合、下記のようにsplitメソッドを使って各文字を要素として持つList<String>を取得できます。

For example, if we have a string like the one above and want to extract and use each character, we can use the split method to get a List<String> that has each character