Unnecessary new (#20138)
* enable lint unnecessary_new
* fix tests
* fix tests
* fix tests
diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart
index de20ccb..72344d2 100644
--- a/packages/flutter_tools/lib/src/android/android_sdk.dart
+++ b/packages/flutter_tools/lib/src/android/android_sdk.dart
@@ -36,8 +36,8 @@
// $ANDROID_HOME/platforms/android-23/android.jar
// $ANDROID_HOME/platforms/android-N/android.jar
-final RegExp _numberedAndroidPlatformRe = new RegExp(r'^android-([0-9]+)$');
-final RegExp _sdkVersionRe = new RegExp(r'^ro.build.version.sdk=([0-9]+)$');
+final RegExp _numberedAndroidPlatformRe = RegExp(r'^android-([0-9]+)$');
+final RegExp _sdkVersionRe = RegExp(r'^ro.build.version.sdk=([0-9]+)$');
/// The minimum Android SDK version we support.
const int minimumAndroidSdkVersion = 25;
@@ -127,13 +127,13 @@
/// Locate NDK within the given SDK or throw [AndroidNdkSearchError].
static AndroidNdk locateNdk(String androidHomeDir) {
if (androidHomeDir == null) {
- throw new AndroidNdkSearchError('Can not locate NDK because no SDK is found');
+ throw AndroidNdkSearchError('Can not locate NDK because no SDK is found');
}
String findBundle(String androidHomeDir) {
final String ndkDirectory = fs.path.join(androidHomeDir, 'ndk-bundle');
if (!fs.isDirectorySync(ndkDirectory)) {
- throw new AndroidNdkSearchError('Can not locate ndk-bundle, tried: $ndkDirectory');
+ throw AndroidNdkSearchError('Can not locate ndk-bundle, tried: $ndkDirectory');
}
return ndkDirectory;
}
@@ -145,14 +145,14 @@
} else if (platform.isMacOS) {
directory = 'darwin-x86_64';
} else {
- throw new AndroidNdkSearchError('Only Linux and macOS are supported');
+ throw AndroidNdkSearchError('Only Linux and macOS are supported');
}
final String ndkCompiler = fs.path.join(ndkDirectory,
'toolchains', 'arm-linux-androideabi-4.9', 'prebuilt', directory,
'bin', 'arm-linux-androideabi-gcc');
if (!fs.isFileSync(ndkCompiler)) {
- throw new AndroidNdkSearchError('Can not locate GCC binary, tried $ndkCompiler');
+ throw AndroidNdkSearchError('Can not locate GCC binary, tried $ndkCompiler');
}
return ndkCompiler;
@@ -193,7 +193,7 @@
final int suitableVersion = versions
.firstWhere((int version) => version >= 9, orElse: () => null);
if (suitableVersion == null) {
- throw new AndroidNdkSearchError('Can not locate a suitable platform ARM sysroot (need android-9 or newer), tried to look in $platformsDir');
+ throw AndroidNdkSearchError('Can not locate a suitable platform ARM sysroot (need android-9 or newer), tried to look in $platformsDir');
}
final String armPlatform = fs.path.join(ndkDirectory, 'platforms',
@@ -204,7 +204,7 @@
final String ndkDir = findBundle(androidHomeDir);
final String ndkCompiler = findCompiler(ndkDir);
final List<String> ndkCompilerArgs = findSysroot(ndkDir);
- return new AndroidNdk._(ndkDir, ndkCompiler, ndkCompilerArgs);
+ return AndroidNdk._(ndkDir, ndkCompiler, ndkCompilerArgs);
}
/// Returns a descriptive message explaining why NDK can not be found within
@@ -300,7 +300,7 @@
// exceptions.
}
- return new AndroidSdk(androidHomeDir, ndk);
+ return AndroidSdk(androidHomeDir, ndk);
}
static bool validSdkDirectory(String dir) {
@@ -372,7 +372,7 @@
.listSync()
.map((FileSystemEntity entity) {
try {
- return new Version.parse(entity.basename);
+ return Version.parse(entity.basename);
} catch (error) {
return null;
}
@@ -412,7 +412,7 @@
if (buildToolsVersion == null)
return null;
- return new AndroidSdkVersion._(
+ return AndroidSdkVersion._(
this,
sdkLevel: platformVersion,
platformName: platformName,