Repository: flutter
Issue: [Desktop] Pasting large run of non-whitespace text consumes many GB and freezes the app
Labels: a: text input,framework,c: performance,a: desktop,perf: memory,has reproducible steps,P2,found in release: 2.8,found in release: 2.9,team-text-input,triaged-text-input

## Steps to Reproduce

1. Execute `flutter run` on the code sample
2. Download large text files from [The Large Corpus](http://corpus.canterbury.ac.nz/resources/large.zip)
3. Paste the contents of E.coli into the text field

**Expected results:** Application does not hang

**Actual results:** Application hangs and memory usage skyrockets:

macOS:
![image](https://user-images.githubusercontent.com/72562119/148201841-f5ec3308-22a9-4e85-9498-5dca6e710b33.png)

Windows:
![large_text memory](https://user-images.githubusercontent.com/72562119/148202679-b4d930d1-1cc4-4f83-bb45-8095b2141333.png)

Pasting a similar amount of text (e.g. world192.txt which is 2.5MB and bible.txt which is 4MB) with spaces and newlines doesn't cause this (editing is painfully slow though, similar to https://github.com/flutter/flutter/issues/90063).


<details>
<summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: const <Widget>[
            Text('Paste huge text below'),
            Expanded(
              child: TextField(maxLines: null, expands: true),
            ),
          ],
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

```
% flutter doctor -v
[✓] Flutter (Channel master, 2.9.0-1.0.pre.233, on macOS 12.1 21C52 darwin-x64, locale en-GB)
    • Flutter version 2.9.0-1.0.pre.233 at /Library/Frameworks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e9b8a6efb2 (18 hours ago), 2022-01-04 17:24:42 +0100
    • Engine revision a6ce607b13
    • Dart version 2.16.0 (build 2.16.0-134.0.dev)
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/jsmith/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.32.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.1 21C52 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 96.0.4664.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>