我想设置从相机获取图像并将其设置为以下代码:
image: DecorationImage(image: FileImage(file),
Run Code Online (Sandbox Code Playgroud)
所以我这样做了:
File file = await ImagePicker.pickImage(
source: ImageSource.camera,
);
Run Code Online (Sandbox Code Playgroud)
现在上面的代码现在可以正常工作,但不推荐使用 'pickImage',我们应该改用 imagePicker.getImage() 方法。
所以我用 imagePicker.getImage() 代替:
PickedFile file = await ImagePicker().getImage(
source: ImageSource.camera,
);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试将此文件设置为以下图像类型时,它不起作用
image: DecorationImage(image: FileImage(file),)
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
但是,终端仍然无法找到 keytool 或者命令不起作用?
在抽屉中,在列表视图中想要在单击 onTap 时更改 CustomListTile 的颜色并将所有其他子项的颜色设置为默认值?
class CustomListTile extends StatelessWidget {
final Color itemContainerColor;
const CustomListTile({
//deafult color is Colors.white
this.itemContainerColor= Colors.white,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: (){},
child: Container(
margin: EdgeInsets.symmetric(vertical: 4),
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 16),
width: 150,
decoration: BoxDecoration(
color: itemContainerColor,
)
child:
Text(
"ListTile 1",
style: TextStyle(
fontSize: 20,
color: Colors.green,
fontWeight: FontWeight.w600),
),
),
));
}
}
Run Code Online (Sandbox Code Playgroud) flutter flutter-layout flutter-animation flutter-container flutter-listview