アプリのウィジェット

依存関係にこのスターターがあれば、SpringApplicationWidget(home: ...) は CupertinoApp を組み立てます。アプリの種類は cupertino で、spring.flutter.app.type で設定されるか、プロパティが設定されていなければ、これがアプリケーションの唯一のデザインのスターターなので推定されます (Spring Boot がクラスパスから spring.main.web-application-type を推定するのと同じです)。アプリのウィジェットの残りは Flutter のスターターのものです。タイトル、デバッグバナー、ロケール、ナビゲーターのオブザーバー、FlutterAppCustomizer Bean は、アプリのウィジェット に説明されているとおり spring.flutter.app.* から来ます。

例

# lib/resources/application.yml
spring:
  flutter:
    app:
      type: cupertino       # 省略可: 唯一のデザインのスターターが決める
      title: NEON Books
      locales: en, ja
@SpringBootApplication()
void main() => runApp(
  SpringApplicationWidget(
    application: () => springApplication,
    home: const BookListPage(),
  ),
);

CupertinoApp が受け取るもの

CupertinoApp の 由来
theme 表示されるテーマの CupertinoThemeData。CupertinoThemes Bean から (コードでのテーマ を参照)。spring.flutter.theme.active: system では、ダークモードに切り替わったデバイスはダークのテーマの Cupertino のテーマを表示する。ThemeSelection Bean で選ばれたテーマや、実行時に読み込まれたテーマは即座に表示される
localizationsDelegates Cupertino とウィジェットの翻訳、その後にアプリ独自のもの (FlutterAppSettings.localizationsDelegates)
title、debugShowCheckedModeBanner、locale、supportedLocales、navigatorObservers、shortcuts、scrollBehavior spring.flutter.app.* と FlutterAppCustomizer Bean
builder Flutter のスターターのもの (テーマの背景、モーションの設定、フレームメーター) を、iOS のテキスト選択と CupertinoDesignControls を持つ DesignScope の中に置いたもの
home または routerConfig SpringApplicationWidget の home:。それがなければ、アプリケーションの RouterConfig<Object> Bean (ナビゲーションのスターター のもの) の上の CupertinoApp.router

アプリのウィジェットは Bean cupertinoAppFactory (CupertinoAppFactory。型 cupertino のための Flutter のスターターの SpringAppFactory) が作ります。

iOS でだけ Cupertino

# lib/resources/application.yml: どこでも Material ...
spring.flutter.app.type: material
# lib/resources/application-ios.yml: ... そして iPhone では Cupertino
spring.flutter.app.type: cupertino

このようなアプリは、二つのデザインのスターターと、material_ui と cupertino_ui の両方を列挙します。デザインのスターターが二つあると種類は推定できません。spring.flutter.app.type がなければ、一方を優先するのではなく、起動が失敗します。

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)

独自の CupertinoApp

SpringApplicationWidget(child: ...) では、アプリは独自のアプリのウィジェットを組み立て、spring.flutter.app.* は使われません。テーマは CupertinoThemes Bean から受け取り、スターター自身のウィジェットには DesignScope で Cupertino のコントロールを与えます。

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,       // SpringTheme のスタイル
        selectable: (context, child) => child,
        child: child!,
      ),
      home: const LoginPage(),
    );
  }
}

DesignScope がなくても、ログインフォームは Cupertino のコントロールを見つけます。cupertinoDesignControls Bean がその上の CupertinoApp を見つけます。

関連項目