For questions relating to Flutter's Container class. Use this tag in combination with the general [flutter] tag. If your question applies to Flutter more generally, use the [flutter] tag only.
Questions tagged [flutter-container]
107 questions
181
votes
20 answers
Flutter: Scrolling to a widget in ListView
How can I scroll to a special widget in a ListView?
For instance I want to scroll automatically to some Container in the ListView if I press a specific button.
ListView(children: [
Container(...),
Container(...), #scroll for example to…

GreenTigerEye
- 5,917
- 9
- 22
- 33
103
votes
10 answers
Limit max width of Container in Flutter
Widget build(context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 300,
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
color: color ??…

Nishant Desai
- 1,492
- 3
- 12
- 19
74
votes
4 answers
Flutter BoxDecoration’s background color overrides the Container's background color, why?
I have a Flutter Container widget and I defined a color for it (pink), but for some reason, the color in BoxDecoration overrides it (green). Why?
new Container(
color: Colors.pink,
decoration: new BoxDecoration(
borderRadius: new…

Mary
- 18,347
- 23
- 59
- 76
36
votes
1 answer
Flutter Container: cannot provide both a color and a decoration
I want to draw a border around my container and have the background be colored.
Widget bodyWidget() {
return Container(
color: Colors.yellow,
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
),
child:…

Suragch
- 484,302
- 314
- 1,365
- 1,393
10
votes
3 answers
How do you animate to expand a container from 0 height to the height of its contents in Flutter?
I have a container that starts at zero height and needs to be expanded after a user interaction.
I tried using AnimatedContainer / AnimatedSize and changing the child widget's height from 0 to null, but in both cases, Flutter complains that it…

mwarrior
- 499
- 5
- 17
7
votes
1 answer
How to size an icon according to parent in flutter
I want to size an icon inside a container to be the size of that container so that it would not be small in larger devices due to hard coding the size value. I was trying something like this
Container(
child: Icon(
Icons.beach_access,
…

Vishnubly
- 539
- 1
- 8
- 17
4
votes
1 answer
Container size depending on his content (text)
I want my container to have different size depending on their content (in this case a text), if one user write a longer text the container will be biger and if another user write a shorter text the container will be smaller.
Is it possible? And if…

Ozz
- 97
- 1
- 9
4
votes
5 answers
Flutter rotated text not filling available space
I have a container holding some text and when the text is normal horizontal position it is split into 2 lines as it does not fit in a single line, which I understand:
Container(
width: 30,
height: 250,
…

codeKiller
- 5,493
- 17
- 60
- 115
3
votes
1 answer
How to add ripple effect to a Container with decoration in Flutter?
I want to add a ripple effect to a custom Container. I have used Inkwell and Material widgets to achieve this behavior, but it does not work. The code is as follows:
@override
Widget build(BuildContext context) {
return Center(
child:…

sm_sayedi
- 326
- 2
- 17
3
votes
1 answer
Giving a fixed width and height to a container vs providing constraints via a BoxConstraints class
In the Container widget in flutter,
What is the difference between giving it a fixed height and width AND providing it BoxConstraints for the constraints property?.
Is it either providing a width + height or constraints? Can they be both provided…

gfit21x
- 141
- 9
3
votes
3 answers
Is there any way to elevate a widget in flutter without using material widget?
I am creating a search widget and I want it to have a little bit of elevation, I can do that by using Material widget but Material has other properties like color as well and it creates weird edges when i wrap my container with material…

Mateen Kiani
- 2,869
- 2
- 19
- 29
3
votes
2 answers
Flutter Container Positioning or alignment inside Row widget
I'm new in flutter. right now learning how to positioning or aligning widgets. I have two containers inside my row widget. I want to set my first container(which is red container) at the top left, and also want to set my second container(which is…

Imtiaz Dipto
- 342
- 1
- 3
- 9
2
votes
1 answer
DraggableScrollableSheet with Column won't drag to top
I'm trying to create a draggable bottom sheet that will have a set header & footer. Between those, the body/content will vary. There may be an empty state or there may be a list of data. The user should be able to expand this sheet to the top of the…

Luke Irvin
- 1,179
- 1
- 20
- 39
2
votes
1 answer
no_logic_in_create_state abstract methods are false positives #2345
I'm Beginner in flutter
can anybody help …..!!!!!
How to resolve this issue?
this the error.
ImplicitlyAnimatedWidgetState createState(); // ignore: no_logic_in_create_state,…

Swapnil Ghule
- 149
- 1
- 8
2
votes
0 answers
Flutter Parent box decoration image overlapping child box decoration
So I have this container wrapped inside a container.
Parent container has full screen background image, the child container has icon with border, which is hiding behind parent container background image.
Why is this happening? Is there something…

wordpress user
- 548
- 7
- 24