Repository: flutter
Issue: Dispose is not called when changing tabs of TabBarView while a keyboard is open
Labels: framework,f: material design,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-design,triaged-design,fyi-text-input

## Steps to Reproduce

1. Run `flutter create bug`. `Done`
2. Update the files as follows: 
- main.dart

```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: TabWidget(),
    );
  }
}

class TabWidget extends StatefulWidget {
  @override
  TabWidgetState createState() => TabWidgetState();
}

class TabWidgetState extends State<TabWidget>
    with SingleTickerProviderStateMixin {
  TabController tabController;

  @override
  void initState() {
    super.initState();

    tabController = TabController(vsync: this, initialIndex: 0, length: 2);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Bug App"),
        elevation: 1.0,
        bottom: TabBar(
          controller: tabController,
          tabs: <Widget>[
            Tab(child: Text("Page 1")),
            Tab(child: Text("Page 2")),
          ],
        ),
      ),
      body: TabBarView(
        controller: tabController,
        children: <Widget>[Text('This is Page 1'), Tab2Page()],
      ),
    );
  }
}

class Tab2Page extends StatefulWidget {
  @override
  Tab2PageState createState() => Tab2PageState();
}

class Tab2PageState extends State<Tab2Page>
    with SingleTickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Text('This is page 2'),
      TextField(
        maxLength: 3,
      )
    ]);
  }

  @override
  void dispose() {
    print(
        'This should be called when I change tabs, but is not callled if the keyboard is open');
    super.dispose();
  }
}
```
3. Have a `TabBarView` with two widgets as children. One tab widget has a `TextField` widget. 

**Expected results:** <!-- what did you want to see? -->
On Tab 2, when I click on the `TextField` widget, a keyboard appears. When I click to navigate to Tab 1, I expect `dispose` to be called on the StatefulWidget in Tab 2.

**Actual results:** 
When I click on Tab 1, the keyboard remains open and `dispose` is not called on the StatefulWidget in tab 2. If I close the keyboard while viewing tab 1, then dispose is called. 

<img src="https://user-images.githubusercontent.com/583936/80233995-62ef8e00-8625-11ea-99ff-e4e91b7ae280.png" width="250" height="550" />

<img src="https://user-images.githubusercontent.com/583936/80234015-6aaf3280-8625-11ea-98b1-049181e85d71.png" width="250" height="550" />


<details>
  <summary>Logs</summary>

<!--
      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.
-->

The output was too long to include here so I truncated it.

