1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'platform.dart';
6
7/// Class containing some message strings that can be produced by Flutter tools.
8//
9// This allows partial reimplementations of the flutter tool to override
10// certain messages.
11// TODO(andrewkolos): It is unclear if this is worth keeping. See
12// https://github.com/flutter/flutter/issues/125155.
13class UserMessages {
14 // Messages used in multiple components.
15 String get flutterToolBugInstructions =>
16 'Please report a bug at https://github.com/flutter/flutter/issues.';
17
18 // Messages used in FlutterValidator
19 String flutterStatusInfo(String? channel, String? version, String os, String locale) =>
20 'Channel ${channel ?? 'unknown'}, ${version ?? 'unknown version'}, on $os, locale $locale';
21 String flutterVersion(String version, String channel, String flutterRoot) =>
22 'Flutter version $version on channel $channel at $flutterRoot';
23 String get flutterUnknownChannel =>
24 'Currently on an unknown channel. Run `flutter channel` to switch to an official channel.\n'
25 "If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.";
26 String get flutterUnknownVersion =>
27 'Cannot resolve current version, possibly due to local changes.\n'
28 'Reinstall Flutter by following instructions at https://flutter.dev/setup.';
29 String flutterRevision(String revision, String age, String date) =>
30 'Framework revision $revision ($age), $date';
31 String flutterUpstreamRepositoryUrl(String url) => 'Upstream repository $url';
32 String get flutterUpstreamRepositoryUnknown =>
33 'Unknown upstream repository.\n'
34 'Reinstall Flutter by following instructions at https://flutter.dev/setup.';
35 String flutterUpstreamRepositoryUrlEnvMismatch(String url) =>
36 'Upstream repository $url is not the same as FLUTTER_GIT_URL';
37 String flutterUpstreamRepositoryUrlNonStandard(String url) =>
38 'Upstream repository $url is not a standard remote.\n'
39 'Set environment variable "FLUTTER_GIT_URL" to $url to dismiss this error.';
40 String flutterGitUrl(String url) => 'FLUTTER_GIT_URL = $url';
41 String engineRevision(String revision) => 'Engine revision $revision';
42 String dartRevision(String revision) => 'Dart version $revision';
43 String devToolsVersion(String version) => 'DevTools version $version';
44 String pubMirrorURL(String url) => 'Pub download mirror $url';
45 String flutterMirrorURL(String url) => 'Flutter download mirror $url';
46 String get flutterBinariesDoNotRun =>
47 'Downloaded executables cannot execute on host.\n'
48 'See https://github.com/flutter/flutter/issues/6207 for more information.';
49 String get flutterBinariesLinuxRepairCommands =>
50 'On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6\n'
51 'On Fedora: dnf install libstdc++.i686\n'
52 'On Arch: pacman -S lib32-gcc-libs';
53 String get flutterValidatorErrorIntentional =>
54 'If those were intentional, you can disregard the above warnings; however it is '
55 'recommended to use "git" directly to perform update checks and upgrades.';
56
57 // Messages used in NoIdeValidator
58 String get noIdeStatusInfo => 'No supported IDEs installed';
59 List<String> get noIdeInstallationInfo => <String>[
60 'IntelliJ - https://www.jetbrains.com/idea/',
61 'Android Studio - https://developer.android.com/studio/',
62 'VS Code - https://code.visualstudio.com/',
63 ];
64
65 // Messages used in IntellijValidator
66 String intellijStatusInfo(String version) => 'version $version';
67 String get intellijPluginInfo =>
68 'For information about installing plugins, see\n'
69 'https://flutter.dev/to/intellij-setup';
70 String intellijMinimumVersion(String minVersion) =>
71 'This install is older than the minimum recommended version of $minVersion.';
72 String intellijLocation(String installPath) => 'IntelliJ at $installPath';
73
74 // Message used in IntellijValidatorOnMac
75 String get intellijMacUnknownResult => 'Cannot determine if IntelliJ is installed';
76
77 // Messages used in DeviceValidator
78 String get devicesMissing => 'No devices available';
79 String devicesAvailable(int devices) => '$devices available';
80
81 // Messages used in AndroidValidator
82 String androidCantRunJavaBinary(String javaBinary) =>
83 'Cannot execute $javaBinary to determine the version';
84 String get androidUnknownJavaVersion => 'Could not determine java version';
85 String androidJavaVersion(String javaVersion) => 'Java version $javaVersion';
86 String androidJavaMinimumVersion(String javaVersion) =>
87 'Java version $javaVersion is older than the minimum recommended version of 1.8';
88 String androidSdkLicenseOnly(String envKey) =>
89 'Android SDK contains licenses only.\n'
90 'Your first build of an Android application will take longer than usual, '
91 'while gradle downloads the missing components. This functionality will '
92 'only work if the licenses in the licenses folder in $envKey are valid.\n'
93 'If the Android SDK has been installed to another location, set $envKey to that location.\n'
94 'You may also want to add it to your PATH environment variable.\n\n'
95 'Certain features, such as `flutter emulators` and `flutter devices`, will '
96 'not work without the currently missing SDK components.';
97 String androidBadSdkDir(String envKey, String homeDir) =>
98 '$envKey = $homeDir\n'
99 'but Android SDK not found at this location.';
100 String androidMissingSdkInstructions(Platform platform) =>
101 'Unable to locate Android SDK.\n'
102 'Install Android Studio from: https://developer.android.com/studio/index.html\n'
103 'On first launch it will assist you in installing the Android SDK components.\n'
104 '(or visit ${androidSdkInstallUrl(platform)} for detailed instructions).\n'
105 'If the Android SDK has been installed to a custom location, please use\n'
106 '`flutter config --android-sdk` to update to that location.\n';
107 String androidSdkLocation(String directory) => 'Android SDK at $directory';
108 String androidSdkPlatformToolsVersion(String platform, String tools) =>
109 'Platform $platform, build-tools $tools';
110 String androidSdkInstallHelp(Platform platform) =>
111 'Try re-installing or updating your Android SDK,\n'
112 'visit ${androidSdkInstallUrl(platform)} for detailed instructions.';
113 // Also occurs in AndroidLicenseValidator
114 String androidStatusInfo(String version) => 'Android SDK version $version';
115
116 // Messages used in AndroidLicenseValidator
117 String get androidMissingJdk =>
118 'No Java Development Kit (JDK) found; You must have the environment '
119 'variable JAVA_HOME set and the java binary in your PATH. '
120 'You can download the JDK from https://www.oracle.com/technetwork/java/javase/downloads/.';
121 String get androidLicensesAll => 'All Android licenses accepted.';
122 String get androidLicensesSome =>
123 'Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses';
124 String get androidLicensesNone =>
125 'Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses';
126 String androidLicensesUnknown(Platform platform) =>
127 'Android license status unknown.\n'
128 'Run `flutter doctor --android-licenses` to accept the SDK licenses.\n'
129 'See ${androidSdkInstallUrl(platform)} for more details.';
130 String androidSdkManagerOutdated(String managerPath) =>
131 'A newer version of the Android SDK is required. To update, run:\n'
132 '$managerPath --update\n';
133 String androidLicensesTimeout(String managerPath) => 'Intentionally killing $managerPath';
134 String get androidSdkShort => 'Unable to locate Android SDK.';
135 String androidMissingSdkManager(String sdkManagerPath, Platform platform) =>
136 'Android sdkmanager tool not found ($sdkManagerPath).\n'
137 'Try re-installing or updating your Android SDK,\n'
138 'visit ${androidSdkInstallUrl(platform)} for detailed instructions.';
139 String androidCannotRunSdkManager(String sdkManagerPath, String error, Platform platform) =>
140 'Android sdkmanager tool was found, but failed to run ($sdkManagerPath): "$error".\n'
141 'Try re-installing or updating your Android SDK,\n'
142 'visit ${androidSdkInstallUrl(platform)} for detailed instructions.';
143 String androidSdkBuildToolsOutdated(
144 int sdkMinVersion,
145 String buildToolsMinVersion,
146 Platform platform,
147 ) =>
148 'Flutter requires Android SDK $sdkMinVersion and the Android BuildTools $buildToolsMinVersion\n'
149 'To update the Android SDK visit ${androidSdkInstallUrl(platform)} for detailed instructions.';
150
151 // Messages used in AndroidStudioValidator
152 String androidStudioVersion(String version) => 'version $version';
153 String androidStudioLocation(String location) => 'Android Studio at $location';
154 String get androidStudioNeedsUpdate => 'Try updating or re-installing Android Studio.';
155 String get androidStudioResetDir =>
156 'Consider removing your android-studio-dir setting by running:\n'
157 'flutter config --android-studio-dir=';
158 String get aaptNotFound =>
159 'Could not locate aapt. Please ensure you have the Android buildtools installed.';
160
161 // Messages used in NoAndroidStudioValidator
162 String androidStudioMissing(String location) =>
163 'android-studio-dir = $location\n'
164 'but Android Studio not found at this location.';
165 String androidStudioInstallation(Platform platform) =>
166 'Android Studio not found; download from https://developer.android.com/studio/index.html\n'
167 '(or visit ${androidSdkInstallUrl(platform)} for detailed instructions).';
168
169 // Messages used in XcodeValidator
170 String xcodeLocation(String location) => 'Xcode at $location';
171
172 String xcodeOutdated(String requiredVersion) =>
173 'Flutter requires Xcode $requiredVersion or higher.\n'
174 'Download the latest version or update via the Mac App Store.';
175
176 String xcodeRecommended(String recommendedVersion) =>
177 'Flutter recommends a minimum Xcode version of $recommendedVersion.\n'
178 'Download the latest version or update via the Mac App Store.';
179
180 String get xcodeEula =>
181 "Xcode end user license agreement not signed; open Xcode or run the command 'sudo xcodebuild -license'.";
182 String get xcodeMissingSimct =>
183 'Xcode requires additional components to be installed in order to run.\n'
184 'Launch Xcode and install additional required components when prompted or run:\n'
185 ' sudo xcodebuild -runFirstLaunch';
186 String get xcodeMissing =>
187 'Xcode not installed; this is necessary for iOS and macOS development.\n'
188 'Download at https://developer.apple.com/xcode/.';
189 String get xcodeIncomplete =>
190 'Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.\n'
191 'Download at: https://developer.apple.com/xcode/\n'
192 'Or install Xcode via the App Store.\n'
193 'Once installed, run:\n'
194 ' sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer\n'
195 ' sudo xcodebuild -runFirstLaunch';
196
197 // Messages used in CocoaPodsValidator
198 String cocoaPodsVersion(String version) => 'CocoaPods version $version';
199 String cocoaPodsMissing(String consequence, String installInstructions) =>
200 'CocoaPods not installed.\n'
201 '$consequence\n'
202 'For installation instructions, $installInstructions';
203 String cocoaPodsUnknownVersion(String consequence, String upgradeInstructions) =>
204 'Unknown CocoaPods version installed.\n'
205 '$consequence\n'
206 'To update CocoaPods, $upgradeInstructions';
207 String cocoaPodsOutdated(
208 String currentVersion,
209 String recVersion,
210 String consequence,
211 String upgradeInstructions,
212 ) =>
213 'CocoaPods $currentVersion out of date ($recVersion is recommended).\n'
214 '$consequence\n'
215 'To update CocoaPods, $upgradeInstructions';
216 String cocoaPodsBrokenInstall(String consequence, String reinstallInstructions) =>
217 'CocoaPods installed but not working.\n'
218 '$consequence\n'
219 'For re-installation instructions, $reinstallInstructions';
220
221 // Messages used in VisualStudioValidator
222 String visualStudioVersion(String name, String version) => '$name version $version';
223 String visualStudioLocation(String location) => 'Visual Studio at $location';
224 String windows10SdkVersion(String version) => 'Windows 10 SDK version $version';
225 String visualStudioMissingComponents(String workload, List<String> components) =>
226 'Visual Studio is missing necessary components. Please re-run the '
227 'Visual Studio installer for the "$workload" workload, and include these components:\n'
228 ' ${components.join('\n ')}\n'
229 ' Windows 10 SDK';
230 String get windows10SdkNotFound =>
231 'Unable to locate a Windows 10 SDK. If building fails, install the Windows 10 SDK in Visual Studio.';
232 String visualStudioMissing(String workload) =>
233 'Visual Studio not installed; this is necessary to develop Windows apps.\n'
234 'Download at https://visualstudio.microsoft.com/downloads/.\n'
235 'Please install the "$workload" workload, including all of its default components';
236 String visualStudioTooOld(String minimumVersion, String workload) =>
237 'Visual Studio $minimumVersion or later is required.\n'
238 'Download at https://visualstudio.microsoft.com/downloads/.\n'
239 'Please install the "$workload" workload, including all of its default components';
240 String get visualStudioIsPrerelease =>
241 'The current Visual Studio installation is a pre-release version. It may not be '
242 'supported by Flutter yet.';
243 String get visualStudioNotLaunchable =>
244 'The current Visual Studio installation is not launchable. Please reinstall Visual Studio.';
245 String get visualStudioIsIncomplete =>
246 'The current Visual Studio installation is incomplete.\n'
247 'Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.';
248 String get visualStudioRebootRequired =>
249 'Visual Studio requires a reboot of your system to complete installation.';
250
251 // Messages used in LinuxDoctorValidator
252 String get clangMissing =>
253 'clang++ is required for Linux development.\n'
254 'It is likely available from your distribution (e.g.: apt install clang), or '
255 'can be downloaded from https://releases.llvm.org/';
256 String clangTooOld(String minimumVersion) => 'clang++ $minimumVersion or later is required.';
257 String get cmakeMissing =>
258 'CMake is required for Linux development.\n'
259 'It is likely available from your distribution (e.g.: apt install cmake), or '
260 'can be downloaded from https://cmake.org/download/';
261 String cmakeTooOld(String minimumVersion) => 'cmake $minimumVersion or later is required.';
262 String ninjaVersion(String version) => 'ninja version $version';
263 String get ninjaMissing =>
264 'ninja is required for Linux development.\n'
265 'It is likely available from your distribution (e.g.: apt install ninja-build), or '
266 'can be downloaded from https://github.com/ninja-build/ninja/releases';
267 String ninjaTooOld(String minimumVersion) => 'ninja $minimumVersion or later is required.';
268 String pkgConfigVersion(String version) => 'pkg-config version $version';
269 String get pkgConfigMissing =>
270 'pkg-config is required for Linux development.\n'
271 'It is likely available from your distribution (e.g.: apt install pkg-config), or '
272 'can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/';
273 String pkgConfigTooOld(String minimumVersion) =>
274 'pkg-config $minimumVersion or later is required.';
275 String get gtkLibrariesMissing =>
276 'GTK 3.0 development libraries are required for Linux development.\n'
277 'They are likely available from your distribution (e.g.: apt install libgtk-3-dev)';
278 String get eglinfoMissing =>
279 "Unable to access driver information using 'eglinfo'.\n"
280 'It is likely available from your distribution (e.g.: apt install mesa-utils)';
281
282 // Messages used in FlutterCommand
283 String flutterElapsedTime(String name, String elapsedTime) =>
284 '"flutter $name" took $elapsedTime.';
285 String get flutterNoDevelopmentDevice =>
286 "Unable to locate a development device; please run 'flutter doctor' "
287 'for information about installing additional components.';
288 String get flutterNoSupportedDevices => 'No supported devices connected.';
289 String flutterMissPlatformProjects(List<String> unsupportedDevicesType) =>
290 'If you would like your app to run on ${unsupportedDevicesType.join(' or ')}, consider running `flutter create .` to generate projects for these platforms.';
291 String get flutterSpecifyDeviceWithAllOption =>
292 'More than one device connected; please specify a device with '
293 "the '-d <deviceId>' flag, or use '-d all' to act on all devices.";
294 String get flutterSpecifyDevice =>
295 'More than one device connected; please specify a device with '
296 "the '-d <deviceId>' flag.";
297 String get flutterNoPubspec =>
298 'Error: No pubspec.yaml file found.\n'
299 'This command should be run from the root of your Flutter project.';
300 String flutterTargetFileMissing(String path) => 'Target file "$path" not found.';
301 String get flutterBasePatchFlagsExclusive => 'Error: Only one of --baseline, --patch is allowed.';
302 String get flutterBaselineRequiresTraceFile =>
303 'Error: --baseline requires --compilation-trace-file to be specified.';
304 String get flutterPatchRequiresTraceFile =>
305 'Error: --patch requires --compilation-trace-file to be specified.';
306
307 // Messages used in FlutterCommandRunner
308 String runnerNoRoot(String error) => 'Unable to locate flutter root: $error';
309 String runnerWrapColumnInvalid(dynamic value) =>
310 'Argument to --wrap-column must be a positive integer. You supplied $value.';
311 String runnerWrapColumnParseError(dynamic value) =>
312 'Unable to parse argument --wrap-column=$value. Must be a positive integer.';
313 String runnerBugReportFinished(String zipFileName) =>
314 'Bug report written to $zipFileName.\n'
315 'Warning: this bug report contains local paths, device identifiers, and log snippets.';
316 String get runnerNoRecordTo => 'record-to location not specified';
317 String get runnerNoReplayFrom => 'replay-from location not specified';
318 String runnerNoEngineSrcDir(String enginePackageName, String engineEnvVar) =>
319 'Unable to detect local Flutter engine src directory.\n'
320 'Either specify a dependency_override for the $enginePackageName package in your pubspec.yaml and '
321 'ensure --package-root is set if necessary, or set the \$$engineEnvVar environment variable, or '
322 'use --local-engine-src-path to specify the path to the root of your flutter/engine repository.';
323 String runnerNoEngineBuildDirInPath(String engineSourcePath) =>
324 'Unable to detect a Flutter engine build directory in $engineSourcePath.\n'
325 "Please ensure that $engineSourcePath is a Flutter engine 'src' directory and that "
326 "you have compiled the engine in that directory, which should produce an 'out' directory";
327 String get runnerLocalEngineOrWebSdkRequired =>
328 'You must specify --local-engine or --local-web-sdk if you are using a locally built engine or web sdk.';
329 String get runnerLocalEngineRequiresHostEngine =>
330 'You are using a locally built engine (--local-engine) but have not specified --local-engine-host.\n'
331 'You may be building with a different engine than the one you are running with. '
332 'See https://github.com/flutter/flutter/issues/132245 for details.';
333 String get runnerHostEngineRequiresLocalEngine =>
334 'You must specify --local-engine if you are using --local-engine-host.';
335 String runnerNoEngineBuild(String engineBuildPath) =>
336 'No Flutter engine build found at $engineBuildPath.';
337 String runnerNoWebSdk(String webSdkPath) => 'No Flutter web sdk found at $webSdkPath.';
338 String runnerWrongFlutterInstance(String flutterRoot, String currentDir) =>
339 "Warning: the 'flutter' tool you are currently running is not the one from the current directory:\n"
340 ' running Flutter : $flutterRoot\n'
341 ' current directory: $currentDir\n'
342 'This can happen when you have multiple copies of flutter installed. Please check your system path to verify '
343 "that you're running the expected version (run 'flutter --version' to see which flutter is on your path).\n";
344 String runnerRemovedFlutterRepo(String flutterRoot, String flutterPath) =>
345 'Warning! This package referenced a Flutter repository via the .packages file that is '
346 "no longer available. The repository from which the 'flutter' tool is currently "
347 'executing will be used instead.\n'
348 ' running Flutter tool: $flutterRoot\n'
349 ' previous reference : $flutterPath\n'
350 'This can happen if you deleted or moved your copy of the Flutter repository, or '
351 'if it was on a volume that is no longer mounted or has been mounted at a '
352 'different location. Please check your system path to verify that you are running '
353 "the expected version (run 'flutter --version' to see which flutter is on your path).\n";
354 String runnerChangedFlutterRepo(String flutterRoot, String flutterPath) =>
355 "Warning! The 'flutter' tool you are currently running is from a different Flutter "
356 'repository than the one last used by this package. The repository from which the '
357 "'flutter' tool is currently executing will be used instead.\n"
358 ' running Flutter tool: $flutterRoot\n'
359 ' previous reference : $flutterPath\n'
360 'This can happen when you have multiple copies of flutter installed. Please check '
361 'your system path to verify that you are running the expected version (run '
362 "'flutter --version' to see which flutter is on your path).\n";
363 String invalidVersionSettingHintMessage(String invalidVersion) =>
364 'Invalid version $invalidVersion found, default value will be used.\n'
365 'In pubspec.yaml, a valid version should look like: build-name+build-number.\n'
366 'In Android, build-name is used as versionName while build-number used as versionCode.\n'
367 'Read more about Android versioning at https://developer.android.com/studio/publish/versioning\n'
368 'In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.\n'
369 'Read more about iOS versioning at\n'
370 'https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html\n';
371
372 String androidSdkInstallUrl(Platform platform) {
373 const baseUrl = 'https://flutter.dev/to/';
374 if (platform.isMacOS) {
375 return '${baseUrl}macos-android-setup';
376 } else if (platform.isLinux) {
377 return '${baseUrl}linux-android-setup';
378 } else if (platform.isWindows) {
379 return '${baseUrl}windows-android-setup';
380 } else {
381 return '${baseUrl}android-setup';
382 }
383 }
384}
385