Skip to content

LateInitializationError: Local 'widgetParams' has not been initialized. #27

@drkdelaney

Description

@drkdelaney

I'm getting the above error when I run tests in my pipelines. The problem is these lines of code:

  Widget build(BuildContext context) {
    late final wf.PlatformWebViewWidgetCreationParams widgetParams;
    if (Platform.isAndroid) {
      widgetParams = wf_android.AndroidWebViewWidgetCreationParams(
        controller: originalWebViewController.platform,
        gestureRecognizers:
            widget.mobileSpecificParams.mobileGestureRecognizers ?? const {},
        displayWithHybridComposition:
            widget.mobileSpecificParams.androidEnableHybridComposition,
      );
    } else if (Platform.isIOS || Platform.isMacOS) {
      widgetParams = wf_wk.WebKitWebViewWidgetCreationParams(
        controller: originalWebViewController.platform,
        gestureRecognizers:
            widget.mobileSpecificParams.mobileGestureRecognizers ?? const {},
      );
    }
...

In my environment we are using linux to run the test. So my Platform here is Platform.isLinux which is not an option. Is there a way to handle the else case when its not those three or use target platform defaultTargetPlatform == TargetPlatform.android and then in my test I can override TargetPlatform with debugDefaultTargetPlatformOverride = TargetPlatform.iOS? If there's a third options I'm not thinking I would be happy to implement that too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions