smf_contracts library

The module model of SMF: everything a module needs, including the built-in roles and module kinds.

See package:smf_contracts/core.dart for the core without concrete roles.

Classes

AnalyticsRole
The role of the services that record what users do in the app, such as Firebase Analytics; an app can have any number of them.
AndroidMetaData
The value of a <meta-data> element in AppEntryRole.androidManifestApplicationMeta: an android:value or an android:resource.
AppEntryRole
The role of the app's entry point: main(), the start-up sequence and the native project files.
AppIdentity
Platform identifiers of the generated app.
ArgsSocket
A socket for named arguments of a call, such as the arguments of MaterialApp.
BrickContribution
Template files of a module or role template: a mason bundle.
CodegenRequest
A request to run code generation in the generated app.
CodeSocket
A socket for code, one Fragment after another in the order of their contributors: statements, declarations, or, for a CodeSocket.text, lines of a non-Dart file such as XML.
ConflictPolicy<V extends Object>
Allows one value per key: equal values merge, different ones conflict.
Contribution
Something a module or a role template adds to the app.
ContributionOrigin
Who contributed something to the app: a module, the template of a role, or the pipeline itself.
CrashReportingRole
The role of the services that report errors of the app, such as Firebase Crashlytics; an app can have any number of them.
DartFileIndex
What a rendered Dart file of the generated app declares and uses, as data.
Destination
How a top-level route appears in the main navigation of the app, such as a tab of a bottom bar.
DiGraph
The registrations of an app as a graph of services and what they need, which every DI provider renders the same way.
DiProvider
A module's implementation of the DiRole, such as get_it.
DiRegistration
A service of the app's DI container: the data of the DiRole.
DiRole
The role of the app's dependency injection: a service locator, such as get_it, that creates the app's services and gives them what they need.
EventsRole
The role of the channel through which parts of the app that do not know each other exchange events, such as an event bus.
FacadeFeature
The routes of one module in a RouterFacade.
FacadeRoute
A route of a RouterFacade: its full path, full name and the classes the facade generates for it.
FactoryListSocket
A socket for a list of function expressions that the owner of the socket calls: factories, such as () => MyNavigatorObserver(), which it calls as many times as it needs instances, or listeners, which it calls when something happens.
FactoryRef
A top-level function that creates a value, such as createFirebaseAnalyticsService, and the services it takes.
Fragment
A piece of code for a socket, with the imports it needs.
FunctionRef
A top-level function of the generated app or of a package, with the import that declares it, such as a function that disposes of a service.
ImportRef
An import that a Fragment needs.
IndexedConstructor
A constructor of an indexed class.
IndexedDeclaration
A top-level declaration of an indexed file.
IndexedImport
An import or export directive of an indexed file.
IndexedInvocation
An invocation in an indexed file, such as locator<A>(), context.nav.home.details(id: 1) or HomeScreen().
IndexedMemberAccess
A property access, such as nav.home in context.nav.home.
IndexedParameter
A parameter of an indexed function or constructor.
IndexedReference
An identifier used without being invoked, such as the tear-off resolve<A> or a read of appRouter.
KeyedSocket<V extends Object>
A socket for entries with a key, such as Android permissions or Gradle plugins.
LayoutProvider
A module's implementation of the LayoutRole.
LayoutRole
The role of the main navigation of the app around its screens, such as a bottom bar with a tab per feature.
MaxPolicy
Keeps the greater of two values, such as the higher of two minimum versions.
MergePolicy<V extends Object>
How a KeyedSocket or ValueSocket merges two values contributed for the same key.
ModuleContext
What a module may know about the app it is generated into.
ModuleDescriptor
What a module is and how it relates to other modules and roles.
ModuleKind
A kind of module and the rules modules of that kind follow, such as "features live in lib/features/<id>/".
ModuleKinds
The kinds of the built-in modules.
ModuleOrigin
A contribution of a module, possibly from one of its Variants.
ModuleRule<D extends Object>
A check that a role applies, during validation and before anything is rendered, to each module that provides, requires or uses the role.
ModuleRuleInput<D extends Object>
The module a ModuleRule checks.
ModuleRuleRequest
What the pipeline knows when it runs the module rules of a role for one module; see Role.checkModule.
NoDsl
The data type of a role that takes no data from modules.
NoValue
The value of the entries of a KeyedSocket whose entries are only keys, such as the permissions of the Android manifest.
PipelineOrigin
A contribution of the pipeline itself, such as the build_runner dependency it adds for a CodegenRequest.
PipelineSocket
A socket the pipeline fills itself, such as the dependencies section of pubspec.yaml.
PipelineSockets
The sockets of the pipeline in the templates of the app.
PlistBoolean
A <true/> or <false/> value.
PlistInteger
An <integer> value.
PlistMergePolicy
Merges Info.plist values: string arrays are united, other values must be equal.
PlistString
A <string> value.
PlistStringArray
An <array> of strings, such as the values of UIBackgroundModes.
PlistValue
A value of an Info.plist key in AppEntryRole.infoPlist.
PostGenStep
A command the pipeline runs in the generated app after flutter pub get and code generation, such as flutterfire configure.
Preflight
Checks of the machine that a module needs before generation, such as an installed and logged-in Firebase CLI.
PreflightCheck
One check of a Preflight, such as "the Firebase CLI is installed".
PreflightFailed
The check itself could not run, for the reason in message.
PreflightMissing
What the check looks for is not there, or not as the module needs it, and instructions say how to fix it.
PreflightPassed
Everything the check looks for is in place.
PreflightStatus
The result of a PreflightCheck.
PubspecContribution
A part of the generated app's pubspec.yaml: a dependency, an SDK constraint, or settings of the flutter: section.
PubspecDependency
A dependency or dev dependency of the app.
PubspecEnvironment
SDK constraints of the app, the environment: section.
PubspecFlutter
Settings of the flutter: section of the app.
PubspecFont
A font family of a PubspecFlutter.
PubspecFontAsset
A font file of a PubspecFont.
RequiredClass
A top-level class that a provider must generate; the parameters are those of its unnamed constructor.
RequiredFunction
A top-level function that a provider must generate.
RequiredSymbol
A symbol that every provider of a role must generate, such as the createAppRouter() function of a router.
Role<D extends Object>
A replaceable part of an app, such as the router, the DI container or the app entry, described by what it offers to the rest of the app.
RoleChoiceContext<D extends Object>
The input of a RoleTemplate.choose hook.
RoleChoiceRequest
What the pipeline knows when it runs the RoleTemplate.choose hooks.
RoleData<D extends Object>
Data for a role in the role's own language, such as the routes of a feature for the router role.
RoleHookInput<D extends Object>
The input of a hook of a role's template or of one of its providers.
RoleHookRequest
What the pipeline knows when it runs the hooks of roles and providers.
RoleImplementation
The implementation of a service role that a provider contributes as its data, such as the Firebase implementation of AnalyticsService.
RoleInterface
What a role guarantees to the rest of the app: the files its template generates and the symbols that other code uses.
RoleOption
A command line option of a role, such as --start of the router.
RoleOutput
What the RoleTemplate.render or RoleProvider.render hook adds to the app.
RoleProvider<D extends Object>
The implementation of a role by a module, such as the go_router module providing the router role.
RoleTemplate<D extends Object>
The code a role contributes itself, whichever module provides it, such as the interface a router's providers implement.
RoleTemplateOrigin
A contribution of the template of a role, which the pipeline treats as a pseudo-owner named role:<id>.
Route
A page of the app: where it is, the screen it shows and the values it takes from its location.
RouteParam
A value that a route takes from its location and passes to its screen.
RouterChoice
What the template of the router decides before rendering: the route the app starts on.
RouterFacade
The routes of all modules of an app with their full paths, names and classes, from which the router role generates the navigation facade.
RouterRole
The role of the router: the pages of the app, how to reach them, and the main navigation when a layout is present.
RoutesData
The routes a module adds to the app: the data of the RouterRole.
ScreenRef
The screen a Route shows: a widget class of the generated app.
ServiceRef
A service of the app's DI container: a type and, if the container has several services of the type, the name of one of them.
SmfEnvironment
What a hook with side effects may use: the machine, the user, and external commands.
SmfIssue
A problem found by a check: a validation hook of a role or provider, a module rule, a structural rule, or the pipeline.
SmfLogger
Reports progress and problems to the user.
SmfModule
A module: a piece of an app that the user can select, such as a router, a DI container or a feature.
SmfNames
Rules for the names that the module model turns into Dart identifiers, route paths and template tags: module ids, role ids and socket names.
SmfProcessResult
The result of a command run by SmfProcessRunner.run.
SmfProcessRunner
Runs external commands.
SmfProgress
The progress indicator of a long-running task.
SmfPrompter
Asks the user questions in the terminal.
SocketContribution
Code or a value for a socket.
SocketFamily<Key, K extends SocketKind>
A family of sockets of the same kind, one per key, such as the annotations of every screen of the router.
SocketKind
What a socket accepts and how its contributions become text.
SocketRef<K extends SocketKind>
A reference to a socket: a named place in a template that receives contributions of the kind K.
StateManagementRole
The role of the library that holds the state of screens, such as BLoC or Riverpod.
StructuralRule<D extends Object>
A check that a role applies to the generated code of an app, such as "resolve is called only in composition files".
StructuralRuleInput<D extends Object>
The generated app a StructuralRule checks.
StructuralRuleRequest
What the contract test harness knows when it runs the structural rules of a role; see Role.checkStructure.
ToolInstall
What PreflightCheck.install installed.
ToolRef
A resolved way to run a tool: an executable, arguments that always come first, and environment variables.
TypeRef
A Dart type that code of the generated app refers to, with the import that declares it, such as AnalyticsService of ImportRef.app('core/analytics/analytics_service.dart').
UnionPolicy<E extends Object>
Unites lists of values, keeping the order of first appearance and dropping every repeated value.
ValueSocket<V extends Object>
A socket for one value merged from all contributions, such as the minimum iOS version of the app.
Variants
Alternative contributions of a module for different providers of role, such as a feature screen with a BLoC and a Riverpod variant.
WrapperSocket
A socket that wraps a piece of code, such as the root widget of the app.

