Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 42d1f44

Browse files
committed
Fix readme
Align with example/example.dart
1 parent 1587bd7 commit 42d1f44

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@ This package exposes a `StringScanner` type that makes it easy to parse a string
22
using a series of `Pattern`s. For example:
33

44
```dart
5-
import 'dart:math';
5+
import 'dart:math' as math;
66
77
import 'package:string_scanner/string_scanner.dart';
88
99
num parseNumber(String source) {
1010
// Scan a number ("1", "1.5", "-3").
11-
var scanner = StringScanner(source);
11+
final scanner = StringScanner(source);
1212
1313
// [Scanner.scan] tries to consume a [Pattern] and returns whether or not it
1414
// succeeded. It will move the scan pointer past the end of the pattern.
15-
var negative = scanner.scan("-");
15+
final negative = scanner.scan('-');
1616
1717
// [Scanner.expect] consumes a [Pattern] and throws a [FormatError] if it
1818
// fails. Like [Scanner.scan], it will move the scan pointer forward.
19-
scanner.expect(RegExp(r"\d+"));
19+
scanner.expect(RegExp(r'\d+'));
2020
2121
// [Scanner.lastMatch] holds the [MatchData] for the most recent call to
2222
// [Scanner.scan], [Scanner.expect], or [Scanner.matches].
2323
var number = num.parse(scanner.lastMatch[0]);
2424
25-
if (scanner.scan(".")) {
26-
scanner.expect(RegExp(r"\d+"));
27-
var decimal = scanner.lastMatch[0];
25+
if (scanner.scan('.')) {
26+
scanner.expect(RegExp(r'\d+'));
27+
final decimal = scanner.lastMatch[0];
2828
number += int.parse(decimal) / math.pow(10, decimal.length);
2929
}
3030

0 commit comments

Comments
 (0)