FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
120 stars 18 forks source link

Unable to Import Webview in custom Widget #3124

Closed gellert234-dev closed 3 months ago

gellert234-dev commented 3 months ago

Can we access your project?

Current Behavior

I'm trying to use the webview package in my custom widget however I am unable to import it. I got this error: The method 'WebView' isn't defined for the type '_CustomWebViewState'. Try correcting the name to the name of an existing method, or defining a method named 'WebView'.

Example code:

// Automatic FlutterFlow imports import '/backend/supabase/supabase.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/custom_code/widgets/index.dart'; // Imports other custom widgets import '/custom_code/actions/index.dart'; // Imports custom actions import '/flutter_flow/custom_functions.dart'; // Imports custom functions import 'package:flutter/material.dart'; // Begin custom widget code // DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:webview_flutter/webview_flutter.dart'; // Import the webview_flutter package

class CustomWebView extends StatefulWidget { const CustomWebView({ super.key, this.width, this.height, required this.url, });

final double? width; final double? height; final String url;

@override State createState() => _CustomWebViewState(); }

class _CustomWebViewState extends State { late WebViewController _controller;

@override Widget build(BuildContext context) { return Container( width: widget.width, height: widget.height, child: WebView( initialUrl: widget.url, ), ); } }

Expected Behavior

I did this because I want Facebook pages to load in my app, but I need to change the user agent for it. I tried "bypass domain restriction," but it doesn't work.

Steps to Reproduce

1:Create new widget and try to use webview.

Reproducible from Blank

Bug Report Code (Required)

IT4WkvHl4ZNPm+kF7aXybfpanSQUJj8ia6xNm8N+SkwYJZz2BJwPXPykP1doTcOiTFZYMFv8knEJzMrTvs7LGOQHAzWtc6ZFzqgIEArgfE66VYSzDoeOPERtEcdRNEuV5MOFqxBNHPdpSEYm6k2AIdivf3bXJJzSPTE7QeaXLt7AnnfhAi+6Xn0Jg1ZSfCvr

Visual documentation

image

Environment

- FlutterFlow version: FlutterFlow v4.1.59+ released June 12, 2024
Flutter version is 3.19.1
- Platform: Web and mobile
- Browser name and version: ungoogled-chromium 125.0.6422.60-3
- Operating system and version affected: Arch Linux

Additional Information

No response

gellert234-dev commented 3 months ago

I fixed this problem using WebViewWidget and WebViewX.

https://community.flutterflow.io/ask-the-community/post/unable-to-import-webview-in-custom-widget-YUWDbplU6K1I91m

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.