import 'dart:async'; import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; void setGetSettings() { testWidgets('set/get settings', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: InAppWebView( key: GlobalKey(), initialUrlRequest: URLRequest(url: Uri.parse('https://github.com/flutter')), initialSettings: InAppWebViewSettings( javaScriptEnabled: false ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, onLoadStop: (controller, url) { pageLoaded.complete(); }, ), ), ); final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; InAppWebViewSettings? settings = await controller.getSettings(); expect(settings, isNotNull); expect(settings!.javaScriptEnabled, false); await controller.setSettings(settings: InAppWebViewSettings( javaScriptEnabled: true)); settings = await controller.getSettings(); expect(settings, isNotNull); expect(settings!.javaScriptEnabled, true); }); }