Block.fromString constructor

Block.fromString(
  1. Iterable<String> bags, {
  2. Encoding encoding = utf8,
})

Creates a Block from a collection of strings.

Each string in bags is encoded using the specified encoding (UTF-8 by default) and added to the block.

Example:

final textBlock = Block.fromString(['Hello', ' ', 'World']);

Implementation

factory Block.fromString(Iterable<String> bags, {Encoding encoding = utf8}) {
  return Block((updates) {
    for (final bag in bags) {
      updates(encoding.encode(bag).toBytes());
    }
  });
}