Skip to content

Instantly share code, notes, and snippets.

@daohoangson
Created August 23, 2021 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daohoangson/a69cf847dda053eab3c9d2cff2a0b65d to your computer and use it in GitHub Desktop.
Save daohoangson/a69cf847dda053eab3c9d2cff2a0b65d to your computer and use it in GitHub Desktop.
`Paragraph.getBoxesForPlaceholders` returns NaN when font size is zero. Reference: https://github.com/daohoangson/flutter_widget_from_html/issues/578
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
));
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final style = DefaultTextStyle.of(context).style;
return SingleChildScrollView(
child: RichText(
text: TextSpan(
children: [
const WidgetSpan(child: SizedBox(width: 10, height: 10)),
TextSpan(text: 'hover me', style: style),
],
style: style.copyWith(fontSize: 0.0),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment