— Flutter, UI Design, Widgets — 1 min read
Flutter developers often encounter a peculiar issue where yellow lines appear under text widgets. This article provides solutions to resolve this issue and ensure a clean, professional look for your Flutter applications.
The yellow lines under text widgets in Flutter are typically caused by missing material design widgets in the widget tree. Flutter's Material design requires specific widgets to render text properly.
Material
WidgetWrapping your text widget with a Material
widget is the simplest solution. This method ensures that your text is rendered correctly without the yellow underline.
1Material(2 child: Text('Your Text Here'),3)
Scaffold
The Scaffold
widget provides a high-level structure for implementing the material design layout. If your text widget is part of a page, consider wrapping the entire page with a Scaffold
.
1Scaffold(2 body: Text('Your Text Here'),3)
TextStyle
If you prefer not to alter the widget tree, you can directly modify the TextStyle
of your text widget to remove the underline.
1Text(2 'Your Text Here',3 style: TextStyle(decoration: TextDecoration.none),4)
When using Hero
animations, ensure that the child widget is wrapped in a Material
widget on both sides of the transition to prevent yellow lines during the animation.
1Hero(2 tag: 'exampleTag',3 child: Material(4 child: Text('Your Text Here'),5 ),6)