Repository: flutter
Issue: [webview_flutter] Navigation delegate does not have the same behavior on Android and iOS
Labels: a: fidelity,p: webview,package,team-ecosystem,has reproducible steps,P2,found in release: 2.2,found in release: 2.5,triaged-ecosystem

## TL;DR:

The navigation delegate is called several different times on iOS versus Android, which may make custom navigation handler difficult to maintain. The solution would be to rely on `isForMainFrame` to know if we enter the delegate on a real user interaction or not, but it may be confusing sometimes.

## Steps to Reproduce

1. Create a simple application with a webview with URL 'https://app-mobile-webview.mobizel.com/webview_flutter/html_with_links.html' or clone and build the following project branch
```
git clone -b issue/navigation-delegate-ios-versus-android git@github.com:stevemoreau/flutter_webview.git
```
2. Run project on Android, click on the first link, and you should logs
```
I/flutter ( 3838): Entering build()
I/flutter ( 3838): Page started loading: https://app-mobile-webview.mobizel.com/webview_flutter/html_with_links.html
I/flutter ( 3838): Page finished loading: https://app-mobile-webview.mobizel.com/webview_flutter/html_with_links.html

// LINK CLICK HAPPENED HERE

I/flutter ( 3838): Entering navigationDelegate: requestUrl=https://www.mobizel.com/dummy-link-internal isForMainFrame=true
I/flutter ( 3838): Page started loading: https://www.mobizel.com/dummy-link-internal
I/flutter ( 3838): Page finished loading: https://www.mobizel.com/dummy-link-internal
```
3. Then, run project on iOS, click on the first link, you should see logs
```
flutter: Entering build()
flutter: Entering build()
flutter: Entering navigationDelegate: requestUrl=https://app-mobile-webview.mobizel.com/webview_flutter/html_with_links.html isForMainFrame=true
flutter: Page started loading: https://app-mobile-webview.mobizel.com/webview_flutter/html_with_links.html
flutter: Entering navigationDelegate: requestUrl=https://www.youtube.com/embed/p9rFDcS4F00 isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Page finished loading: https://app-mobile-webview.mobizel.com/webview_flutter/html_with_links.html

// LINK CLICK HAPPENED HERE

flutter: Entering navigationDelegate: requestUrl=https://www.mobizel.com/dummy-link-internal isForMainFrame=true
flutter: Page started loading: https://www.mobizel.com/dummy-link-internal
flutter: Entering navigationDelegate: requestUrl=https://www.google.com/recaptcha/api2/anchor?ar=1&k=6LdO8pAUAAAAAK6Ei_JJmKQIztUcBZaBod-3NdCL&co=aHR0cHM6Ly93d3cubW9iaXplbC5jb206NDQz&hl=en&v=mhgGrlTs_PbFQOW4ejlxlxZn&size=invisible&cb=4xw6wzque43i isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Page finished loading: https://www.mobizel.com/dummy-link-internal
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
flutter: Entering navigationDelegate: requestUrl=about:blank isForMainFrame=false
```

**Target Platform:** iOS/Android
**Target OS version: Any**
**Devices: Any**
**Flutter configuration:** webview_flutter: ^0.3.18+1

## Logs

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

$ flutter run --verbose
[webview_navigation_delegate_android.txt](https://github.com/flutter/flutter/files/3973980/webview_navigation_delegate_android.txt)
[webview_navigation_delegate_ios.txt](https://github.com/flutter/flutter/files/3973981/webview_navigation_delegate_ios.txt)


<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
$ flutter analyze
Analyzing flutter_webview...                          
No issues found! (ran in 9.5s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
$ flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.1 19B88, locale fr-FR)
    • Flutter version 1.12.13+hotfix.5 at /Users/steve/sdk/flutter
    • Framework revision 27321ebbad (6 days ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/steve/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3, Build version 11C29
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (2 available)
    • Android SDK built for x86 • emulator-5554                            • android-x86 • Android 7.0 (API 24) (emulator)
    • iPhone                    • 5c21e6117ed37334bb86a3667172e7317c1f609e • ios         • iOS 13.2.3

• No issues found!
```