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

Text flickering #46

Open
n3o2k7i8ch5 opened this issue Jan 21, 2020 · 7 comments
Open

Text flickering #46

n3o2k7i8ch5 opened this issue Jan 21, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@n3o2k7i8ch5
Copy link

n3o2k7i8ch5 commented Jan 21, 2020

Steps to Reproduce
The bug is caused by the inability to set a text size, when two AutoSizeText with the same AutoSizeTextGroup with certain parameters (as in sample code) are horizontally next to each other. Depending on the screen size, this results in a sort of text size flickering (in reality this flickering is much much faster, but the GIF has a low FPS).

The sample code is an app, to reproduce the bug just run it.

As mentioned above, to reproduce the bug on a specific screen size, the text length of the longest line in one of the AutoSizeTexts may need to be changed.

Code sample

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  AutoSizeGroup group;

  @override
  void initState() {
    group = AutoSizeGroup();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Expanded(
                child: Card(
                    child: AutoSizeText(
                      'You have\npushed the\nbutton this\nmanyn times:aa',
                      group: group,
                      style: TextStyle(fontSize: 50),
                      maxLines: 4,
                    )
                )
            ),
            Card(
                child: AutoSizeText(
                    'Abd Abd\nAbd Abd\nAbd Abd\nAbd Abd',
                    group: group,
                  style: TextStyle(fontSize: 50),
                  maxLines: 4,
                )
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots
Peek 2020-01-22 00-06

Version

  • Flutter version: 1.12.13+hotfix.5
  • auto_size_text version: 2.1.0
@simc
Copy link
Owner

simc commented Sep 27, 2020

@n3o2k7i8ch5 Do you have an idea how to solve this?

@simc simc closed this as completed Sep 27, 2020
@simc simc reopened this Sep 27, 2020
@ManolloGuedes
Copy link

@leisim and @n3o2k7i8ch5 I'm having the same problem here.
Do you have an idea about what is causing it?

@n3o2k7i8ch5
Copy link
Author

n3o2k7i8ch5 commented Nov 24, 2020

If I'm not mistaken, the cause is the following:

  1. Text A realizes it has more free space and can expand.
  2. Text B, because it is in an AutoSizeGroup with text A, increases it's font size as well.
  3. But now, after text B increased, it took some space and A is too big for it's borders.
  4. So -> Text A decreases it's size.
  5. Text B also decreases it's size (since it's in an AutoSzieGroup).
  6. Now, both A and B decreased their sizes, and there is lots of free space -> We arrive at 1. again.

@g-balas
Copy link

g-balas commented Dec 30, 2020

Any workaround ?

@mpowloka
Copy link

Having a similar situation with [Image, SizedBox, AutoSizeText, SizedBox, AutoSizeText, SizedBox] in a horizontal, Instagram-like user profile.

In my situation, the only most-left text is flickering and only when Image is tapped or page is refreshed via RefreshIndicator. Really weird.

@mpowloka
Copy link

mpowloka commented Feb 17, 2021

Did anyone find a working workaround?

EDIT: for me, setting presetFontSizes did the job. My preferred fontSize is 14, my presetFontSizes are [11, 12, 13, 14] and the flickering no longer occurs.

@caiogranero
Copy link

Did anyone find a working workaround?

EDIT: for me, setting presetFontSizes did the job. My preferred fontSize is 14, my presetFontSizes are [11, 12, 13, 14] and the flickering no longer occurs.

Not yet =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants