can I add more widget inside the image on flutter? - flutter

Just started to learn fultter and I am trying to create a login page on flutter for an app and I found an image as the background of the login page. Is it possible to add some text and input field on the image ? Please let me know if there's a way to do so. Thanks.

Yes, You have to use Stack widget for that. Initial one has your image and for textField you can add widget with Position.

Container(
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage('asset_image'),
),
),
child: Column(
children: [
// Form field
],
),
);

Related

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'),
),
),
),

How can I get this look on my welcome screen? flutter

I am trying to have a welcome screen like this:
I have all the lines from the bottom and the orange and blue bubbles as asset images. How can I stack them all together and then use Text() widget for the writing part?
You can use the Stack widget to stack its children if that answers your question:
Stack(
children: [
your_images_here,
your_text_here,
],
);
You can do it without using stack by using the image property in container decoration.
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/bg.png',
),
fit: BoxFit.cover,
)),
child: Column(
children: [
// your text widgets
])
),
So I had three images, and I couldn't use Imageprovider to use it as a background image of my main Container(). But, I decided to make a difference in my design by wrapping them all together using adobe photoshop and getting one image instead of three so that I can use ImageProvider instead of a stack. Then I used Decoration image and made the image the background of my page.

how to change image opacity within Image() widget - flutter

So am trying to change image opacity using the opacity property i found in Image() widget, this is a short code to be clear :
Padding(
padding: EdgeInsets.all(10.0),
child: Center(
child: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Image(
image: NetworkImage(challengeImage),
fit: BoxFit.cover,
height: 150,
width: 350,
opacity: //not sure how to use
),
),
),
),
the image is a network image i retrieved from Firestore and am not sure what is the value i should put if its not double in order to apply opacity on the image. i thought to create a stack and insert asset image as a layer above my image and use the filter property but i would really like to know how the opacity can work with my code above, Thank you.
You can use AlwaysStoppedAnimation or create an Animation<double>
Image(
image: NetworkImage(""),
opacity: AlwaysStoppedAnimation(.1),
),
Another solution : wrap the widget with Opacity Widget
it accepts a double value in range [0,1] where 1 is fully displaying and 0 is not

use loadingBuilder in NetworkImage class flutter

I faced some problems in my flutter app when I use network image:
the image takes too much time to load.
I found the solution by adding loading Builder prosperity in the network.image widget like that :
Image.network( 'URL image}',
fit: BoxFit.fitHeight,
loadingBuilder:(BuildContext context, Widget child,ImageChunkEvent loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null ?
loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes
: null,
),
);
},
),
This works out right now, but then I need to add the same property (loadingBuilder) with the NetworkImage class (into the BoxDecoration)
as follows:
image: DecorationImage(
image: NetworkImage(widget.cover),
fit: BoxFit.cover,
),
How do I add the loadingBuilder with the NetworkImage class (in the last part of the code)?
There is a solution that I used although it seems like trick.
Using 'Stack' widget, at first show loading widget and draw image widget over that.
If that, at first loading widget will be shown and after image loading completed, image will be shown over the loading widget.
Stack(
children: <Widget>[
// Locate loading widget
LoadingWidget(),
//
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(widget.cover),
fit: BoxFit.cover,
),
),
),
],
);

I want to add an image to home page of my flutter app.But am getting difficulties with its length and width

Because of that can't get a good view on different types of phones . I am trying to create an image using clip path library of flutter. Also i want to know whether there is any possibilities to add bootstrap and css to flutter?
You can not use Bootstrap or css in flutter.
To use a background image that fits the whole screen, you can use this :
Widget build(BuildContext context){
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/yourimage.jpg"),
fit: BoxFit.cover,
),
),
child: null /* add child content here */,
),
);
}