mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 05:16:40 +00:00
Documentation update for LineSplitter
Adding example of usage Closes https://github.com/dart-lang/sdk/pull/47621 https://github.com/dart-lang/sdk/pull/47621 GitOrigin-RevId: e2509b50cf4a7285a2ad1aa4435ab5dc178eb634 Change-Id: I1cd79309799d8361c359c4e5194473bc4e46463b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219280 Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
56035a7df0
commit
93c2aad57d
|
@ -10,12 +10,31 @@ const int _CR = 13;
|
|||
|
||||
/// A [StreamTransformer] that splits a [String] into individual lines.
|
||||
///
|
||||
/// A line is terminated by either a CR (U+000D), a LF (U+000A), a
|
||||
/// CR+LF sequence (DOS line ending),
|
||||
/// and a final non-empty line can be ended by the end of the string.
|
||||
/// A line is terminated by either:
|
||||
/// * a CR, carriage return: U+000D ('\r')
|
||||
/// * a LF, line feed (Unix line break): U+000A ('\n') or
|
||||
/// * a CR+LF sequence (DOS/Windows line break), and
|
||||
/// * a final non-empty line can be ended by the end of the input.
|
||||
///
|
||||
/// The returned lines do not contain the line terminators.
|
||||
|
||||
/// The resulting lines do not contain the line terminators.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// const splitter = LineSplitter();
|
||||
/// const sampleText =
|
||||
/// 'Dart is: \r an object-oriented \n class-based \n garbage-collected '
|
||||
/// '\r\n language with C-style syntax \r\n';
|
||||
///
|
||||
/// final sampleTextLines = splitter.convert(sampleText);
|
||||
/// for (var i = 0; i < sampleTextLines.length; i++) {
|
||||
/// print('$i: ${sampleTextLines[i]}');
|
||||
/// }
|
||||
/// // 0: Dart is:
|
||||
/// // 1: an object-oriented
|
||||
/// // 2: class-based
|
||||
/// // 3: garbage-collected
|
||||
/// // 4: language with C-style syntax
|
||||
/// ```
|
||||
class LineSplitter extends StreamTransformerBase<String, String> {
|
||||
const LineSplitter();
|
||||
|
||||
|
|
Loading…
Reference in a new issue