Repository: flutter
Issue: AlignmentGeometryTween should extend Tween<AlignmentGeometry> (not nullable) instead of Tween<AlignmentGeometry?> (nullable)
Labels: framework,a: animation,f: material design,has reproducible steps,a: null-safety,P2,found in release: 2.3,team-design,triaged-design

The class `AlignmentGeometryTween`  extends from `Tween<AlignmentGeometry?>`, this means that when creating an animation out of it, the animation will be an `Animation<AlignmentGeometry?>`. (note how AlignmentGeometry can be null)

https://github.com/flutter/flutter/blob/e7b7ebc066c1b2a5aa5c19f8961307427e0142a6/packages/flutter/lib/src/rendering/tweens.dart#L65

The problem is that classes like `AlignTransition` only accept `Animation<AlignmentGeometry>` (note the lack of nullable values) making it impossible to use.

A `Tween` with a null output can only happen if both begin and end values are null, as we can see in the `lerp` implementation of `AlignmentGeometry`: 

https://github.com/flutter/flutter/blob/e7b7ebc066c1b2a5aa5c19f8961307427e0142a6/packages/flutter/lib/src/painting/alignment.dart#L93

IMO if a `Tween` is outputting a null value that's a mistake on the developer side for providing two null values.

For example, `AlignmentTween` is not nullable: https://github.com/flutter/flutter/blob/e7b7ebc066c1b2a5aa5c19f8961307427e0142a6/packages/flutter/lib/src/rendering/tweens.dart#L42 and the solution is simple, add a `!` in the `lerp` call: https://github.com/flutter/flutter/blob/e7b7ebc066c1b2a5aa5c19f8961307427e0142a6/packages/flutter/lib/src/rendering/tweens.dart#L52

This was not an issue before null safety, but with null safety the existing code does not compile anymore. To fix this on my project I created a custom Tween that cannot be nullable.

## Steps to Reproduce

1. Create new Flutter project
2. Bump SDK version to 2.12.0
3. Copy the following code using `AlignmentGeometryTween` and `AlignTransition`:

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  late AnimationController _controller;
  late Animation<AlignmentGeometry?> _animation;

  @override
  void initState() {
    super.initState();

    _controller = AnimationController(
      duration: const Duration(milliseconds: 600),
      vsync: this,
    )..addStatusListener((status) {
        if (status == AnimationStatus.completed) {
          _controller.reverse();
        } else if (status == AnimationStatus.dismissed) {
          _controller.forward();
        }
      });

    _animation = AlignmentGeometryTween(
      begin: Alignment.topCenter,
      end: Alignment.bottomCenter,
    ).animate(CurvedAnimation(
      parent: _controller,
      curve: const Interval(
        0.0,
        1.0,
        curve: Curves.easeInOut,
      ),
    ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AlignTransition(
        alignment: _animation,
        child: Container(
          color: Colors.red,
          width: 20,
          height: 20,
        ),
      ),
    );
  }
}
```

**Expected results:**

No compilation errors.

**Actual results:** 

Compilation errors:

```
ERROR: lib/main.dart:60:20: Error: The argument type 'Animation<AlignmentGeometry?>' can't be assigned to the parameter type 'Animation<AlignmentGeometry>' because 'AlignmentGeometry?' is nullable and 'AlignmentGeometry' isn't.
ERROR:  - 'Animation' is from 'package:flutter/src/animation/animation.dart' ('../../dev/tools/flutter/packages/flutter/lib/src/animation/animation.dart').
ERROR:  - 'AlignmentGeometry' is from 'package:flutter/src/painting/alignment.dart' ('../../dev/tools/flutter/packages/flutter/lib/src/painting/alignment.dart').
ERROR:         alignment: _animation,
ERROR:                    ^
Exception: Build process failed
```

If I change `late Animation<AlignmentGeometry?> _animation;` to `late Animation<AlignmentGeometry> _animation;`:

```
ERROR: lib/main.dart:46:7: Error: A value of type 'Animation<AlignmentGeometry?>' can't be assigned to a variable of type 'Animation<AlignmentGeometry>' because 'AlignmentGeometry?' is nullable and 'AlignmentGeometry' isn't.
ERROR:  - 'Animation' is from 'package:flutter/src/animation/animation.dart' ('../../dev/tools/flutter/packages/flutter/lib/src/animation/animation.dart').
ERROR:  - 'AlignmentGeometry' is from 'package:flutter/src/painting/alignment.dart' ('../../dev/tools/flutter/packages/flutter/lib/src/painting/alignment.dart').
ERROR:     ).animate(CurvedAnimation(
ERROR:       ^
Exception: Build process failed
```

<details>

```
analyzing alignment_geometry_tween...                                   

  error • The argument type 'Animation<AlignmentGeometry?>' can't be assigned to the parameter type 'Animation<AlignmentGeometry>' • lib/main.dart:60:9 • argument_type_not_assignable

1 issue found. (ran in 0.7s)

```

```
flutter doctor -v
[✓] Flutter (Channel stable, 2.0.5, on Linux, locale en_US.UTF-8)
    • Flutter version 2.0.5 at /home/miquel/dev/tools/flutter
    • Framework revision adc687823a (4 weeks ago), 2021-04-16 09:40:20 -0700
    • Engine revision b09f014e96
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/miquel/Android/Sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10)
    • 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 (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3)
    • IntelliJ at /home/miquel/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/203.6682.168
    • Flutter plugin version 55.1.3
    • Dart plugin version 203.8173

[✓] VS Code (version 1.56.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.22.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Linux
    • Chrome (web)    • chrome • web-javascript • Google Chrome 90.0.4430.93

! Doctor found issues in 1 category.
```
</details>