Flutter AssetImage loads in slowly / with white screen - image

I have noticed this issue a few times with times while loading my app in the emulator. My background image on my Homescreen seems to load in slow and shows a White screen/placeholder while it is loading.
Oddly enough, I've heard more complaints about this "white screen issue" from my iPhone users. They even complain about the screen just staying white and the image never loading.
I am just curious if this is something others have seen and if so, how you solved the issue.
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(0.4), BlendMode.darken),
image: const AssetImage(AppStrings.graffitLogo),
fit: BoxFit.cover,
),
),
)
[

Related

Flutter How set images fit to custom image frame?

I want to set images to my custom frame(frame is a png file) like image below.
image
image reference (https://favpng.com/png_view/film-strips-photographic-film-filmstrip-photography-photo-booth-png/EDuYNtkt)
use can try this it will help
Expanded(
// your image goes here which will take as much height as possible.
child: Image.asset('asset', fit: BoxFit.contain),
),
or
Image.asset('asset', fit: BoxFit.fill)

Image overflow Flutter

I have an overflow on this image :
Container(
width: MediaQuery.of(context).size.width,
child: Image.network(imageSomwhereFomTheInternet),
),
How can I display a generic image from the internet preventing it to change its proportions? (I mean, if I fix an height or width the image could be "damaged" by this decision, I would like to use an automatic widget that fit this image in a certain Box, or something like that).
I don't know much about "How handle images", if you can suggest me something easy to understand where I can read more I would be very happy.
You can use fit property of image
Container(
child: Image.network(
"https://images.unsplash.com/photo-1547721064-da6cfb341d50",
fit: BoxFit.cover,
),
)
You can choose which suits you best from following:
BoxFit.contain- As large as possible but contained within the Container
BoxFit.cover- As small as possible but covering the entire Container
BoxFit.fill- Fill the entire Container but may distort the image aspect ratio

Flutter scale image to fill height without boundary error

I want to have a card/container which fits the whole screen. In this card exists an image asset. However, trying to fit the image in a Expanded Widget just scale it as far as it reaches a boundayry of the screen.
Is there any way to scale it up (and of course clip/crop the image by this) so it fills up the entire screen without reaching these overflow messages? Also the user should not be able to scroll in the overflowed part.
This code should help you, you can use the image as a widget as a Container's child too;
Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage(filepath),
),
),
);

FLUTTER CircleAvatar not displaying network image

I am trying to display a network image of mario in a circleavatar using flutter. Nothing is displaying and no errors are returned. Please help! This is my code (Indents are screwed up):
CircleAvatar(
backgroundImage: NetworkImage("https://blogs.forbes.com/olliebarder/files/2018/03/super_mario_plumber_new.jpg") ,
radius: 40.0,
),
It is part of a class which extends StatelessWidget and it is wrapped in a padding, and a column.
You just need to hard-reset, use the green circle in vs code or android studio, or CTRL + C, then flutter run in terminal.

Animate a diagonally-scrolling background pattern in Flutter

Flutter newbie here.
Basically I'd like to reproduce the effect of the background in this video:
https://youtu.be/LcCtg1D_RIE?t=804
From what I have gathered so far, I can use a Stack widget to set some background layer, and use the repeat property of Image to get a repeating tile pattern. The following code does this reasonably well:
Widget build(BuildContext context) {
return Stack(children: <Widget>[
Container(
width: 5000,
height: 5000,
child: Image.network(
"https://www.scirra.com/images/articles/daf.png",
repeat: ImageRepeat.repeat,
)),
/* UI goes here */
]);
What I cannot figure out, is how to perform the animation. I have tried various scroll classes (like SingleChildScrollView) but they seem more designed for interactive use and do not allow bi-directional scrolling.
Another idea I have explored is providing a translation matrix to my Container, but while this indeed scrolls the pattern, it also leaves a black area at the edge of the screen.
I'm sure there exists a smart trick to easily achieve that effect - would someone have some clever input?

Resources