The following assertion was thrown resolving an image codec: - flutter

ListView(
scrollDirection: Axis.vertical,
physics: ClampingScrollPhysics(),
shrinkWrap: true,
children: [Column(
children: [
Buttons(),
Text("Premium Exclusive"),
Column(
children: [
Row(
children: [
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/components/shop/shop_giftcard.png')
)
),
),
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/components/shop/shop_giftcard.png')
)
),
),
]
),
Row(
children: [
Container(
width: 100,
height: 200,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/components/shop/shop_giftcard.png')
)
),
),
Container(
width: 100,
height: 200,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/components/shop/shop_giftcard.png')
)
),
),
]
),
]
),
Hi, I'm flutter beginner.. When I put the image in container in listview, It doesn't apper and error like a picture below. I don't understand and how to resolve that in the error messages.. please give some advice and aprreciate that,,
---error---
Error while trying to load an asset: Failed to load asset at "assets/assets/images/components/shop/shop_giftcard.png" (404)
======== Exception caught by image resource service ================================================
Is it problem related with image file that I put in asset folder in not correctly?

make this change to all AssetImage widget. make sure pubspec.yaml spacing is correct.
First in your pubspec.yaml file
flutter:
uses-material-design: true
assets:
- assets/images/components/shop/
then in you code
AssetImage(
'assets/images/components/shop/shop_giftcard.png'
)

Related

Problem I have space in listview between items (Container) with flutter

Problem I have space in listview between items (Container) with flutter
Problem I have space in listview between items (Container) with flutter
this code :
return Scaffold(
body: Column(
children: [
Expanded(
child: ListView(
children: [
Container(
width: width,
height: 220,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/exclusion.png'),
// fit: BoxFit.contain,
),
),
),
Container(
width: width,
height: 220,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/exclusion.png'),
// fit: BoxFit.contain,
),
),
),
],
),
),
],
),
);
The height of the container you provided does not reflect the image height, so the image gets centered try to set fit: BoxFit.fill in the DecorationImage so that you see the actual height you need

unable to put stack inside slivers. flutter

My error is A RenderViewport expected a child of type RenderSliver but received a child of type RenderStack.
Scaffold(
body: CustomScrollView(
slivers: [
appbar(context),
Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://idsb.tmgrup.com.tr/ly/uploads/images/2020/05/13/35552.jpeg'))),
height: createSize(347, context),
width: createSize(375, context),
)
],
)
],
));
You have to use SliverToBoxAdapter widget to render any non sliver widget inside custom scroll view like this:
SliverToBoxAdapter(
child: Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://idsb.tmgrup.com.tr/ly/uploads/images/2020/05/13/35552.jpeg'))),
height: createSize(347, context),
width: createSize(375, context),
)
],
),
),

How to set asset images in container background image with flutter

I know how to set image file in container.
However when I try to set background of Container in ListView, the images can not shown up.
Of course, I wrote these image files in pubspec.yaml.
body: ListView(
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/IMG_01.JPG'),
fit: BoxFit.cover,
),
),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/IMG_02.JPG'),
fit: BoxFit.cover,
),
),
),
Give me advice.
Thank you.

My container's color property doesnt work and it doesnt give any error Flutter

I have a profile page layout as its seperated by 2 and 1 positioned for avatar picture. my down container color, ı cant set it seems not working ıdk why. here is my code below:
body: new Stack(
children: <Widget>[
new Column(
children: <Widget>[
new Container(
height: topWidgetHeight,
decoration: BoxDecoration(
image: new DecorationImage(image: new AssetImage("assets/9.jpg"),
fit: BoxFit.cover)
),
),
new Container(
color: Colors.red,
)
],
),
new Positioned(
child: new Container(
height: 150,
width: 150,
decoration: BoxDecoration(
image: new DecorationImage(image: new AssetImage("assets/0.jpg"),
fit: BoxFit.cover),
borderRadius: BorderRadius.all(Radius.circular(75.0)),
boxShadow: [
BoxShadow(blurRadius: 7.0, color: Colors.black)
],
),
),
left: (MediaQuery.of(context).size.width/2) - avatarRadius,
top: topWidgetHeight - avatarRadius,
)
],
)
the container is not appearing because you have not given any height and to container
please give it height and width and then try

Image glitch in Image.network or NetworkImage

Hi I'm loading my profile pics from my server in Image.network and showing it in a pageview to show next pictures. But when my image load from the internet it become a glitch as shown in the picture.
But when i open the same link in google chrome there is no glitch in my profile pic
This is the code is what i used to list
photos.forEach((photo) {
profileImages.add(
Container(
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Image(
image: NetworkImage(
APis().imageApi(
photo.photoName,
),
),
filterQuality: FilterQuality.low,
fit: BoxFit.cover,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
gradient: LinearGradient(colors: [
Colors.black12,
Colors.transparent,
Colors.black,
], stops: [
0.25,
0.75,
1.0
], begin: FractionalOffset.topCenter, end: FractionalOffset.bottomCenter)),
),
],
),
),
);
});
print("profileImages :${photos.length} ${profileImages.length}");
}
And this is what i displaying in pageview
PageView.builder(
controller: pageController,
onPageChanged: onPageChanged,
itemCount: profileImages.length,
itemBuilder: (context, position) {
return profileImages[position];
})
So my question is do i have to change anything or do i have to put placeholder?
The way I've handled it is by using a placeholder, so I use a Stack, i put the placeholder image underneath it and then once it loads, it just shows on top.
See the before and after:
And the code just pretty much looks like this:
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
Image.asset('assets/placeholder.jpg',
fit: BoxFit.cover,
width: 600.0,
height: 900.0
),
Image.network(imgPath,
fit: BoxFit.cover,
width: 600.0,
height: 900.0
)]))