admin管理员组文章数量:1125070
I am following a tutorial from youtube and not able to position image as shown in the image below.
I want to achieve this
My current state is shown here My current state
Widget build(BuildContext context) {
return Column(
children: [
GestureDetector(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Food text
Text(food.name),
Text(
'\$' + food.price.toString(),
style: TextStyle(
color: Theme.of(context).colorScheme.primary),
),
const SizedBox(
height: 10,
),
Text(
food.description,
style: TextStyle(
color: Theme.of(context).colorScheme.inversePrimary),
),
],
)),
// const SizedBox(
// width: 15,
// ),
// Food image
Image.asset(
food.imagePath,
height: 120,
width: 120,
),
],
),
),
),
What am I missing here?
I am following a tutorial from youtube and not able to position image as shown in the image below.
I want to achieve this
My current state is shown here My current state
Widget build(BuildContext context) {
return Column(
children: [
GestureDetector(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Food text
Text(food.name),
Text(
'\$' + food.price.toString(),
style: TextStyle(
color: Theme.of(context).colorScheme.primary),
),
const SizedBox(
height: 10,
),
Text(
food.description,
style: TextStyle(
color: Theme.of(context).colorScheme.inversePrimary),
),
],
)),
// const SizedBox(
// width: 15,
// ),
// Food image
Image.asset(
food.imagePath,
height: 120,
width: 120,
),
],
),
),
),
What am I missing here?
Share Improve this question asked 2 days ago Sahil NagSahil Nag 11 bronze badge2 Answers
Reset to default 0To make sure your image scales properly and has smooth, polished edges when you add rounded corners, you can use the ClipRRect widget in Flutter. By setting the clipBehavior property to Clip.antiAlias, you’ll get smoother edges, which makes the overall look more refined.
Here’s an example of how you can do this:
ClipRRect(
borderRadius: BorderRadius.circular(15.0), // Adds rounded corners
clipBehavior: Clip.antiAlias, // Ensures smooth edges
child: Image.asset(
'assets/images/sample.jpg',
height: 120, // Sets the image height
width: 120, // Sets the image width
fit: BoxFit.cover, // Ensures the image scales correctly
),
),
Try
Image.asset(
food.imagePath,
height: 120,
width: 120,
fit: BoxFit.cover,
),
本文标签: How to position image accurately in flutterStack Overflow
版权声明:本文标题:How to position image accurately in flutter - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736652594a1946176.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论