mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
feat(flutter_tools): add linux-gtk template selector
This commit is contained in:
parent
60e001eeaa
commit
ec08a47de1
@ -83,6 +83,12 @@ class CreateCommand extends FlutterCommand with CreateBase {
|
||||
help:
|
||||
'The language to use for Android-specific code, either Kotlin (recommended) or Java (legacy).',
|
||||
);
|
||||
argParser.addOption(
|
||||
'linux-gtk',
|
||||
defaultsTo: 'gtk4',
|
||||
allowed: <String>['gtk4', 'gtk3'],
|
||||
help: 'Select the GTK version for Linux templates (gtk4 default, gtk3 opt-in).',
|
||||
);
|
||||
argParser.addFlag(
|
||||
'skip-name-checks',
|
||||
help:
|
||||
@ -459,6 +465,7 @@ class CreateCommand extends FlutterCommand with CreateBase {
|
||||
darwin: includeDarwin,
|
||||
web: includeWeb,
|
||||
linux: includeLinux,
|
||||
linuxGtkVersion: stringArg('linux-gtk') ?? 'gtk4',
|
||||
macos: includeMacos,
|
||||
windows: includeWindows,
|
||||
dartSdkVersionBounds: '^$dartSdk',
|
||||
|
||||
@ -319,6 +319,7 @@ mixin CreateBase on FlutterCommand {
|
||||
bool android = false,
|
||||
bool web = false,
|
||||
bool linux = false,
|
||||
String linuxGtkVersion = 'gtk4',
|
||||
bool macos = false,
|
||||
bool windows = false,
|
||||
bool darwin = false,
|
||||
@ -375,6 +376,7 @@ mixin CreateBase on FlutterCommand {
|
||||
'android': android,
|
||||
'web': web,
|
||||
'linux': linux,
|
||||
'linuxGtkVersion': linuxGtkVersion,
|
||||
'macos': macos,
|
||||
'darwin': darwin,
|
||||
'sharedDarwinSource': darwin,
|
||||
|
||||
@ -258,6 +258,18 @@ class Template {
|
||||
}
|
||||
// Only build a Linux project if explicitly asked.
|
||||
final bool linux = (context['linux'] as bool?) ?? false;
|
||||
final String linuxGtkVersion = (context['linuxGtkVersion'] as String?) ?? 'gtk4';
|
||||
final bool linuxGtk3Template = relativeDestinationPath.startsWith('linux-gtk3.tmpl');
|
||||
final bool linuxGtk4Template = relativeDestinationPath.startsWith('linux-gtk4.tmpl');
|
||||
if ((linuxGtk3Template || linuxGtk4Template) && !linux) {
|
||||
return null;
|
||||
}
|
||||
if (linuxGtk3Template && linuxGtkVersion != 'gtk3') {
|
||||
return null;
|
||||
}
|
||||
if (linuxGtk4Template && linuxGtkVersion != 'gtk4') {
|
||||
return null;
|
||||
}
|
||||
if (relativeDestinationPath.startsWith('linux.tmpl') && !linux) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user