Make launguage_version in flutter_tool null safe (#78843)

This commit is contained in:
Jenn Magder 2021-03-23 10:11:07 -07:00 committed by GitHub
parent 72ff553af3
commit 8a0cc1bef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:file/file.dart';
import 'package:package_config/package_config.dart';
@ -62,10 +60,10 @@ LanguageVersion determineLanguageVersion(File file, Package package) {
continue;
}
// Check for a match with the language version.
final Match match = _languageVersion.matchAsPrefix(trimmedLine);
final Match? match = _languageVersion.matchAsPrefix(trimmedLine);
if (match != null) {
final String rawMajor = match.group(1);
final String rawMinor = match.group(2);
final String rawMajor = match.group(1) ?? '';
final String rawMinor = match.group(2) ?? '';
try {
final int major = int.parse(rawMajor);
final int minor = int.parse(rawMinor);