Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for Flutter 3.27 template #68

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const _webDirPath = 'web';

// ? Linux
const _linuxDirPath = 'linux';
const _linuxRunnerDirPath = '$_linuxDirPath/runner';

// ? Windows
const _windowsDirPath = 'windows';
Expand Down Expand Up @@ -101,6 +102,8 @@ const _webManifestFilePath = '$_webDirPath/$_manifestJsonFileName';
// ? Linux
const _linuxCMakeListsFilePath = '$_linuxDirPath/$_cMakeListsFileName';
const _linuxMyApplicationFilePath = '$_linuxDirPath/$_myApplicationFileName';
const _linuxRunnerMyApplicationFilePath =
'$_linuxRunnerDirPath/$_myApplicationFileName';

// ? Windows
const _windowsCMakeListsFilePath = '$_windowsDirPath/$_cMakeListsFileName';
Expand Down
6 changes: 3 additions & 3 deletions lib/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ const _linuxCMakeListsNotFoundMessage = '''
''';

const _linuxMyApplicationNotFoundMessage = '''
╔══════════════════════════════════════════════╗
║ my_application.cc not found in `linux/`. ║
╚══════════════════════════════════════════════╝
╔══════════════════════════════════════════════════════════════════
║ my_application.cc not found in `linux/` and `linux/runner/`. ║
╚══════════════════════════════════════════════════════════════════
''';

const _invalidWindowsConfigMessage = '''
Expand Down
47 changes: 34 additions & 13 deletions lib/platforms/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,43 @@ void _setLinuxAppName(dynamic appName) {
if (appName is! String) throw _PackageRenameErrors.invalidAppName;

final myAppFile = File(_linuxMyApplicationFilePath);
if (!myAppFile.existsSync()) {
final runnerMyAppFile = File(_linuxRunnerMyApplicationFilePath);

final doesMyAppFileExist = myAppFile.existsSync();
final doesRunnerMyAppFileExist = runnerMyAppFile.existsSync();

if (!doesMyAppFileExist && !doesRunnerMyAppFileExist) {
throw _PackageRenameErrors.linuxMyApplicationNotFound;
}

final myAppString = myAppFile.readAsStringSync();
final newTitleMyAppString = myAppString
.replaceAll(
RegExp(r'gtk_header_bar_set_title\(header_bar, "(.*)"\);'),
'gtk_header_bar_set_title(header_bar, "$appName");',
)
.replaceAll(
RegExp(r'gtk_window_set_title\(window, "(.*)"\);'),
'gtk_window_set_title(window, "$appName");',
);

myAppFile.writeAsStringSync(newTitleMyAppString);
if (doesMyAppFileExist) {
final myAppString = myAppFile.readAsStringSync();
final newTitleMyAppString = myAppString
.replaceAll(
RegExp(r'gtk_header_bar_set_title\(header_bar, "(.*)"\);'),
'gtk_header_bar_set_title(header_bar, "$appName");',
)
.replaceAll(
RegExp(r'gtk_window_set_title\(window, "(.*)"\);'),
'gtk_window_set_title(window, "$appName");',
);

myAppFile.writeAsStringSync(newTitleMyAppString);
}
if (doesRunnerMyAppFileExist) {
final runnerMyAppString = runnerMyAppFile.readAsStringSync();
final newTitleRunnerMyAppString = runnerMyAppString
.replaceAll(
RegExp(r'gtk_header_bar_set_title\(header_bar, "(.*)"\);'),
'gtk_header_bar_set_title(header_bar, "$appName");',
)
.replaceAll(
RegExp(r'gtk_window_set_title\(window, "(.*)"\);'),
'gtk_window_set_title(window, "$appName");',
);

runnerMyAppFile.writeAsStringSync(newTitleRunnerMyAppString);
}

_logger.i('Linux app title set to: `$appName` (my_application.cc)');
} on _PackageRenameException catch (e) {
Expand Down
Loading