PieceSet.text constructor

PieceSet.text({
  1. required Map<String, String> strings,
  2. TextStyle? style,
})

Specifies a set of WidgetBuilders that render Text widgets, using map of piece keys mapped to strings. Hint: this works with emojis. See the example app.

Implementation

factory PieceSet.text({required Map<String, String> strings, TextStyle? style}) {
  Map<String, WidgetBuilder> pieces = {};
  strings.forEach((k, v) {
    pieces[k] = (BuildContext context) => Text(v, style: style);
  });
  return PieceSet(pieces: pieces);
}