Skip to content

Resolving Yellow Lines Under Text Widgets in Flutter

Flutter, UI Design, Widgets1 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.

Understanding the Issue

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.

Solutions to Resolve the Issue

1. Using the Material Widget

Wrapping your text widget with a Material widget is the simplest solution. This method ensures that your text is rendered correctly without the yellow underline.

2 child: Text('Your Text Here'),

2. Incorporating 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.

2 body: Text('Your Text Here'),

3. Customizing TextStyle

If you prefer not to alter the widget tree, you can directly modify the TextStyle of your text widget to remove the underline.

2 'Your Text Here',
3 style: TextStyle(decoration: TextDecoration.none),

4. Handling Hero Transitions

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.

2 tag: 'exampleTag',
3 child: Material(
4 child: Text('Your Text Here'),
5 ),