-
Notifications
You must be signed in to change notification settings - Fork 172
Description
We're having a strange issue with mockito generating the wrong types in webview_flutter_android when trying to update analyzer. I have tried to make a minimal repro case, but haven't been able to recreate the problem so far so filing with what I have for now.
STR:
- git clone https://github.com/flutter/packages
- cd packages/packages/webview_flutter/webview_flutter_android
- Edit
pubspec.yamlto change thepigeondependency topigeon: ^9.0.0. (This allowsanalyzerto resolve to 5.7.1 instead of 4.x.) thenflutter pub get flutter pub run build_runner build --delete-conflicting-outputsflutter test test/android_webview_test.dart
The test fails to compile:
Error: The return type of the method 'MockWebView.getScrollPosition' is
'Future<dynamic>', which does not match the return type, 'Future<Offset>', of the overridden method,
'WebView.getScrollPosition'.
- 'Future' is from 'dart:async'.
- 'Offset' is from 'dart:ui'.
Change to a subtype of 'Future<Offset>'.
_i4.Future<dynamic> getScrollPosition() => (super.noSuchMethod(
^
lib/src/android_webview.dart:331:18: Context: This is the overridden method ('getScrollPosition').
Future<Offset> getScrollPosition() {
^
There are similar problems with a Future<Size>.
If you skip step 3, everything is fine, and the generated code has the correct type. Comparing the lock files, it's just analyzer that changes between them (and pigeon of course, but I'm not re-running Pigeon generation, so its version is irrelevant).
I tried adding Offset to the @GenerateMocks list in android_webview_test.dart to see if that would help, and that causes (with 5.x only): Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension.
I made a simple project that just has a class with a Future<Offset> method in it, and couldn't reproduce this, but I haven't yet been able to figure out what the important difference is.