扑动问题:如何制作圆形的国家形象?
flutter problem : How to make country image in circular?
我想做一个圆形的旗帜。我正在使用“country_calling_code_picker: ^2.0.0”插件,我得到了一张我想要的圆形图像。当我尝试制作圆形时,它不会成为。
这是我的代码。
Row(
children: [
Expanded(
flex: 0,
child: Container(
decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
border: Border(
bottom: BorderSide(
color:greyColor,
width: 1.7,
),
)
),
child: InkWell(onTap: (){
_onPressedShowBottomSheet();
},
child: Row(
children: [
Image.asset(
country.flag,
package: countryCodePackageName,
width: 40,
height: 50,
),SizedBox(width: 5,),
Icon(Icons.arrow_drop_down_sharp,size: 30,color: greyColor,)
],
),
),
),
),
SizedBox(
width: 15,
),
Expanded(
flex: 3,
child: Container( decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
),
child: TextFormField(
cursorColor: Theme.of(context).cursorColor,
decoration: const InputDecoration(
hintText: "Enter Number",
enabledBorder: UnderlineInputBorder(
borderSide:
BorderSide(color:greyColor,width: 1.7),
), contentPadding: EdgeInsets.only(left: 12,right: 12),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: greyColor,width: 1.7),
),
),
),
),
),
],
),
我想做这样的旗帜
但是现在变成这样了
您可以将图像包裹在 ClipRRect
中。
Row(
children: [
Expanded(
flex: 0,
child: Container(
decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
border: Border(
bottom: BorderSide(
color: greyColor,
width: 1.7,
),
)
),
child: InkWell(onTap: () {
_onPressedShowBottomSheet();
},
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(100),
Image.asset(
country.flag,
package: countryCodePackageName,
width: 40,
height: 50,
),
),
SizedBox(width: 5,),
Icon(Icons.arrow_drop_down_sharp, size: 30,
color: greyColor,)
],
),
),
),
),
SizedBox(
width: 15,
),
Expanded(
flex: 3,
child: Container(decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
),
child: TextFormField(
cursorColor: Theme
.of(context)
.cursorColor,
decoration: const InputDecoration(
hintText: "Enter Number",
enabledBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: greyColor, width: 1.7),
), contentPadding: EdgeInsets.only(left: 12, right: 12),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: greyColor, width: 1.7),
),
),
),
),
),
],
),
我想做一个圆形的旗帜。我正在使用“country_calling_code_picker: ^2.0.0”插件,我得到了一张我想要的圆形图像。当我尝试制作圆形时,它不会成为。
这是我的代码。
Row(
children: [
Expanded(
flex: 0,
child: Container(
decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
border: Border(
bottom: BorderSide(
color:greyColor,
width: 1.7,
),
)
),
child: InkWell(onTap: (){
_onPressedShowBottomSheet();
},
child: Row(
children: [
Image.asset(
country.flag,
package: countryCodePackageName,
width: 40,
height: 50,
),SizedBox(width: 5,),
Icon(Icons.arrow_drop_down_sharp,size: 30,color: greyColor,)
],
),
),
),
),
SizedBox(
width: 15,
),
Expanded(
flex: 3,
child: Container( decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
),
child: TextFormField(
cursorColor: Theme.of(context).cursorColor,
decoration: const InputDecoration(
hintText: "Enter Number",
enabledBorder: UnderlineInputBorder(
borderSide:
BorderSide(color:greyColor,width: 1.7),
), contentPadding: EdgeInsets.only(left: 12,right: 12),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: greyColor,width: 1.7),
),
),
),
),
),
],
),
我想做这样的旗帜
但是现在变成这样了
您可以将图像包裹在 ClipRRect
中。
Row(
children: [
Expanded(
flex: 0,
child: Container(
decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
border: Border(
bottom: BorderSide(
color: greyColor,
width: 1.7,
),
)
),
child: InkWell(onTap: () {
_onPressedShowBottomSheet();
},
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(100),
Image.asset(
country.flag,
package: countryCodePackageName,
width: 40,
height: 50,
),
),
SizedBox(width: 5,),
Icon(Icons.arrow_drop_down_sharp, size: 30,
color: greyColor,)
],
),
),
),
),
SizedBox(
width: 15,
),
Expanded(
flex: 3,
child: Container(decoration: BoxDecoration(
color: whiteColor.withOpacity(0.4),
),
child: TextFormField(
cursorColor: Theme
.of(context)
.cursorColor,
decoration: const InputDecoration(
hintText: "Enter Number",
enabledBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: greyColor, width: 1.7),
), contentPadding: EdgeInsets.only(left: 12, right: 12),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: greyColor, width: 1.7),
),
),
),
),
),
],
),