我有3个具有不同屏幕尺寸的模拟器。我的应用程序中的TabBar小部件包含5个元素,其中包含64x64 png的png项目,并且每个屏幕尺寸都变得变形,因此我无法更改其尺寸。
static var tabBar = new TabBar(
tabs: [
Tab(
child: new Container(
width: 64.0,
height: 32.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/BottomBar1.png"),
// fit: BoxFit.fill,
),
),
),
),
Tab(
icon: new Container(
width: 64.0,
height: 64.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/BottomBar2.png"),
fit: BoxFit.fill),
),
),
),
Tab(
icon: new Container(
width: 64.0,
height: 64.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/BottomBar3.png"), fit: BoxFit.fill),
),
),
),
Tab(
icon: new Container(
width: 64.0,
height: 64.0,
alignment: Alignment.center,
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage(
"assets/BottomBar1.png",
),
fit: BoxFit.fill),
),
),
),
Tab(
child: Image.asset(
"assets/BottomBar1.png",
width: 64.0,
height: 64.0,
)),
],
// labelStyle: ,
labelColor: Colors.white,
unselectedLabelColor: Colors.white,
);
我也尝试使用此方法,但是无法干预元素的大小。
Image.asset('assets/BottomBar1.png',scale: 1,width: 32,height: 32,),
我尝试删除
fit: BoxFit.fill,