Skip to main content

Modules

These are the modules that smf create offers. Each one is a Dart package on pub.dev, but you never add them to an app yourself: smf create puts what they generate into the app.

Module (-m)PackageKindRole it providesAdds to the app
flutter_coresmf_flutter_corescaffoldApp entryThe Flutter project, main(), start-up, root widget, and the screen that an app shows while it has no screen to start on; in every app
go_routersmf_go_routerinfrastructureRouterThe router of the features' routes, with go_router
bottom_tabssmf_bottom_tabslayoutLayoutTabs at the bottom for the destinations of the features, in a bar that it draws in the colors of the theme
homesmf_home_flutterfeaturenoneA start screen at /home, which welcomes the developer of the app and lists the next steps
onboardingsmf_onboardingfeaturenoneThe onboarding at /onboarding, which the app shows on its first launch until the user finishes it
settingssmf_settingsfeatureSettings screenA settings screen at /settings, with the settings of the modules in one group, a row for each
sign_insmf_sign_infeaturenoneThe screens of sign-in, sign-up and password reset for an email address and a password, and the screen of the account with its row on the settings screen, with BLoC or with Riverpod
blocsmf_blocinfrastructureState managementflutter_bloc
riverpodsmf_riverpodinfrastructureState managementflutter_riverpod and its ProviderScope
material_themesmf_material_themeinfrastructureThemeA light and a dark Material 3 theme with a palette, text styles and a bundled font, in lib/core/theme/app_theme.dart
gen_l10nsmf_gen_l10ninfrastructureLocalizationThe texts of the app in ARB files, one for each language, with gen-l10n of Flutter
get_itsmf_get_itinfrastructureDependency injectionRegistration of the app's services in get_it
event_bussmf_event_businfrastructureEventsA CommunicationService on the event_bus package
shared_preferencessmf_shared_preferencesinfrastructurePreferencesAppPreferences on the shared_preferences package, for the settings that the app remembers
firebase_coresmf_firebase_coreinfrastructurenoneFirebase: options, initialization, setup of the machine
firebase_crashlyticssmf_firebase_crashlyticsinfrastructureCrash reportingA CrashReporter on Firebase Crashlytics
firebase_analyticssmf_firebase_analyticsinfrastructureAnalyticsAn AnalyticsService on Firebase Analytics, and screen views
firebase_authsmf_firebase_authinfrastructureAuthenticationSign-in with Firebase Authentication: an email address and a password, or an anonymous user, and a script that enables the sign-in methods in the Firebase project

The kind of a module decides the rules it follows. A feature keeps its files in lib/features/<id>/ and declares routes, a layout provides the main navigation, and infrastructure sets up a service or a library without screens of its own. A feature can provide a role too, as settings does, and it can keep its state with the state manager of the app, as sign_in does in a variant for each. See the module model.

Roles and their files​

A role generates the part of the app that other code counts on, whichever module provides it. These files belong to the roles rather than to a module:

RoleFilesWhat they declare
App entryAGENTS.md, CLAUDE.mdThe guide for coding agents that work on the app
Routerlib/core/router/app_router.dart, lib/core/router/navigation.dartAppRouter, appRouter, the location classes and context.nav. In an app with guards, also routeGuards, redirectOf(), flowIsOver(), guardChanges and GuardedNavigation
Layoutlib/core/layout/destination.dartDestination, the label and icon of an item of the main navigation, and appDestinations, the destinations of the app
Themelib/core/theme/theme_mode.dart, and lib/core/theme/theme_mode_setting.dart in an app with a settings screenappThemeMode, the theme mode that the user selected, AppThemeModeScope and restoreAppThemeMode; ThemeModeSetting, the entry of the settings screen
Localizationlib/core/l10n/app_locale.dart, and lib/core/l10n/language_setting.dart in an app with a settings screenappLocales, the languages of the app, appLocale, the language that the user chose, AppLocaleScope and restoreAppLocale; LanguageSetting, the entry of the settings screen
Dependency injectionlib/core/di/service_locator.dartServiceLocator, resolve<T>()
Eventslib/core/events/communication_service.dartAppEvent, CommunicationService, createCommunicationService()
Preferenceslib/core/preferences/app_preferences.dartAppPreferences, initPreferences(), createAppPreferences()
Analyticslib/core/analytics/analytics_service.dartAnalyticsService, createAnalyticsService()
Crash reportinglib/core/crash_reporting/crash_reporter.dartCrashReporter, createCrashReporter(), installCrashReporting()
Authenticationlib/core/auth/app_session.dart, lib/core/auth/auth_service.dart, lib/core/auth/guest_data.dartappSession, the session of the app, authMode and initAuth(); AuthService, the interface of a provider, and AuthFailure; takeGuestData(), which the developer of the app edits

The state management role and the settings screen role have no files of their own: screens use the state management libraries directly, and the module that provides the settings screen generates the screen. Besides the guide for coding agents, the files of the app entry come from flutter_core.

Routes, settings and texts of the modules​

A module does not reach into another module. It gives a role what the role collects from every module: a route, a guard, a restorer of a setting, a row of the settings screen, a text. In an app with every module above, the router, the preferences, the settings screen and the localization get these from the modules, and from two roles. The services of the modules and what follows the screens are on the pages of the modules.

FromRoutes and guardsRestorer of the preferencesRow of the settings screenTexts, in English and in Ukrainian
flutter_coreThe two texts of its fallback start screen
home/home, a destinationThe label of its tab, and the 14 texts of its screen
onboarding/onboarding, and the guard onboarding.firstRunrestoreOnboardingThe six texts of its screen
settings/settings, a destinationThe title of its screen, which is the label of its tab too
sign_in/sign_in with /sign_in/sign_up and /sign_in/reset_password below it, /sign_in/account, which asks for an account, and the guards sign_in.gate and sign_in.hasAccountAccountThe 42 texts of its screens
The theme role, with material_themerestoreAppThemeModeThemeThe four texts of its row
The localization role, with gen_l10nrestoreAppLocaleLanguageThe two texts of its row

So the settings screen of such an app has the row Account, and after it the rows Language and Theme, in the order of the modules that provide the two roles. The preferences restore three settings before the first frame, and the router asks three guards: the gate of the onboarding, then the gate of the sign-in, then the guard of the routes that need an account. A module of your own gives the roles the same things; see Extending SMF.

Two modules also add files that are not code, and declare them in pubspec.yaml: home the image of its screen, in lib/features/home/assets/, and material_theme the font of its themes with its license, in assets/fonts/geist/.