Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setState() causes custom overflow to disappear with minimal example #171

Open
ProfessorX737 opened this issue Feb 1, 2025 · 1 comment

Comments

@ProfessorX737
Copy link

Before pressing rebuild button

Image

After pressing rebuild button a couple of times:

Image

Minimal example:

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

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

class MyApp extends StatefulWidget {
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Custom Overflow Example'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Padding(
                padding: const EdgeInsets.all(16.0),
                child: ExtendedText(
                  'This is a long text that will demonstrate the custom overflow feature of the extended_text package. '
                  'You can customize how the overflow is handled and what widget is displayed when the text overflows.',
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                  overflowWidget: TextOverflowWidget(
                    debugOverflowRectColor: Colors.red.withOpacity(0.1),
                    align: TextOverflowAlign.left,
                    child: const Row(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text('...'),
                        Icon(Icons.insert_drive_file_outlined,
                            size: 16), // Use the file icon
                      ],
                    ),
                  ),
                ),
              ),
              ElevatedButton(
                onPressed: () {
                  setState(() {});
                },
                child: Text('Rebuild'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
@zmtzawqlp
Copy link
Member

add a key for ExtendedText

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants