fluttercandies / extended_text

A powerful extended official text for Flutter, which supports Speical Text(Image,@somebody), Custom Background, Custom overFlow, Text Selection.
MIT License
664 stars 134 forks source link

[Bug report] Flutter 3.10 onTap not triggered inside TextOverflowWidget #147

Closed farmerswalker closed 1 year ago

farmerswalker commented 1 year ago

Version

11.0.0

Platforms

Android, iOS

Device Model

iPhone 14

flutter info

[✓] Flutter (Channel stable, 3.10.1, on macOS 13.3 22E252 darwin-arm64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.78.2)
[✓] Connected device (5 available)
[✓] Network resources

How to reproduce?

From Flutter 3.10, I'm experiencing an issue where the onTap event of GestureDetector is not being triggered when it's placed inside a TextOverflowWidget. Here is a simplified code snippet:

Logs

No response

Example code (optional)

ExtendedText.rich(
  text,
  overflowWidget: TextOverflowWidget(
    child: GestureDetector(
      onTap: () {
        print('Tap event not triggered');
      },
      child: Text('Read more'),
    ),
  ),
)

Contact

No response

zmtzawqlp commented 1 year ago

can't reproduce at my side

ZhouC125 commented 1 year ago

I've also encountered this situation version: flutter 3.10.0 extended_text: ^11.0.0 platform: Simulator iPhone 14 Pro Max

zmtzawqlp commented 1 year ago

https://github.com/fluttercandies/extended_text/assets/16477333/bb1c0df1-702b-4b5a-b15b-f05aeafeb881

zmtzawqlp commented 1 year ago

i need a simple runnable demo to reproduce it.

ZhouC125 commented 1 year ago

It appears that wrapping with ScrollView enables the onTap to succeed.


import 'package:extended_text/extended_text.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: CustomTextOverflowDemo(),
    );
  }
}

class CustomTextOverflowDemo extends StatefulWidget {
  @override
  _CustomTextOverflowDemoState createState() => _CustomTextOverflowDemoState();
}
class _CustomTextOverflowDemoState extends State<CustomTextOverflowDemo> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('test'),
      ),
      body: Column(
        children: [
          Card(
            child: _buildExtendedText(),
          ),
          Card(
            child: SingleChildScrollView(
              child: _buildExtendedText(),
            ),
          ),
        ],
      ),

    );
  }

  ExtendedText _buildExtendedText() {
    return ExtendedText.rich(
                TextSpan(children: <TextSpan>[
                  BackgroundTextSpan(
                    text: 'paint background end of line 错误演示12345'*3,
                    style: const TextStyle(color: Colors.red),
                    background: Paint()..color = Colors.red.withOpacity(0.1),
                  ),
                ]),
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
                overflowWidget: TextOverflowWidget(
                  maxHeight: 30,
                  child: InkWell(
                    onTap: () {
                      print('more');
                    },
                    child: const Text(
                        ' more',
                        style:  TextStyle(
                          color: Colors.blue,
                          decoration: TextDecoration.underline,
                        )
                    ),
                  ),
                ),
              );
  }

}
zmtzawqlp commented 1 year ago

11.0.1 is ready, reopen if still has problem