Ben*_*sal 1 containers colors dart flutter
这backGround color取决于red设备的电池电量。我希望它是动态的。
我这样尝试过:
return Container(
child: Row(
children: [
Expanded(flex: 100-battery,child: SizedBox()),
Expanded(flex: battery,child: Container(child: Text(battery.toString()+'%', style: TextStyle(fontSize: 10,),),color: Colors.green)),
],
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5), border: Border.all(color: Colors.white)),
);
Run Code Online (Sandbox Code Playgroud)
看起来不错,问题是与Text一侧对齐。我希望它在一侧。所以我必须指定两个background color来解决这个问题。任何想法?
我做得更好:
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,//Starting point
end: Alignment.centerRight,//Ending point
stops: [0.5, 0], //First Part is the amount of space the first color has
//occupy and the second parameter is the space that is to be occupied by
//mixture of both colors.
colors: [Colors.green, Colors.amber], // List of colors
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2592 次 |
| 最近记录: |