我希望我的容器还剩一点位置。我尝试使用填充,但无法正常工作。下面是我的代码容器(颜色:蓝色,
//padding: EdgeInsets.all(10),
child: Row(
children: <Widget>[
Padding(
child: new Text(
'BIKE DETAILS',
style: new TextStyle(
fontWeight: FontWeight.bold, fontSize: 20.0),
textAlign: TextAlign.left,
),
padding: EdgeInsets.only(bottom: 20.0),),
SizedBox(width: 20),
),
),
],
以下代码将蓝色容器向左移动。如果您想向右移动文本,请像以前一样用Padding
小部件包裹文本。或将文本包装在container
中,然后使用EdgeInsets根据需要提供特定的填充。
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('text'),
),
body: Container(
color: Colors.blue,
height: 50, //change to your desired height.
width:
MediaQuery.of(context).size.width, //change to your desired width.
/// Below in the margin parameter EdgeInsets.fromLTRB will help you give specific
/// margins from Left, Top, Right and Bottom respectively.
margin: EdgeInsets.fromLTRB(5, 20, 5, 20),
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'BIKE DETAILS',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
textAlign: TextAlign.left,
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'BIKE DETAILS',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
textAlign: TextAlign.left,
),
),
],
),
),
);
}
}
希望这会有所帮助!