31.10 Flutter App and Package Name
20230703
The app and package name is recorded at the top of the pubspec.yaml
file:
name: healthtracks
description: Privacy focused location based health data app using SOLID.
Individual dart source files can then refer to package:healthtracks
to import from, as an alternative to relative paths like
../../pages/
.
import 'package:healthtracks/pages/home/index.dart';
To change the name of the package, we can edit the name in
pubspec.yaml
and run something like the following.
rgrep healthtracks lib
find lib -type f -exec sed -i 's/package:healthtracks/package:myhealth/g' {} +
The app name will also have been instantiated within the build, macos, ios, web, linux, windows, and android directories. So to change the name throughout is more complex.
Individual files can be modified for Android
android/app/src/main/AndroidManifest.xml
and for iOS
ios/Runner/Info.plist
or we can use the
flutter_app_name package to make that change by
adding the following to pubspec.yaml
:
dev_dependencies:
flutter_app_name: ^0.1.1
flutter_app_name:
name: "Health Tracks"
id: "com.togaware.healthtrack"
and then:
flutter pub get
flutter pub run flutter_app_name
For Linux we can find where the old title is used and change them manually:
rgrep healthtracks linux
to see
linux/my_application.cc: gtk_header_bar_set_title(header_bar, "healthtracks");
linux/my_application.cc: gtk_window_set_title(window, "healthtracks");
linux/CMakeLists.txt:set(BINARY_NAME "healthtracks")
linux/CMakeLists.txt:set(APPLICATION_ID "com.example.healthtracks")
To change the name:
find linux -type f -exec sed -i 's|healthtracks|myhealth|' {} +
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0
