I am creating a new page route PopupRoute
and using a Stack
as the root of the new popup page. It works fine until I add Text
to its children. Text will have two yellow lines underneath. I tried Material(child:Stack())
and Scaffold(child:Stack())
. It can fix the yellow line issue, but it covers the entire screen and make the barrierDismissible not work.
Are there any other widgets can solve the Text yellow issues in my case?
There might be a cleaner solution, but the first thing I thought of is wrapping Material
inside of Align
widget.
eg
showDialog(context: context, barrierDismissible: true, builder: (context) {
return Stack(alignment: Alignment.center, fit: StackFit.loose, children: <Widget>[
Container(width: 100, height: 100, color: Colors.blue),
Align(
child: Material(
type: MaterialType.transparency,
child: Text("TEXT"),
)
),
]);
});
You just need to wrap your Text
widget inside a DefaultTextStyle
widget. A DefaultTextStyle
widget gets added implicitly by the Scaffold
or Material
widget.
DefaultTextStyle(
style: TextStyle(),
child: Text("This is a test"),
),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.