at main 1.3 kB view raw
1import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; 2 3/// Mock implementation of UrlLauncherPlatform for testing 4class MockUrlLauncherPlatform extends UrlLauncherPlatform { 5 final List<String> launchedUrls = []; 6 PreferredLaunchMode? lastLaunchMode; 7 bool canLaunchResponse = true; 8 bool launchResponse = true; 9 10 @override 11 Future<bool> canLaunch(String url) async { 12 return canLaunchResponse; 13 } 14 15 @override 16 Future<bool> launch( 17 String url, { 18 required bool useSafariVC, 19 required bool useWebView, 20 required bool enableJavaScript, 21 required bool enableDomStorage, 22 required bool universalLinksOnly, 23 required Map<String, String> headers, 24 String? webOnlyWindowName, 25 }) async { 26 launchedUrls.add(url); 27 return launchResponse; 28 } 29 30 @override 31 Future<bool> launchUrl(String url, LaunchOptions options) async { 32 launchedUrls.add(url); 33 lastLaunchMode = options.mode; 34 return launchResponse; 35 } 36 37 @override 38 Future<bool> supportsMode(PreferredLaunchMode mode) async { 39 return true; 40 } 41 42 @override 43 Future<bool> supportsCloseForMode(PreferredLaunchMode mode) async { 44 return false; 45 } 46 47 @override 48 dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 49}