smf_flutter_core 0.7.1
smf_flutter_core: ^0.7.1 copied to clipboard
The module that creates the Flutter app every SMF app starts from, with its Android and iOS projects, main(), start-up and root widget.
smf_flutter_core #
The SMF module that creates the Flutter app every SMF app starts from. It provides the app entry role of SMF, which every app has exactly one provider of:
- the Android and iOS projects of
flutter create, with the flavorsdev,stagingandprodas plain text, which install next to each other on a device; lib/main.dart, whosemain()awaitsbootstrap()and runs the root widget inside the wrappers of other modules;lib/bootstrap.dart, where modules put their start-up code, phase by phase;lib/app.dart, the rootMaterialApp, which becomesMaterialApp.routerwhen the app has a router;- the fallback start screen with a widget test, which only an app that no route starts gets;
pubspec.yamlwith the dependencies of all modules, andanalysis_options.yaml, which leavesbuild/out of the analysis.
The fallback start screen is for the developer of the app, who sees it until the app has a screen to start on. It shows a cell with a symbol and a number, both made from the name of the app. Below the cell are the name of the app, a hint that the app has no start screen yet, and the path of the file of the screen. A tap on the path copies it. An app with a feature whose route can start the app gets neither the screen nor its test nor its texts.
The hint and the word that the screen says after a copy are in English and in Ukrainian. With a module for the languages of the app, such as gen_l10n, the screen reads them from the texts of the app. Without one they are in English.
The app runs on iOS 15 or newer. For iOS builds with Xcode 27, use Flutter 3.47 or newer; see troubleshooting.
Use with the SMF CLI #
Every app needs a module that provides the app entry role. While this is the only one, smf create adds it to every app by itself.
You don't add this package to an app yourself: smf create of the SMF CLI puts what the module generates into the app.
SMF generates apps for Flutter 3.44 or newer and Dart 3.12 or newer. It is tested on macOS, Linux and Windows.
Updating the Flutter template #
The files in bricks/flutter_core/__brick__ are those that flutter create --platforms=android,ios --org com.example --no-pub my_app writes with Flutter 3.44.2, with these changes:
- The names and ids come from the app.
CFBundleNameis its name in Pascal case. The Android namespace, application id and Kotlin package path, and the iOS bundle id are variables of the brick. android:labelis the placeholder${appName}andCFBundleDisplayNameis$(APP_DISPLAY_NAME), so each flavor has a name of its own on the device, the name of the app in title case withDevorStagingafter it, and without either forprod.- The Gradle file of the app has
flavorDimensionsandproductFlavorsafterdefaultConfig, with the id suffix and the name of each flavor. project.pbxprojhas the settingAPP_DISPLAY_NAMEon the three plain configurations of the Runner target, and nine more build configurations in each of its three configuration lists. They are copies of the plain ones, whose object ids start withF1A5, unlike those offlutter create.xcshareddata/xcschemes/has a scheme for each flavor, a copy ofRunner.xcschemewith the names of the configurations replaced, including its pre-action.IPHONEOS_DEPLOYMENT_TARGET, in each build configuration ofproject.pbxproj, is the tag of the minimum iOS version, and the project has noDEVELOPMENT_TEAM.- The Android manifest,
Info.plistand the Gradle files hold the tags of the native sockets of the app entry role, each alone on its line. The Gradle file of the app ends with adependenciesblock for the dependencies of the modules.flutter createdoes not write that block, and it stays empty when no module adds one. The file also has the two tags of core library desugaring, the switch incompileOptionsand the library independencies. A tag that gets nothing leaves no line, so an app without a module that needs desugaring has thecompileOptionsofflutter create. - The
.gitignoreat the root of the app ends with the tag of the patterns that the modules keep out of git, on a line of its own. A tag that gets nothing leaves no line, so an app without such a pattern has the.gitignoreofflutter create. ios/Runner/AppDelegate.swiftholds the tag of the code that runs before the launch of the app finishes. The tag is inapplication(_:didFinishLaunchingWithOptions:), beforereturn super.application(...). Without such code the file is the one offlutter create.ios/Runner/Runner.entitlementsbelongs to the brick. It holds the tag of the entitlements of the app and is empty when no module adds any. Every build configuration of the Runner target signs with it (CODE_SIGN_ENTITLEMENTS), and the Runner group ofproject.pbxprojrefers to it, the way Xcode does when it adds a capability.- The Gradle wrapper takes Gradle 9.3.1 and
settings.gradle.ktsthe Android Gradle plugin 9.1.1, later than those of Flutter 3.44.2. Flutter 3.50 fails the build of a project with older ones, and Flutter 3.44 builds with these too. lib/,test/,pubspec.yaml,README.mdandanalysis_options.yamlare SMF's own.
gradlew, gradle-wrapper.jar, local.properties, .idea/ and the .iml files are left out: Flutter writes the Gradle wrapper when it builds the app, and the rest belongs to one machine.
To move to a newer Flutter:
- Run
flutter createas above with it. - Copy every file it writes over those of the brick, but for the files that SMF owns or leaves out. The files to copy include
.metadata, which names the commit of Flutter, and both.gitignorefiles. - Make the changes above again. Bring every setting of a plain build configuration into its flavored copies, and every change of
Runner.xcschemeinto the schemes of the flavors:test/native_projects_test.dartnames any that differs. - Compare
pubspec.yamlandanalysis_options.yamlof the new app with the brick's. Their SDK constraint, the version offlutter_lintsand the lints follow Flutter's template, but no test compares these files. The brick'sanalysis_options.yamlkeeps leavingbuild/out. - Update the minimum Flutter and iOS versions of
FlutterCoreModule, and the Flutter of the CI workflow with the SHA-256 of its archive. - Bundle the bricks with
melos bootstrap.
test/flutter_create_test.dart takes the flavors out of the brick and compares the rest with the app of flutter create, allowing only the changes above, and fails when Flutter asks for a later iOS, Gradle or Android Gradle plugin than the brick. test/native_projects_test.dart holds the brick to the Gradle and the Android Gradle plugin that the newest Flutter of the apps builds with. It runs when SMF_FLUTTER_CREATE_APP names that app, as the CI job Generated apps (real) does with the Flutter it pins:
flutter create --platforms=android,ios --org com.example --no-pub my_app
SMF_FLUTTER_CREATE_APP=$PWD/my_app dart test test/flutter_create_test.dart