79360715

Date: 2025-01-16 07:42:55
Score: 1
Natty:
Report link

Follow the following steps:

  1. Create the folders called assets/images inside project but outside lib folder.
  2. Now Open pubspec.yaml and add:

enter image description here

(The indents must be precise)

  1. After updating pubspec.yaml close the app and RUN IT AGAIN.
  2. Now your code will work: (All possible ways)
Container(
  height: 200, //As per your requirement
  width: 200,//As per your requirement
  child: Image(
    image: AssetImage(
      'assets/images/profile.png',
    ),
    fit: BoxFit.cover,
  )
)
Container(
  height: 200, //As per your requirement
  width: 200,//As per your requirement
  decoration: BoxDecoration(
    image: DecorationImage(
      'assets/images/profile.png',
      fit: BoxFit.cover,
    )
  )
)
Container(
  height: 200, //As per your requirement
  width: 200,//As per your requirement
  child: Image.asset(
    'assets/images/profile.png',
    fit: BoxFit.cover,
  )
)
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Newb