Skip to content

Text flickering #46

@n3o2k7i8ch5

Description

@n3o2k7i8ch5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions