Skip to content

Commit 7320d1a

Browse files
committed
Pass a language version to DartFormatter().
We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402). That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory. This updates the call to `DartFormatter()` to pass in the latest language version. If there's a more specific version that should be used, let me know and I'll update the PR.
1 parent 499dabc commit 7320d1a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

discoveryapis_generator/lib/src/utils.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import 'package:path/path.dart';
1010
final _cleanRegEx = RegExp(r'[^\w$]');
1111
String _cleanName(String name) => name.replaceAll(_cleanRegEx, '_');
1212

13-
final _formatter = DartFormatter(lineEnding: '\n', pageWidth: 80);
13+
final _formatter = DartFormatter(
14+
languageVersion: DartFormatter.latestLanguageVersion,
15+
lineEnding: '\n',
16+
pageWidth: 80);
1417

1518
String formatSource(String source) => _formatter.format(source);
1619

discoveryapis_generator/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
_discoveryapis_commons: ^1.0.0
1212
args: ^2.5.0
1313
collection: ^1.16.0
14-
dart_style: ^2.3.0
14+
dart_style: ^2.3.7
1515
http: ^1.0.0
1616
meta: ^1.2.4
1717
path: ^1.3.3

0 commit comments

Comments
 (0)