@@ -10,12 +10,31 @@ const int _CR = 13;
10
10
11
11
/// A [StreamTransformer] that splits a [String] into individual lines.
12
12
///
13
- /// A line is terminated by either a CR (U+000D), a LF (U+000A), a
14
- /// CR+LF sequence (DOS line ending),
15
- /// and a final non-empty line can be ended by the end of the string.
13
+ /// A line is terminated by either:
14
+ /// * a CR, carriage return: U+000D ('\r')
15
+ /// * a LF, line feed (Unix line break): U+000A ('\n') or
16
+ /// * a CR+LF sequence (DOS/Windows line break), and
17
+ /// * a final non-empty line can be ended by the end of the input.
16
18
///
17
- /// The returned lines do not contain the line terminators.
18
-
19
+ /// The resulting lines do not contain the line terminators.
20
+ ///
21
+ /// Example:
22
+ /// ```dart
23
+ /// const splitter = LineSplitter();
24
+ /// const sampleText =
25
+ /// 'Dart is: \r an object-oriented \n class-based \n garbage-collected '
26
+ /// '\r\n language with C-style syntax \r\n';
27
+ ///
28
+ /// final sampleTextLines = splitter.convert(sampleText);
29
+ /// for (var i = 0; i < sampleTextLines.length; i++) {
30
+ /// print('$i: ${sampleTextLines[i]}');
31
+ /// }
32
+ /// // 0: Dart is:
33
+ /// // 1: an object-oriented
34
+ /// // 2: class-based
35
+ /// // 3: garbage-collected
36
+ /// // 4: language with C-style syntax
37
+ /// ```
19
38
class LineSplitter extends StreamTransformerBase <String , String > {
20
39
const LineSplitter ();
21
40
0 commit comments