text static method

Response text(
  1. String s, {
  2. int status = 200,
  3. Headers? headers,
  4. Encoding encoding = utf8,
})

Implementation

static Response text(String s,
    {int status = 200, Headers? headers, Encoding encoding = utf8}) {
  final h = headers ?? Headers();
  if (!h.has('content-type')) {
    h.set('content-type', 'text/plain; charset=${encoding.name}');
  }
  final data = encoding.encode(s);
  return Response(status,
      headers: h, body: Stream<List<int>>.value(Uint8List.fromList(data)));
}