flutter-packages
flutter-packages copied to clipboard
TextDecoration.lineThrough bug
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.
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),
),
);
}
}
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),
),
Here using assets fonts. Which is normal.
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.
Any update?
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.