```
➜  bug git:(master) ✗ flutter run --verbose
...
[   +4 ms] 🔥  To hot reload changes while running, press "r". To hot restart
(and
           rebuild state), press "R".
[   +1 ms] An Observatory debugger and profiler on iPhone 11 Pro Max is
available at:
           http://127.0.0.1:62398/YX71IU9etW4=/
[        ] For a more detailed help message, press "h". To detach, press "d";
to quit,
           press "q".
[+186060 ms] [DEVICE LOG] 2020-04-24 12:13:55.163553-0400  localhost
Runner[67275]: (Flutter) flutter: This should be called when I change tabs,
but is not callled if the keyboard is open
[   +1 ms] flutter: This should be called when I change tabs, but is not
callled if the keyboard is open
[+1322 ms] [DEVICE LOG] 2020-04-24 12:13:56.488551-0400  localhost
Runner[67275]: (ManagedConfiguration) [com.apple.ManagedConfiguration:MC] Got
system group container path from MCM for
systemgroup.com.apple.configurationprofiles:
/Users/avi/Library/Developer/CoreSimulator/Devices/DBA213BC-C6C7-4248-89CB-DE
19D7875C10/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configura
tionprofiles
[  +22 ms] [DEVICE LOG] 2020-04-24 12:13:56.509830-0400  localhost
Runner[67275]: (AggregateDictionary) AggregateDictionary is not supported on
this platform
[ +111 ms] [DEVICE LOG] 2020-04-24 12:13:56.622448-0400  localhost
Runner[67275]: (CallKit) [com.apple.calls.callkit:Default] Call host has no
calls
[  +50 ms] [DEVICE LOG] 2020-04-24 12:13:56.649266-0400  localhost
Runner[67275]: (CoreFoundation) Created Activity ID: 0x2e1516, Description:
Updating Key-Value Observers Of Preferences
[        ] [DEVICE LOG] 2020-04-24 12:13:56.653467-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:FeedbackActivation] activate
generator with style: TurnOn; activationCount: 0 -> 1; styleActivationCount:
0 -> 1; <_UIKeyboardFeedbackGenerator: 0x600002c10fa0>
[   +3 ms] [DEVICE LOG] 2020-04-24 12:13:56.653689-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] activate engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0>, clientCount: 0 -> 1
[        ] [DEVICE LOG] 2020-04-24 12:13:56.653808-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] activating engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0>
[        ] [DEVICE LOG] 2020-04-24 12:13:56.654179-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0: state=3, numberOfClients=1,
prewarmCount=0, _internal_isSuspended=0> state changed: Inactive ->
Activating
[        ] [DEVICE LOG] 2020-04-24 12:13:56.654310-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0: state=4, numberOfClients=1,
prewarmCount=0, _internal_isSuspended=0> state changed: Activating -> Running
[   +3 ms] [DEVICE LOG] 2020-04-24 12:13:56.664478-0400  localhost
Runner[67275]: (RunningBoardServices) Created Activity ID: 0x2e1517,
Description: didChangeInheritances
[+10953 ms] [DEVICE LOG] 2020-04-24 12:14:07.627132-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:FeedbackActivation] activate
generator with style: TurnOn; activationCount: 1 -> 2; styleActivationCount:
1 -> 2; <_UIKeyboardFeedbackGenerator: 0x600002c10fa0>
[   +2 ms] [DEVICE LOG] 2020-04-24 12:14:07.627388-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] generator
<_UIKeyboardFeedbackGenerator: 0x600002c10fa0> playing feedback
<_UICustomDiscreteFeedback: 0x600002f00cf0>
[        ] [DEVICE LOG] 2020-04-24 12:14:07.627544-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] player dequeue needed -
initial request for feedback <_UICustomDiscreteFeedback: 0x600002f00cf0>
[   +4 ms] [DEVICE LOG] 2020-04-24 12:14:07.627626-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] player dequeue finished
for feedback <_UICustomDiscreteFeedback: 0x600002f00cf0> with player
<_UIFeedbackSystemSoundEngine: 0x6000036258f0>
[   +5 ms] [DEVICE LOG] 2020-04-24 12:14:07.634267-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:FeedbackActivation] deactivate
generator with style: TurnOn; activationCount: 2 -> 1; styleActivationCount:
2 -> 1; <_UIKeyboardFeedbackGenerator: 0x600002c10fa0>
[   +1 ms] [DEVICE LOG] 2020-04-24 12:14:07.634391-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] played feedback
<_UICustomDiscreteFeedback: 0x600002f00cf0> with engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0> at time 172050.635894
[ +142 ms] [DEVICE LOG] 2020-04-24 12:14:07.785147-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:FeedbackActivation] deactivate
generator with style: TurnOn; activationCount: 1 -> 0; styleActivationCount:
1 -> 0; <_UIKeyboardFeedbackGenerator: 0x600002c10fa0>
[   +3 ms] [DEVICE LOG] 2020-04-24 12:14:07.785371-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] deactivate engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0>, clientCount: 1 -> 0
[   +2 ms] [DEVICE LOG] 2020-04-24 12:14:07.785449-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback]
_internal_deactivateEngineIfPossible <_UIFeedbackSystemSoundEngine:
0x6000036258f0>, clientCount: 0, suspended: 0
[   +2 ms] [DEVICE LOG] 2020-04-24 12:14:07.785502-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback]
_internal_deactivateEngineIfPossible <_UIFeedbackSystemSoundEngine:
0x6000036258f0> tearedDown: 1
[   +1 ms] [DEVICE LOG] 2020-04-24 12:14:07.785668-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0: state=0, numberOfClients=0,
prewarmCount=0, _internal_isSuspended=0> state changed: Running -> Inactive
[  +90 ms] [DEVICE LOG] 2020-04-24 12:14:07.890558-0400  localhost
Runner[67275]: (Flutter) flutter: This should be called when I change tabs,
but is not callled if the keyboard is open
[   +2 ms] flutter: This should be called when I change tabs, but is not
callled if the keyboard is open
[ +505 ms] [DEVICE LOG] 2020-04-24 12:14:08.399732-0400  localhost
Runner[67275]: (RunningBoardServices) Created Activity ID: 0x2e1518,
Description: didChangeInheritances
[+7960 ms] [DEVICE LOG] 2020-04-24 12:14:16.311409-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:FeedbackActivation] activate
generator with style: TurnOn; activationCount: 0 -> 1; styleActivationCount:
0 -> 1; <_UIKeyboardFeedbackGenerator: 0x600002c10fa0>
[   +1 ms] [DEVICE LOG] 2020-04-24 12:14:16.311514-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] activate engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0>, clientCount: 0 -> 1
[   +2 ms] [DEVICE LOG] 2020-04-24 12:14:16.311596-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] activating engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0>
[   +1 ms] [DEVICE LOG] 2020-04-24 12:14:16.311740-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0: state=3, numberOfClients=1,
prewarmCount=0, _internal_isSuspended=0> state changed: Inactive ->
Activating
[   +1 ms] [DEVICE LOG] 2020-04-24 12:14:16.311860-0400  localhost
Runner[67275]: (UIKitCore) [com.apple.UIKit:Feedback] engine
<_UIFeedbackSystemSoundEngine: 0x6000036258f0: state=4, numberOfClients=1,
prewarmCount=0, _internal_isSuspended=0> state changed: Activating -> Running
[  +43 ms] [DEVICE LOG] 2020-04-24 12:14:16.328590-0400  localhost
Runner[67275]: (RunningBoardServices) Created Activity ID: 0x2e1519,
Description: didChangeInheritances
[+20154 ms] Application finished.
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
➜  bug git:(master) ✗ flutter analyze
Analyzing bug...
No issues found! (ran in 13.3s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
➜  bug git:(master) ✗ flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287,
    locale en-US)
    • Flutter version 1.12.13+hotfix.9 at /Users/avi/flutter
    • Framework revision f139b11009 (4 weeks ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2


[✓] Android toolchain - develop for Android devices (Android SDK version
    29.0.2)
    • Android SDK at /Users/avi/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native
      profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Users/avi/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/192.6392135/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.6)
    • Android Studio at /Users/avi/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/192.6392135/Android
      Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build
      1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.42.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.8.1

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • DBA213BC-C6C7-4248-89CB-DE19D7875C10 • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)

• No issues found!
```

</details>