TfFramework class

框架的总入口:统一管理组件库、偏好设置和设置页内容。

在 runApp 之前用 TfFramework.initialize 创建,然后交给 TfApp。 任何页面都可以用 TfFramework.of 取到它。

Future<void> main() async {
  final framework = await TfFramework.initialize(
    designSystems: const [Material3DesignSystem(), LiquidGlassDesignSystem()],
    settingsBuilder: (context) => [
      TfSettingsSection(title: '账号', settings: [...]),
    ],
  );
  runApp(TfApp(framework: framework, home: const HomePage()));
}

// 页面中:
final framework = TfFramework.of(context);
framework.preferences.get(AppKeys.token);
framework.switchDesignSystem(LiquidGlassDesignSystem.systemId);

Properties

activeDesignSystem → TfDesignSystem
当前使用的组件库;保存的 id 无效时回退到默认组件库。
no setter
defaultDesignSystem → TfDesignSystem
默认组件库(designSystems 的第一个)。
no setter
designSystems → List<TfDesignSystem>
注册的组件库,第一个为默认值。
final
hashCode → int
The hash code for this object.
no setterinherited
preferences → TfPreferencesController
所有偏好的读写入口。
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
settings → List<TfSettingsSection>
应用注册的固定设置分组。
final
settingsBuilder → TfSettingsBuilder?
应用注册的动态设置分组。
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
settingsFor(BuildContext context) → List<TfSettingsSection>
合并 settings 和 settingsBuilder 的结果。
switchDesignSystem(String id) → Future<void>
切换到指定 id 的组件库,界面立即刷新并保存选择;页面栈保持不变。
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

initialize({required List<TfDesignSystem> designSystems, TfPreferenceStore? store, List<TfSettingsSection> settings = const [], TfSettingsBuilder? settingsBuilder}) → Future<TfFramework>
读取已保存的偏好,并初始化所有组件库(例如预热液态玻璃着色器)。
of(BuildContext context) → TfFramework
获取 TfApp 提供的框架实例。