How to assign asset image to Fancy Shimmer image flutter - flutter

help me out I am using fancy Shimmer Image flutter dev package, but it only accept network images! I want to assign asset image how can I achieve that?
FancyShimmerImage(
boxFit: BoxFit.contain,
imageUrl:'Network image goes here ',
errorWidget: Image.network('Network image goes here '),
shimmerBaseColor: Colors.greenAccent,
shimmerHighlightColor: Colors.grey,
shimmerBackColor: Colors.greenAccent,
),

You put like this
FancyShimmerImage(
boxFit: BoxFit.contain,
imageUrl:'',
errorWidget: Image.asset('images/lake.jpg',width: 600.0, height: 240.0, fit:
shimmerBaseColor: Colors.greenAccent,
shimmerHighlightColor: Colors.grey,
shimmerBackColor: Colors.greenAccent,
),

Related

How can I show an asset Image while NetworkImage is loading

I am not able to show a circular loading indicator or an image while flutter is loading the image from the network.
image: DecorationImage(
image: NetworkImage(
Juegos_de_siempre[index].url_foto,
),
fit: BoxFit.fill,
),
Flutter's documentation suggested the usage of FadeInImage for the placeholder functionality. Here's a link to an example on Flutter's documentation.
You cannot use FadeInImage inside a DecorationImage, so you have to wrap it inside a Stack instead like shown in this thread.
Use CacheNetworkImage Package.Click here.
This is sample code.
CachedNetworkImage(
width: 100,
height: 100,
fit: BoxFit.cover,
imageUrl: imageUrl,
placeholder: (context, url) => const Center(
child: CupertinoActivityIndicator(),
), // replace with your asset image
errorWidget: (context, url, error) =>
const Icon(Icons.error),
),

Set container width according to image.network widh in flutter?

i want to fix my container size(width) according to the image which is getting from api(image.network..).So, how can i go for this?
i am trying to set dynamic width of container according to image which i get from image.network() in flutter.
You will get overflow error in your device when the image was bigger than your device screen. I recommend you to use this
Container(
width: 100,
height: 100,
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
'image link'),
),
),
),

Any widgets in flutter allow me to have a profile picture but if they don't have one the initials show instead?

Im trying to make a flutter app for HR and for my employee's section I need to have it so that their initials are shown if a profile picture is unavailable is there a widget which allows me to do this?
Below is an example of what im trying to achieve
You can try it with CachedNetworkImage
CachedNetworkImage(
imageUrl: "http://myimage...",
placeholder: (context, url) => new CircularProgressIndicator(),
errorWidget: (context, url, error) => new Text("my initials here"),
),
You need to Do Something Like This, but first Need to check for Image thats depends on how you are managing data and then
_isImageAvailable ? ProfileImage() : Text(Name)
Container(
height: 100.0,
width: 100.0,
color: Colors.grey,
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: hasImage
? Image.network(
imageUrl,
fit: BoxFit.contain,
)
: Center(
child: Text('$nameInitial'),
),
),
)

Can't set Image.file to Circular Avatar in flutter

I am trying to use Circular Avatar in my design. however i want to set the image based on a file chosen by the User in their gallery. this image is set to:
File _imageUpload;
This loads properly if i use a container with Image.file
However, CircularAvatar wont accept it as part of the backgroundImage property.
am i meant to convert the file to another file type before assigning it to the Circular Avatar?
Try this code
CircleAvatar(
radius: 57,
backgroundColor: Color(0xff476cfb),
child: ClipOval(
child: new SizedBox(
width: 100.0,
height: 100.0,
child: (_image != null)
? Image.file(
_image,
fit: BoxFit.fill,
)
: Image.network(
"Any Url from the internet to display image",
fit: BoxFit.fill,
),
),
),
),
I found the issue. In circular avatar you should not use Image.file. instead you should be using FileImage
Use Image.file for showing a local photo
Image.file(_imageUpload)

Fill a Card widget with a photo in Flutter

I have a circleavatar within a card widget but the image is not displaying as intended, how can I fill the card with the image rather than getting this eyeball effect?
Card with image
[Card(
shape: CircleBorder(),
elevation: 10.0,
child: CircleAvatar(
backgroundColor: Colors.white,
radius: 75.0,
child: ClipOval(
child: FadeInImage.assetNetwork(
placeholder:
'lib/screens/shared/defaultprofile.png',
image: userData.profilephoto,
fit: BoxFit.fill,
),
),
),
),
you are using ClipOval class A widget that clips its child using an oval.
By default, inscribes an axis-aligned oval into its layout dimensions and prevents its child from painting outside that oval, but the size and location of the clip oval can be customized using a custom clipper.You can remove it to have your desired view.
CircleAvatar(
Backgroundimage: NetworkImage(url)
...
Also see hw to add assets to you flutter app