flutter-packages icon indicating copy to clipboard operation
flutter-packages copied to clipboard

TextDecoration.lineThrough bug

Open pavel-birdy opened this issue 5 years ago • 6 comments

TextDecoration.lineThrough showing the line at the bottom of the text. It used to be (using assets font) at the center. I switched back to the assets font and it's working perfectly.

pavel-birdy avatar Dec 13 '19 13:12 pavel-birdy

Can you share a reproducible example? I tried with the following demo code, and it seems to work as expected for me.

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.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.light(),
      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> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Flutter Demo Home Page',
          style: GoogleFonts.biryani(fontWeight: FontWeight.w900, fontStyle: FontStyle.italic),
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
              style: GoogleFonts.tomorrow().copyWith(decoration: TextDecoration.lineThrough),
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Simulator Screen Shot - iPhone 11 Pro Max - 2019-12-13 at 11 33 22

johnsonmh avatar Dec 13 '19 16:12 johnsonmh

I am sorry I didn't try other fonts. I found this issue with the font I am using in my project. Not sure if the bug is font specific?

Text(
              'You have pushed the button this many times:',
              style: GoogleFonts.asap()
                  .copyWith(decoration: TextDecoration.lineThrough),
            ),


photo_2019-12-13_22-23-38

pavel-birdy avatar Dec 13 '19 16:12 pavel-birdy

Here using assets fonts. Which is normal.

photo_2019-12-13_22-34-45

pavel-birdy avatar Dec 13 '19 17:12 pavel-birdy

Ah ok, I was able to reproduce the bug as you defined it above. It's oddly specific. It only occurs for this font (as far as I've found), and it only occurs on android devices. And when you download the exact same ttf from this link: http://fonts.gstatic.com/s/asap/v11/KFOoCniXp96a-zwU4UROGzY.ttf, and put it in the pubspec, it works as expected. Something may be going weird with the FontLoader, I think we'll have to file a bug with the flutter framework to point out the odd behavior of the FontLoader with this particular font file.

johnsonmh avatar Dec 16 '19 17:12 johnsonmh

Any update?

pavel-birdy avatar Jan 06 '20 07:01 pavel-birdy

This seems to be a bug in the FontLoader. It only happens with this specific font, and only on Android, and only when used with the FontLoader.

I've filed https://github.com/flutter/flutter/issues/49239 to the flutter/flutter repo, hopefully this will get resolved there.

johnsonmh avatar Jan 21 '20 20:01 johnsonmh