flutter_webview_communication 0.3.0
flutter_webview_communication: ^0.3.0 copied to clipboard
A comprehensive Flutter plugin for bi-directional WebView communication with 70+ methods including navigation, security, monitoring, and advanced features.
Changelog #
0.3.0 (Unreleased) #
Added #
-
Full Platform Support (NEW!):
- ✅ Web - Now fully supported using IFrameElement
- ✅ Windows - Now fully supported using webview_windows package
- ✅ Linux - Now fully supported using WebKitGTK
- ✅ macOS - Background color now supported via CSS fallback
- All 84+ methods work across all platforms
- Platform-specific optimizations and fallbacks
-
File Handling (NEW!):
downloadFile()- Download files from URLs with progress trackingcancelDownload()- Cancel active downloadsgetActiveDownloads()- Get list of active downloadspickFiles()- Open file picker for file selectiongetDownloadsDirectoryPath()- Get platform-specific downloads directoryhandleFileDownload()- Trigger file download callbackhandleFileUpload()- Trigger file upload callbackgetMimeType()- Get MIME type from filenameOnFileDownloadcallback typedef for download requestsOnFileUploadRequestcallback typedef for upload requestsOnDownloadProgresscallback typedef for progress updates- Added
file_picker: ^8.1.6dependency - Added
path_provider: ^2.1.5dependency - Added
dio: ^5.7.0dependency for downloads
-
Permission Handling (NEW!):
requestGeolocationPermission()- Request location permissionhasGeolocationPermission()- Check location permission statusrequestCameraPermission()- Request camera permissionhasCameraPermission()- Check camera permission statusrequestMicrophonePermission()- Request microphone permissionhasMicrophonePermission()- Check microphone permission statusrequestStoragePermission()- Request storage/photos permissionhasStoragePermission()- Check storage permission statusrequestMultiplePermissions()- Request multiple permissions at oncecheckMultiplePermissions()- Check multiple permissions at onceopenAppSettings()- Open app settings for manual permission grantisPermissionPermanentlyDenied()- Check if permission is permanently denied
-
JavaScript Channel Management:
addJavaScriptChannel()- Add custom JavaScript channelsremoveJavaScriptChannel()- Remove JavaScript channelslistJavaScriptChannels()- List all registered channelshasJavaScriptChannel()- Check if channel exists
-
Console Message Capture:
enableConsoleCapture()- Capture console.log, console.error, etc.getConsoleMessages()- Get all captured console messagesclearConsoleMessages()- Clear console message history
-
Page Metadata & Information:
getPageMetadata()- Get comprehensive page metadatagetPageLinks()- Get all links on the pagegetPageImages()- Get all images on the pagegetPageHtml()- Get page HTML contentgetPageText()- Get page text content (without HTML tags)
-
Element Interaction:
injectCSS()- Inject custom CSS into the pageremoveInjectedCSS()- Remove injected CSS by IDclickElement()- Click an element by CSS selectorsetInputValue()- Set input element valuegetInputValue()- Get input element valueelementExists()- Check if element existscountElements()- Count elements matching selectorscrollElementIntoView()- Scroll element into view
-
Security & URL Filtering:
setAllowedUrls()- Set URL whitelistsetBlockedUrls()- Set URL blacklistsetUrlValidator()- Set custom URL validatorisUrlAllowed()- Check if URL is allowedclearUrlRestrictions()- Clear all URL restrictions
-
Performance Monitoring:
getPerformanceMetrics()- Get page load performance metricsgetMemoryUsage()- Get JavaScript memory usagegetResourceCount()- Get count of loaded resources by type
-
Network Monitoring:
enableNetworkMonitoring()- Monitor XHR and Fetch requests
Dependencies #
- Added
permission_handler: ^11.3.1for native permission handling
Platform Configuration #
-
Android: Added permission declarations in AndroidManifest.xml
- Location (fine and coarse)
- Camera
- Microphone
- Storage (legacy and granular media permissions for Android 13+)
-
iOS: Added permission descriptions in Info.plist
- Location (when in use and always)
- Camera
- Microphone
- Photo Library (read and write)
Improved #
- Better error handling for all new methods
- Enhanced debugging capabilities
- More comprehensive page inspection tools
- Automatic URL filtering in navigation delegate
0.2.0 (Unreleased) #
Breaking Changes #
- Updated minimum dependencies to support new features
Added #
-
Navigation Controls:
goBack()- Navigate back in historygoForward()- Navigate forward in historycanGoBack()- Check if can navigate backcanGoForward()- Check if can navigate forwardgetCurrentUrl()- Get current page URLgetTitle()- Get current page titlestopLoading()- Stop current page load
-
Zoom Controls:
setZoomEnabled(bool)- Enable/disable zoomzoomIn()- Zoom in by 20%zoomOut()- Zoom out by 20%setZoomLevel(double)- Set specific zoom levelgetZoomLevel()- Get current zoom level
-
Enhanced Cookie Management:
getCookie(String name, String url)- Get specific cookiesetCookie()- Set cookie with domain and expirationhasCookies()- Check if cookies existgetAllCookies()- Get all cookies as map
-
Scroll Controls:
scrollTo(double x, double y)- Scroll to positionscrollBy(double x, double y)- Scroll by offsetscrollToTop()- Scroll to top of pagescrollToBottom()- Scroll to bottom of page- Smooth scrolling support for all scroll methods
-
Find in Page:
findInPage(String searchText)- Find text in pagefindNext()- Navigate to next matchfindPrevious()- Navigate to previous matchclearFindMatches()- Clear all highlightsgetFindMatchInfo()- Get current match info
-
Lifecycle Management:
dispose()- Properly dispose WebView resources
Improved #
- Updated dependencies to latest compatible versions
- Enhanced error handling across all methods
- Better debug logging for all operations
- Improved documentation with detailed examples
Fixed #
- Copyright headers standardized across all files
- Deprecated test matchers replaced
0.1.6 #
- Added
enableCommunicationflag to control injection of communication scripts for URLs and HTML. - Added
onJavaScriptErrorcallback to handle JavaScript errors across all operations. - Enhanced
buildWebViewwith new parameters:enableCommunication: Overrides constructor’s setting for communication scripts.userAgent: Sets a custom user agent string.csp: Adds Content Security Policy for custom HTML.onLoadingStateChanged: Provides callbacks for page loading states (started,progress,finished,error).
- Added
removeFromLocalStoragemethod to remove a specific key from WebView local storage. - Added
getLocalStoragemethod to retrieve all key-value pairs from WebView local storage. - Added
clearWebViewDatamethod to clear cookies, cache, and local storage. - Added
reloadmethod to refresh the current WebView content (HTML or URL). - Improved error handling with detailed debug messages and
rethrowfor all async methods.
0.1.3 #
- Bug fix.
- Implemented removal of existing local storage data before saving new data.
- Improved error handling with silent logging for local storage operations.
- Updated documentation and comments for better clarity.
0.1.2 #
- Added support for injecting custom JavaScript into URL-loaded pages.
- Added
saveToLocalStoragemethod to store data in the WebView's local storage for both HTML and URL content. - Updated documentation and example to demonstrate HTML, URL usage with JavaScript injection, and local storage.
0.1.1 #
- Fixed platform support issues by implementing conditional imports for
webview_flutter_androidandwebview_flutter_wkwebview. - Added explicit platform initialization and support for Android, iOS, and macOS.
- Added error handling for unsupported platforms (Web, Windows, Linux) with
Exception. - Updated example to handle unsupported platforms gracefully.
- Added support for loading URLs in addition to HTML content in
buildWebViewwith theisUrlparameter. - Updated documentation and example to demonstrate both HTML and URL usage.
0.1.0 #
- Initial release
- Bi-directional communication between Flutter and WebView
- Support for custom HTML, CSS, and JavaScript
- Platform-specific configurations for Android and iOS