Repository: flutter
Issue: CurvedAnimation does not update state of _curveDirection correctly
Labels: framework,a: animation,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-framework,triaged-framework

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

When `CurvedAnimation` plays animation through `AnimationController#repeat(reverse: true)`, `_curveDirection` is not updated correctly inside `CurvedAnimation`, so `_useForwardCurve` is always true, and the incoming `reverseCurve` cannot be used.

https://github.com/flutter/flutter/blob/cd97b4391a0d02ed2272a4adae48e9139fc66e80/packages/flutter/lib/src/animation/animations.dart#L386-L387

https://github.com/flutter/flutter/blob/cd97b4391a0d02ed2272a4adae48e9139fc66e80/packages/flutter/lib/src/animation/animations.dart#L422-L432

### Expected results

![2023-06-29 23 37 45](https://github.com/flutter/flutter/assets/6304197/caec9714-a5bd-4a14-8049-ac06b4072cce)


### Actual results

![2023-06-29 23 45 15](https://github.com/flutter/flutter/assets/6304197/d90a64bb-d72f-489a-9450-8d041c3769fd)


### Code sample

<details><summary>Code sample</summary>

```dart

class Demo extends StatefulWidget {
  const Demo({super.key});

  @override
  State<Demo> createState() => _DemoState();
}

class _DemoState extends State<Demo> with TickerProviderStateMixin {
  late final AnimationController _controller;
  late final Animation<Alignment> _curve;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      vsync: this,
      duration: const Duration(seconds: 3),
    );
    _curve = AlignmentTween(
      begin: Alignment.centerLeft,
      end: Alignment.centerRight,
    ).animate(
      CurvedAnimation(
        parent: _controller,
        curve: Curves.easeOutCirc,
        reverseCurve: Curves.easeInCirc,
      ),
    );
    _controller.repeat(reverse: true);
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        AlignTransition(
          alignment: _curve,
          child: Container(
            width: 50,
            height: 50,
            color: Colors.blue,
          ),
        ),
      ],
    );
  }
}

```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.7.9, on macOS 12.6.2 21G320 darwin-x64, locale
    zh-Hans-CN)
    • Flutter version 3.7.9 on channel stable at /Users/fingerart/.flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 62bd79521d (3 months ago), 2023-03-30 10:59:36 -0700
    • Engine revision ec975089ac
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
    • Android SDK at /Users/fingerart/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.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
      17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Community Edition (version 2022.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 223.8888

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.6.2 21G320 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.198

[✓] HTTP Host Availability
    • All required HTTP hosts are available
```

</details>