Repository: flutter
Issue: LinearGradient inside SliverPersistentHeader renders visible difference on Linux platforms
Labels: framework,f: material design,platform-linux,c: rendering,has reproducible steps,found in release: 2.5,team-design,triaged-design

We're running our golden test in CI and locally (on Macs) in Linux containers, to have pixel-perfect matches across both systems.

This has worked well so far, but with developers on the M1 Macs we see differences in certain gradient situations which are then failing the CI checks. In my eyes these are also visually perceptible, which is more of a difference than I would expect.


## Steps to Reproduce

1. Check out https://github.com/tp/flutter_gradient_test_mac on both an Intel as well as an M1 Mac
2. Run the 2 Docker commands from the README to run the golden test on each platform

The committed result of the above actions is here (diff from M1 to Intel Mac):
https://github.com/tp/flutter_gradient_test_mac/commit/3709bd04f2d98d1d59647100ad1d7bdd35a3224c#diff-811270a4b065003fb3fe562d438e64c8fe6ff61019a513de44223247f6f98fcf


**Expected results:** <!-- what did you want to see? -->

Renderings on the same platform should be the same, regardless of CPU architecture.

I ran the test case above both natively on the Intel and M1 Macs, and there the images match up perfectly. Only using Docker I see the difference (I don't have native Linux machines to verify this on).

**Actual results:** <!-- what did you see? -->

<img width="867" alt="image" src="https://user-images.githubusercontent.com/52437/140822491-e703cf0f-4038-4f53-8d53-58c2dd68fe21.png">


<details>
<summary>Code sample</summary>

This was the minimal code sample with which I could reproduce the issue.

Just having the gradients by themselves at similar sizes doesn't show the error. Only when they are inside the `SliverPersistentHeader` (or perhaps some other widgets with similar behavior) I get the difference across platforms.

We also have this same issue in a button with gradient background, but I didn't extract that yet to a standalone case (but can do if it would be helpful; it'll just have more indirection due to Material's theme).

```dart
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    await tester.pumpWidget(
      MaterialApp(
        home: Scaffold(
          body: CustomScrollView(
            slivers: [
              SliverPersistentHeader(
                pinned: true,
                delegate: AppBarSliverPersistentHeaderDelegate(
                  builder: (_) {
                    return Stack(
                      children: [
                        Positioned.fill(
                          child: Container(
                            decoration: const BoxDecoration(
                              gradient: LinearGradient(
                                begin: Alignment.topRight,
                                end: Alignment.bottomLeft,
                                colors: [
                                  Color.fromRGBO(255, 221, 0, 1),
                                  Color.fromRGBO(246, 178, 34, 1),
                                ],
                              ),
                            ),
                          ),
                        ),
                      ],
                    );
                  },
                  maxHeight: 250,
                  minHeight: 65,
                ),
              ),
            ],
          ),
        ),
      ),
    );

    expect(find.byType(Scaffold), matchesGoldenFile("gradient_${Platform.operatingSystem}.png"));
  });
}

class AppBarSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
  AppBarSliverPersistentHeaderDelegate({
    required this.builder,
    required this.maxHeight,
    required this.minHeight,
  });

  final WidgetBuilder builder;
  final double maxHeight;
  final double minHeight;

  @override
  Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
    return builder(context);
  }

  @override
  double get maxExtent => maxHeight;

  @override
  double get minExtent => minHeight;

  @override
  bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
    return true;
  }
}
```

</details>