Enums

ArgShape
Whether an argument of an ArgsSocket takes one value or a list.
DeclarationKind
Kinds of top-level declarations.
DiCapability
What a DI container can do beyond singletons, lazy singletons and factories whose factory functions take services; see DiProvider.capabilities.
DiLifetime
How long a service of the DI container lives.
HostOperatingSystem
The operating system the pipeline runs on.
IssueSeverity
How serious an SmfIssue is.
ParameterKind
Kinds of parameters.
PubspecSource
Where a PubspecDependency comes from.
RoleCardinality
How many providers of a role an app can have.
RouteParamSource
Where the value of a RouteParam comes from.

Extension Types

ModuleId
Identifies a module: a lower snake_case name such as go_router.

Extensions

KeyedSocketContributions on SocketRef<KeyedSocket<V>>
Contributions to a KeyedSocket.
KeySocketContributions on SocketRef<KeyedSocket<NoValue>>
Contributions to a KeyedSocket whose entries are only keys.
ValueSocketContributions on SocketRef<ValueSocket<V>>
Contributions to a ValueSocket.

Constants

analyticsRole → const AnalyticsRole
The analytics role; see AnalyticsRole.
appEntryRole → const AppEntryRole
The app entry role; see AppEntryRole.
crashReportingRole → const CrashReportingRole
The crash reporting role; see CrashReportingRole.
diRole → const DiRole
The DI role; see DiRole.
eventsRole → const EventsRole
The events role; see EventsRole.
layoutRole → const LayoutRole
The layout role; see LayoutRole.
routerRole → const RouterRole
The router role; see RouterRole.
stateManagementRole → const StateManagementRole
The state management role; see StateManagementRole.

Functions

compareLooseVersions(String a, String b) → int
Compares versions such as 13.0, 15, 8.7.3 or 33.3.1-jre, which minimum platform versions and Gradle artifacts use.

Typedefs

ParamKey = ({ModuleId feature, String param, String screen})
The key of a member of RouterRole.paramAnnotations: a parameter of the constructor of a screen of a feature.
ScreenKey = ({ModuleId feature, String screen})
The key of a member of RouterRole.screenAnnotations: a screen of a feature.
VariantContributions = List<Contribution> Function(ModuleContext context)
The contributions of a module's variant for one provider of a role.

Exceptions / Errors

MergeConflict
Thrown when two values for a key cannot be merged.
SmfCancelledException
Thrown when the user cancels the run, such as with Ctrl-C.
SmfUsageException
Thrown by a role hook when the user's input cannot work, such as a missing option in a non-interactive run.