Repository: flutter
Issue: Vertical linear gradient on TextStyle not rendering as gradient
Labels: engine,dependency: dart,a: typography,c: rendering,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-engine,triaged-engine

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill our the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->
I'm having trouble with vertical linear gradients on TextStyle. The behavior seems to be different between Flutter v1.12.13+hotfix.9 (tested hotfix.5 - hotfix.9) and v1.17.5 (tested 1.17.0 - 5), but in either version the gradients do not worked as expected.

## Steps to Reproduce

1. Starting with Flutter v1.12.13+hotfix.9, run `flutter create bug`.
2. Update the lib/main.dart with this code: 
```
import 'package:flutter/material.dart';
import 'dart:ui' as ui;

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TextStyle Gradient Bug',
      theme: ThemeData(),
      home: Scaffold(
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              // At fontSize 73, shows as solid red in v1.17 and v1.12 - no vertical gradient.
              Text(
                'dart:ui 73',
                style: TextStyle(
                    fontSize: 73,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = ui.Gradient.linear(Offset.zero, Offset(0, 73), [Colors.yellow, Colors.red])),
              ),
              // Only difference between this style and the one of above is the fontSize, but it shows as solid
              // yellow in v1.17 and solid red in v1.12 - no vertical gradient.
              Text(
                'dart:ui 74',
                style: TextStyle(
                    fontSize: 74,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = ui.Gradient.linear(Offset.zero, Offset(0, 73), [Colors.yellow, Colors.red])),
              ),
              // This one changes the gradient 'to' to negative and we get the desired vertical gradient in v1.17,
              // but only yellow in v1.12
              Text(
                'dart:ui -73',
                style: TextStyle(
                    fontSize: 74,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = ui.Gradient.linear(Offset.zero, Offset(0, -73), [Colors.yellow, Colors.red])),
              ),
              // This one changes the gradient 'to' to negative and we get the desired vertical gradient in 1.17,
              // but only yellow in v1.12
              Text(
                'dart:ui -74',
                style: TextStyle(
                    fontSize: 74,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = ui.Gradient.linear(Offset.zero, Offset(0, -73), [Colors.yellow, Colors.red])),
              ),
              // A diagonal gradient works, unlike a vertical gradient
              Text(
                'dart:ui d74',
                style: TextStyle(
                    fontSize: 74,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = ui.Gradient.linear(Offset(0, 73), Offset(411, 0), [Colors.yellow, Colors.red])),
              ),
              // Same diagonal gradient created with Flutter's LinearGradient
              Text(
                'Flutter d74',
                style: TextStyle(
                    fontSize: 74,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = LinearGradient(
                          begin: Alignment.bottomLeft,
                          end: Alignment.topRight,
                          colors: [Colors.yellow, Colors.red]).createShader(Rect.fromLTWH(0, 0, 411, 73))),
              ),
              // Vertical gradient fails - just yellow on v1.12, and solid red on v1.17
              Text(
                'Flutter v74',
                style: TextStyle(
                    fontSize: 74,
                    fontStyle: FontStyle.normal,
                    fontWeight: FontWeight.bold,
                    foreground: Paint()
                      ..shader = LinearGradient(
                          begin: Alignment.bottomCenter,
                          end: Alignment.topCenter,
                          colors: [Colors.yellow, Colors.red]).createShader(Rect.fromLTWH(0, 0, 411, 73))),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
```

3. Run the app on Android using an Android 9 API 28 emulator on Ubuntu Linux and take a screenshot.
4. Change your Flutter SDK version to v1.17.5 and rebuild/re-run on the same emulator and take a screenshot.
5. Run again on a physical Pixel 3 XL running Android 10. 

**Expected results:**
1. Expected vertical linear gradients running from yellow on top to red on the bottom for the text "dart:ui 73" and "dart:ui 74". 
2. Expected vertical linear gradients running from red on top to yellow on the bottom for the text "dart:ui -73" and "dart:ui -74".
3. Expected diagonal linear gradients running bottom left to top right from yellow to red for "dart:ui d74" and "Flutter d74".
4. Expected vertical linear gradient running from bottom to top, yellow to red for "Flutter v74".

**Actual results:**

For Flutter v1.12.13+hotfix.9 on the emulator, I see:

<img src="https://user-images.githubusercontent.com/1719665/87258816-26853e80-c46c-11ea-8a36-f422037cc6a9.png" width ="300"> 

- "dart:ui 73" and "dart:ui 74" are solid red
- "dart:ui -73" and "dart:ui -74" are solid yellow
- "dart:ui d74" and "Flutter d74" seem to have horizontal  (maybe diagonal?) gradients running left to right.
- "Flutter v74" is solid yellow

For Flutter v1.17.5 on the emulator, I see different results (a little better, but still not correct):

<img src="https://user-images.githubusercontent.com/1719665/87259149-c5129f00-c46e-11ea-95ae-0e17061cef60.png" width ="300"> 

- "dart:ui 73" is solid red
- `*` "dart:ui 74" is solid yellow - the only difference between this and "dart:ui 73" is the fontSize.
- `*` "dart:ui -73" and "dart:ui -74" work as expected. The only difference between these and the previous two are that the y offset is negative.
- "dart:ui d74" and "Flutter d74" seem to have horizontal  (maybe diagonal?) gradients running left to right.
- `*` "Flutter v74" is solid red 

The items marked `*` above differ from the v1.12.13 results.

Finally for the physical Pixel 3 XL scenario running the Flutter v1.17.5 version, appears to look like v1.12.13 results:

<img src="https://user-images.githubusercontent.com/1719665/87259264-9ea13380-c46f-11ea-9ba5-1afc9bfd6d07.png" width ="300"> 

<details>
<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
flutter analyze
Analyzing gradient_bug_demo_1_12...                                         
No issues found! (ran in 5.0s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

Flutter doctor with Flutter v1.12.13:
```
✓] Flutter (Channel unknown, v1.12.13+hotfix.9, on Linux, locale en_US.UTF-8)
    • Flutter version 1.12.13+hotfix.9 at /home/dsyrstad/Flutter/flutter
    • Framework revision f139b11009 (3 months ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /home/dsyrstad/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0
    • ANDROID_SDK_ROOT = /home/dsyrstad/Android/Sdk
    • Java binary at: /home/dsyrstad/AndroidStudio/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Android Studio (version 3.5)
    • Android Studio at /home/dsyrstad/AndroidStudio/android-studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at /home/dsyrstad/IntelliJ/idea-latest
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.6911.31

[✓] IntelliJ IDEA Ultimate Edition (version 2019.1)
    • IntelliJ at /home/dsyrstad/IntelliJ/idea-IU-181.4668.68
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423

[✓] Connected device (2 available)
    • Pixel 3 XL          • 192.168.86.28:5555 • android-arm64 • Android 10 (API 29)
    • AOSP on IA Emulator • emulator-5554      • android-x86   • Android 9 (API 28) (emulator)

• No issues found!
```
Flutter doctor with Flutter v1.17.5:
```
[✓] Flutter (Channel stable, v1.17.5, on Linux, locale en_US.UTF-8)
    • Flutter version 1.17.5 at /home/dsyrstad/Flutter/flutter
    • Framework revision 8af6b2f038 (12 days ago), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /home/dsyrstad/Android/Sdk
    • Platform android-29, build-tools 29.0.0
    • ANDROID_SDK_ROOT = /home/dsyrstad/Android/Sdk
    • Java binary at: /home/dsyrstad/AndroidStudio/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Android Studio (version 3.5)
    • Android Studio at /home/dsyrstad/AndroidStudio/android-studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at /home/dsyrstad/IntelliJ/idea-latest
    • Flutter plugin version 45.1.2
    • Dart plugin version 193.6911.31

[✓] IntelliJ IDEA Ultimate Edition (version 2019.1)
    • IntelliJ at /home/dsyrstad/IntelliJ/idea-IU-181.4668.68
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423

[✓] Connected device (2 available)
    • Pixel 3 XL          • 192.168.86.28:5555 • android-arm64 • Android 10 (API 29)
    • AOSP on IA Emulator • emulator-5554      • android-x86   • Android 9 (API 28) (emulator)

• No issues found!
```
</details>