Search code examples
flutterdartrenderemojiscaling

FittedBox with single emoji in text not showing up


My beloved 🦦 is not showing up. It used to though, with Flutter 3.0.0.

Now, using Flutter 3.3.6 Dart SDK 2.18.2, it does not.

Does anyone know if it's a bug? Or does anyone know a workaround for auto-scaling?

Minimal example:

class OtterFreakshow extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return 
      Column(children: [
        // works as expected with single letters
        Container(
      color: Colors.green,
      width:200, height: 200 ,child: const FittedBox(child: Text('A'))),
              
        // works as expected for emoji with surrounding letters
                Container(color: Colors.purple,
      width:200, height: 200 ,child: const FittedBox(child: Text('_🦦_'))),
        
        // not rendering correctly (invisible!) without some letters surrounding the otter
        Container(color: Colors.red,
      width:200, height: 200 ,child: const FittedBox(child: Text('🦦')))
      
      
      ]);
    }}

yields:

https://www.dropbox.com/s/n87grh6na3n2dfj/Screenshot%202022-11-01%20at%2019.42.29.png?dl=0

Interestingly, with surrounding blankspaces, the emoji also does not show up.


Solution

  • There is nothing wrong with it. Also I can clearly see the emoji when I run it in dartpad.

    enter image description here

    Still if you feel unsafe about it,

    Use auto_size_text plugin

    If you wanna automatically resize fonts based on parent widget's width and height, using auto_size_text package is the best option. It's really easy to use and has rich documentation.

    Sample Usage:

    AutoSizeText(
      'The text to display',
      style: TextStyle(fontSize: 20),
      maxLines: 2,
    )
    

    Have fun!