The app widget
With this starter in the dependencies, SpringApplicationWidget(home: ...) builds a MaterialApp: the app's type is material, set with spring.flutter.app.type or, when the property is not set, deduced because this is the application's one design starter (as Spring Boot deduces spring.main.web-application-type from the class path). Everything else about the app widget is the Flutter starter's: the title, the debug banner, the locales, the navigator observers and the FlutterAppCustomizer beans come from spring.flutter.app.* as described in The app widget.
Example
# lib/resources/application.yml
spring:
flutter:
app:
type: material # may be left out: the one design starter decides
title: NEON Books
debug-banner: false
locales: en, ja
theme:
active: system # light or dark with the device
seed-color: teal
@SpringBootApplication()
void main() => runApp(
SpringApplicationWidget(
application: () => springApplication,
home: const BookListPage(),
),
);
What the MaterialApp gets
Of the MaterialApp |
From |
|---|---|
theme, darkTheme |
The MaterialThemes bean: the themes of spring.flutter.theme.* as ThemeData, changed by the ThemeCustomizer beans (see Themes in code) |
themeMode |
spring.flutter.theme.active: with system (the default) Material switches between the light and the dark theme with the device; a theme picked with the ThemeSelection bean, or loaded at run time, shows at once |
localizationsDelegates |
Material's, Cupertino's and the widgets' translations, then the app's own (FlutterAppSettings.localizationsDelegates) |
title, debugShowCheckedModeBanner, locale, supportedLocales, navigatorObservers, shortcuts, scrollBehavior |
spring.flutter.app.* and the FlutterAppCustomizer beans |
builder |
The Flutter starter's (the theme's background, the motion settings, the frame meter) inside a DesignScope with Material's text styles, Material's text selection and MaterialDesignControls |
home or routerConfig |
home: of SpringApplicationWidget; without it MaterialApp.router on the application's RouterConfig<Object> bean (the one of the navigation starter) |
The app widget is made by a bean, materialAppFactory (a MaterialAppFactory, which implements the Flutter starter's SpringAppFactory for the type material). The Flutter starter finds the factory whose type the property names or, when it is not set, the one factory besides its own widgets.
Material on Android, Cupertino on iOS
An app that is Material on most platforms and Cupertino on iPhones lists both design starters, so it must set the type, for every platform and again in the profile of iOS:
# lib/resources/application.yml
spring.flutter.app.type: material
# lib/resources/application-ios.yml
spring.flutter.app.type: cupertino
Without the property, app factories of two types fail the start instead of one being preferred:
Invalid argument(s) (spring.flutter.app.type): not set, and the application has app widgets of several types: cupertino, material. Choose one, for every platform or in a profile of each (spring.flutter.app.type=cupertino in application-ios.properties)
See spring_boot_starter_flutter_cupertino.
A MaterialApp of your own
With SpringApplicationWidget(child: ...) the app builds its own app widget, and spring.flutter.app.* is not used. It takes the themes from the MaterialThemes bean, and gives the starters' own widgets (MarkdownView, the login form) Material's look with a DesignScope:
class BooksApp extends SpringStatelessWidget<(MaterialThemes,)> {
const BooksApp({super.key});
@override
Widget build(BuildContext context) {
final (themes,) = beans;
return MaterialApp(
theme: themes.theme('light'),
darkTheme: themes.theme('dark'),
builder: (context, child) => DesignScope(
textStyle: (context, style) =>
Theme.of(context).textTheme.styleNamed(style),
selectable: (context, child) => SelectionArea(child: child),
controls: const MaterialDesignControls(),
child: child!,
),
home: const BookListPage(),
);
}
}
Without the DesignScope, the login form of the security starter still finds Material's controls (the materialDesignControls bean sees the MaterialApp above it); MarkdownView then uses the SpringTheme and the Flutter starter's own selection handles.