Open stefanhk31 opened 8 months ago
Also possible to mock with MockPlatformInterfaceMixin
:
class _MockUrlLauncherPlatform extends Mock
with MockPlatformInterfaceMixin
implements UrlLauncherPlatform {}
class _FakeLaunchOptions extends Fake implements LaunchOptions {}
// ...
late UrlLauncherPlatform urlLauncher;
setUpAll(() async {
registerFallbackValue(_FakeLaunchOptions());
});
setUp(() {
urlLauncher = _MockUrlLauncherPlatform();
UrlLauncherPlatform.instance = urlLauncher;
when(() => urlLauncher.canLaunch(any())).thenAnswer((_) async => true);
when(() => urlLauncher.launchUrl(any(), any()))
.thenAnswer((_) async => true);
});
Might make sense to add a dedicated repository to wrap url launcher. It'd be light, but would solve the test cov issues and possibly also make some of the clickable link widgets cleaner?
...or better yet, can url launcher go in Blog repo?