Reputation: 65
I have a Container and an image inside the container. I want to define the height for the container depending on the type of photo. If it is in portrait then the height should be of a size. If it is in Landscape then i want it to be in default height(the one automatically assigned).
In the Example below consider the height is False(Landscape Photo)
Container(
height: isPortrait
? MediaQuery.of(context).size.height / 1.4
: __________ , // How to define something like do nothing
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Image.asset(image)
),
),
Upvotes: 0
Views: 775
Reputation: 1939
Since height is a double, there is no real way of setting it to "default" other than not assigning it. You could try something like this:
isPortrait
? Container(
height: MediaQuery.of(context).size.height / 2,
child: RestOfContent())
: Container(
child: RestOfContent(),
),
RestOfContent
Would be a Builder/Widget with the rest of your code. This way you don't have to write duplicate code.
Upvotes: 1