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.
Related
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
],
),
);
I would like to incorporate a widget inside my image. But the problem is that all the ways that I found dont have a child method so I can't put a widget in there.
The last thing that I tried was to use BoxDecoration inside a Container and use child for the widget that I want to display inside. But the size of the container don't match with this image I don't know why. Anyone have an idea ?
my code:
You need to use fit, like this:
Container(
height: 200,
width: 100,
decoration: BoxDecoration(
color: Colors.red,
image: DecorationImage(
fit: BoxFit.cover,//<--- add this
image: AssetImage('assets/images/test.jpeg'),
)),
child: ...
),
result before:
result after:
Wrap your Row() with Positioned() and play around with alignment
the Stack widget is what you need, simply it just considers its children as layers :
Stack(
children= <Widget>[
YourImageWidget(),
AnotherWidget(),
]
)
this will put one over the other widget
to control the position of your widget, Wrap it with the Positioned widget and set top, left, bottom, and right properties.
or wrap with the Align widget and set alignment property , example :
Stack(
children= <Widget>[
YourImageWidget(),
Positioned(
bottom: 0,
left: 15
child: AnotherWidget(),
)
]
)
I try to recreate the following image in Flutter web, I understand how to do almost everything, except the profile box that is above the image,
How can I put an object on top of an image?
Use Stack to put widgets on each other ,if you want to put widget on specific position use Positioned
i suggest you to read this article
This is an example of placing object on the top of an image:
Stack(
children: [
// Background image placed in the center of Stack
Center(
child: Image.network(
'https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg'),
),
// Blue container 50x50 placed on the top of an image
Center(
child: Container(
width: 50,
height: 50,
color: Colors.blue
),
),
],
)
I have positioned(using Align) two child widgets within stack widget and one of it contains form TextField to take input. When I clicked to enter data, only it's parent widget is moved up on Keypad entered as in the below picture.
Is there any way to move/resize the child widgets of stack while entering data from keypad.
Source code:
return Scaffold(
body: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/playingboard2.jpg'),
fit: BoxFit.cover)),
child: null,
),
_buildSelfPlayer(), // Returns the widget with form input and other widgets
_buildBank(), // top center, shows two pictures of bank
],
),
);
I don't see another fix for this, while also making use of Stack widget.
So instead I'd suggest you to use Column widget wrapped inside a SingleChildScrollView. I tried it and it works as intended. The other children move up too along with the TextField, so maintaining the distance between them and not overlapping.
For the background image, you can wrap the Scaffold in a Container, use that image in the Column decoration and make the Scaffold's backgroundColor to Colors.transparent.
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 */,
),
);
}