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; 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
homesmf_home_flutterfeaturenoneA start screen at /home
blocsmf_blocinfrastructureState managementflutter_bloc
riverpodsmf_riverpodinfrastructureState managementflutter_riverpod and its ProviderScope
get_itsmf_get_itinfrastructureDependency injectionRegistration of the app's services in get_it
event_bussmf_event_businfrastructureEventsA CommunicationService on the event_bus package
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

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. 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
Routerlib/core/router/app_router.dart, lib/core/router/navigation.dartAppRouter, appRouter, the location classes and context.nav
Layoutlib/core/layout/destination.dartDestination, the label and icon of an item of the main navigation
Dependency injectionlib/core/di/service_locator.dartServiceLocator, resolve<T>(), resolveWith<T>()
Eventslib/core/events/communication_service.dartAppEvent, CommunicationService, createCommunicationService()
Analyticslib/core/analytics/analytics_service.dartAnalyticsService, createAnalyticsService()
Crash reportinglib/core/crash_reporting/crash_reporter.dartCrashReporter, createCrashReporter(), installCrashReporting()

The app entry and the state management role have no files of their own. flutter_core generates the files of the app entry, and screens use the state management libraries directly.