stringbuffer in dart code example

Example 1: alternate of string class in dart, stringBuffer dart, string buffer dart, string buffer,stringbuffer,stringBuffer

var sb = StringBuffer();
sb
  ..write('Use a StringBuffer for ')
  ..writeAll(['efficient', 'string', 'creation'], ' ')
  ..write('.');

var fullString = sb.toString();

assert(fullString ==
    'Use a StringBuffer for efficient string creation.');

Example 2: stringbuffer in dart

void main() {    StringBuffer sb = new StringBuffer('Website: ');      sb.write('woolha');    sb.writeCharCode(46);    sb.writeln('com');    sb.write('Tags: ');    sb.writeAll({'Dart', 'Flutter'}, ',');      print('length: ${sb.length}');    print('isEmpty: ${sb.isEmpty}');    print('isNotEmpty: ${sb.isNotEmpty}');    print('----------\n${sb.toString()}\n----------');      print('CLEAR THE BUFFER');    sb.clear();      print('length: ${sb.length}');    print('isEmpty: ${sb.isEmpty}');    print('isNotEmpty: ${sb.isNotEmpty}');    print('----------\n${sb.toString()}\n----------');  }

Tags:

Misc Example