Skip to content

Instantly share code, notes, and snippets.

@tailorvj
Last active April 7, 2020 06:25
Show Gist options
  • Save tailorvj/b287f2b94aa5cc7b4e4cd4285a17af38 to your computer and use it in GitHub Desktop.
Save tailorvj/b287f2b94aa5cc7b4e4cd4285a17af38 to your computer and use it in GitHub Desktop.
Dart StringBuffer example
main() {
StringBuffer sb = new StringBuffer('initial_content');
print('sb.length is ${sb.length}');
print('${sb.toString()}\n');
sb.write("_Hello");
sb.writeAll(['_space', '_and', '_more']);
print('sb.length is ${sb.length}');
print('${sb.toString()}\n');
sb.clear();
print('sb.isEmpty? ${sb.isEmpty}\n');
sb.writeAll(['It\'s all', ' fun', ' and', ' games']);
print('sb.length is ${sb.length}');
print('${sb.toString()}\n');
sb.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment