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; 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;- a fallback start screen with a widget test;
pubspec.yamlwith the dependencies of all modules, andanalysis_options.yaml, which leavesbuild/out of the analysis.
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
smf create adds this module 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.
android:labelandCFBundleDisplayNameare its name in title case, andCFBundleNamein Pascal case. The Android namespace, application id and Kotlin package path, and the iOS bundle id are variables of the brick. 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. 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.
- 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 compares the brick with the app of flutter create, allowing only the changes above, and fails when Flutter asks for a later iOS than the brick. 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
Documentation
Libraries
- bundles/flutter_core_bundle
- smf_flutter_core
- The module that creates the Flutter app every SMF app starts from:
FlutterCoreModule, the provider of the app entry role.