init static method
Initialize the adaptive UI
This method should be called before using any adaptive UI components, preferably in the main() method of your app.
Example:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AdaptiveUIUX.init();
runApp(MyApp());
}
Implementation
static Future<void> init({AdaptiveConfig? customConfig}) async {
if (_initialized) {
debugPrint('AdaptiveUIUX already initialized');
return;
}
// Set configuration if provided
if (customConfig != null) {
config = customConfig;
}
// Initialize dependencies
_layoutStore = LayoutStore();
_tracker = InteractionTracker();
_ruleEngine = RuleEngine(
tracker: _tracker,
layoutStore: _layoutStore,
minInteractions: config.threshold,
);
// Start auto-adjustments if enabled
if (config.enableAutoAdjust) {
_ruleEngine.startAutoAdjustments();
}
// Enable debug logging if requested
if (config.enableDebugLogging) {
_enableDebugLogging();
}
_initialized = true;
debugPrint('AdaptiveUIUX initialized successfully');
}