Repository: flutter
Issue: Scroll Listener does not trigger when keyboard is dismissed
Labels: framework,f: scrolling,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.27,found in release: 3.28

### Steps to reproduce

When a TextField is used within a CustomScrollView, opening the keyboard triggers events from the ScrollController due to changes in the scroll position. However, when the keyboard is dismissed, no ScrollController events are triggered, even though the scroll position adjusts due to layout changes.

UI elements or functionalities relying on ScrollController events, such as animations or dynamic header color changes, may not function correctly when the keyboard is dismissed.

1. Run the app on a physical or virtual device.
2. Tap on the TextField to focus on it, causing the keyboard to appear.
3. Observe that the ScrollController updates its events and observe the top header color changing dynamically.
4. Dismiss the keyboard.
5. Observe that the ScrollController does not trigger any events and the top header color doesn't change.

### Expected results

The ScrollController should trigger events when the keyboard is dismissed to reflect changes in the scroll position caused by layout adjustments.

### Actual results

The ScrollController does not trigger any events when the keyboard is dismissed, causing inconsistencies in offset-dependent behavior.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: ScrollColorChangePage(),
    );
  }
}

class ScrollColorChangePage extends StatefulWidget {
  const ScrollColorChangePage({super.key});

  @override
  ScrollColorChangePageState createState() => ScrollColorChangePageState();
}

class ScrollColorChangePageState extends State<ScrollColorChangePage> {
  final ScrollController _scrollController = ScrollController();
  Color _headerColor = Colors.blue;

  @override
  void initState() {
    super.initState();
    _scrollController.addListener(_onScroll);
  }

  @override
  void dispose() {
    _scrollController.removeListener(_onScroll);
    _scrollController.dispose();
    super.dispose();
  }

  void _onScroll() {
    final scrollOffset = _scrollController.offset;
    print(scrollOffset);
    setState(() {
      _headerColor = Color.lerp(Colors.blue, Colors.red, scrollOffset / 100) ?? Colors.blue;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        controller: _scrollController,
        slivers: [
          SliverToBoxAdapter(
            child: Container(
              height: 300,
              color: _headerColor,
            ),
          ),
          const SliverToBoxAdapter(
            child: Padding(
              padding: EdgeInsets.only(top: 300),
              child: TextField(
                decoration: InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Enter text here',
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/user-attachments/assets/941b0a9a-e5b8-4201-8610-4463de01043d



</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.0, on macOS 15.2 24C101 darwin-arm64, locale en-EG)
    • Flutter version 3.27.0 on channel stable at /Users/ahmedelsayed/.puro/envs/stable/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (12 days ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/ahmedelsayed/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • 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 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.96.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (4 available)
    • iPhone 16 Pro (mobile)          • DBB1EC9A-D253-49C3-BFC2-077B99FFDCC7 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.2 24C101
      darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.2 24C101
      darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.205

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>