The app widget
With this starter in the dependencies, SpringApplicationWidget(home: ...) builds a CupertinoApp: the app's type is cupertino, 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). The rest of 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: cupertino # may be left out: the one design starter decides
title: NEON Books
locales: en, ja
@SpringBootApplication()
void main() => runApp(
SpringApplicationWidget(
application: () => springApplication,
home: const BookListPage(),
),
);
What the CupertinoApp gets
Of the CupertinoApp |
From |
|---|---|
theme |
The CupertinoThemeData of the theme shown, from the CupertinoThemes bean (see Themes in code). With spring.flutter.theme.active: system, a device switching to dark mode shows the Cupertino theme of the dark theme; a theme picked with the ThemeSelection bean, or loaded at run time, shows at once |
localizationsDelegates |
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 iOS's text selection and CupertinoDesignControls |
home or routerConfig |
home: of SpringApplicationWidget; without it CupertinoApp.router on the application's RouterConfig<Object> bean (the one of the navigation starter) |
The app widget is made by the bean cupertinoAppFactory (a CupertinoAppFactory, the Flutter starter's SpringAppFactory for the type cupertino).
Cupertino on iOS only
# lib/resources/application.yml: Material everywhere ...
spring.flutter.app.type: material
# lib/resources/application-ios.yml: ... and Cupertino on iPhones
spring.flutter.app.type: cupertino
Such an app lists both design starters, and both material_ui and cupertino_ui. With two design starters the type cannot be deduced: without spring.flutter.app.type the start fails instead of preferring one:
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)
A CupertinoApp of your own
With SpringApplicationWidget(child: ...) the app builds its own app widget, and spring.flutter.app.* is not used. It takes the theme from the CupertinoThemes bean, and gives the starters' own widgets Cupertino's controls with a DesignScope:
class BooksApp extends SpringStatelessWidget<(CupertinoThemes,)> {
const BooksApp({super.key});
@override
Widget build(BuildContext context) {
final (themes,) = beans;
return CupertinoApp(
theme: themes.theme('light'),
builder: (context, child) => DesignScope(
controls: const CupertinoDesignControls(),
textStyle: (context, style) => null, // the SpringTheme's styles
selectable: (context, child) => child,
child: child!,
),
home: const LoginPage(),
);
}
}
Without the DesignScope, the login form still finds Cupertino's controls: the cupertinoDesignControls bean sees the CupertinoApp above it.