attachToFlutter method
Attaches the WebF controller to a Flutter BuildContext.
This connects the WebF environment to the Flutter widget tree, enabling rendering and interactions. Must be called before content can be displayed.
Implementation
void attachToFlutter(BuildContext context) {
// Record attach to flutter phase
_loadingState.recordPhase(LoadingState.phaseAttachToFlutter, parameters: {
'routePath': initialRoute ?? '/',
'hasInitialState': initialState != null,
});
_ownerFlutterView = View.of(context);
updateTextSettingsFromContext(context);
view.attachToFlutter(context);
PaintingBinding.instance.systemFonts.addListener(_watchFontLoading);
_isFlutterAttached = true;
pushNewBuildContext(context: context, routePath: initialRoute ?? '/', state: initialState);
// Notify DevTools service about controller attach
try {
ChromeDevToolsService.unifiedService.switchToController(this);
} catch (e) {
// Ignore DevTools errors in production builds
if (kDebugMode) {
devToolsLogger.warning('DevTools notification failed', e);
}
}
}