Repository: flutter
Issue: Cursor disappears after TextField receives focus and executes setState.
Labels: a: text input,framework,f: material design,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,team-text-input,triaged-text-input

I'm just updating the background after my TextField receives focus. 

The TextField lost the cursor after a Container receives a color in the setState. Only happens if the color was NULL.

The setState without set the color is ok.

## Steps to Reproduce

1. Select the TextField
2. No cursor

## Code

```dart
import 'dart:math' as math;
import 'package:flutter/material.dart';

void main() {
  runApp(const ExampleApp());
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Focus',
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final FocusNode _focusNode = FocusNode();
  final TextEditingController _controller = TextEditingController();
  Color? _color;

  @override
  void initState() {
    super.initState();
    _focusNode.addListener(_onFocusChanged);
  }

  void _onFocusChanged() {
    // Here you can see that the TextField will show the cursor but will lost
    // after setState
    Future.delayed(
        const Duration(seconds: 2),
        () => setState(() {
              print('focus changed: ${_focusNode.hasFocus}');

              _color = _focusNode.hasFocus ? Colors.green[200] : null;

              // No problem after keeping any color
              // _color=_randomColor();
            }));
  }

  Color _randomColor() {
    return Color((math.Random().nextDouble() * 0xFFFFFF).toInt())
        .withOpacity(1);
  }

  @override
  void dispose() {
    _focusNode.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Container(
            // setState + color = TextField cursor gone
            color: _color,
            child: Center(
                child: SizedBox(
                    width: 150,
                    child: TextField(
                        focusNode: _focusNode, controller: _controller)))));
  }
}
```

## flutter doctor

```
cadu@cadulandia:~$ flutter doctor -v
[✓] Flutter (Channel stable, 3.0.2, on Ubuntu 20.04.4 LTS 5.13.0-51-generic, locale en_US.UTF-8)
    • Flutter version 3.0.2 at /cadu/desenv/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (3 weeks ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /home/cadu/Android/Sdk
    • Platform android-32, build-tools 32.0.0
    • ANDROID_SDK_ROOT = /home/cadu/Android/Sdk
    • Java binary at: /cadu/desenv/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /cadu/desenv/android-studio
    • Flutter plugin version 67.1.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2)
    • IntelliJ at /cadu/desenv/idea-IC-211.7628.21
    • 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

[✓] VS Code (version 1.68.1)
    • VS Code at /usr/share/code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.13.0-51-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.53

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```