Skip to content

[Impeller] Text foreground Paint()..shader doesn't render inside scroll view #127103

@junaid1460

Description

@junaid1460

Is there an existing issue for this?

Steps to reproduce

  1. clone this repo https://github.com/junaid1460/flutter_impeller_gradient_shader_bug_example
  2. run without and with --no-enable-impeller

Expected results

Should render text with gradient paint

Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-05-18.at.17.16.28.mp4

Actual results

Rendering with no color at all

Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-05-18.at.17.11.32.mp4

The issue was earlier reported here #120003 but the fix looks like partial

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}
class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var _showRichText = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _showRichText ? SafeArea(child: _richText()) : _scrollView(),
      floatingActionButton: FloatingActionButton(
        onPressed: () => setState(() {
          _showRichText = !_showRichText;
        }),
        child: const Icon(Icons.swap_horiz_rounded),
      ),
    );
  }

  Widget _scrollView() => CustomScrollView(
        physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
        slivers: [
          const SliverAppBar(
            title: Text('Scroll View'),
          ),
          SliverToBoxAdapter(
              child: SingleChildScrollView(
            child: Row(
              children: [
                _richText(),
              ],
            ),
          )),
        ],
      );

  Widget _richText() => RichText(
        text: TextSpan(
          children: [
            const TextSpan(
              text: 'Hello, ',
            ),
            TextSpan(
              text: 'John',
              style: TextStyle(
                  fontWeight: FontWeight.bold,
                  foreground: Paint()
                    ..shader = const LinearGradient(
                      colors: [
                        Colors.red,
                        Colors.blue,
                      ],
                    ).createShader(
                        const Rect.fromLTWH(0.0, 0.0, 500.0, 800.0))),
            ),
          ],
          style: const TextStyle(
            fontSize: 44,
            color: Colors.black,
          ),
        ),
      );
}

Screenshots or Video

Expected (skia)
Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-05-18.at.17.16.28.mp4
Vs Impeller
Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2023-05-18.at.17.11.32.mp4

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.1 22C65 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Community Edition (version 2022.2.1)
[✓] VS Code (version 1.78.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work liste: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions