Make body have 100% of the browser height
Try setting the height of the html element to 100% as well.
html,
body {
height: 100%;
}
Body looks to its parent (HTML) for how to scale the dynamic property, so the HTML element needs to have its height set as well.
However the content of body will probably need to change dynamically.
Setting min-height to 100% will accomplish this goal.
html {
height: 100%;
}
body {
min-height: 100%;
}
Cannot set dynamic height for TabBarView in flutter
I have fixed this issue by changing SingleChildScrollView into ListView and writing my own TabView widget which contains tabs in Stack wrapper.
Top level widget body wrappers changed from Column and SingleChildScrollView to ListView:
Widget build(BuildContext context) {
SizeConfig().init(context);
return Scaffold(
appBar: RestaurantInfoAppBar(),
body: ListView(
children: <Widget>[Description(), Tabs()],
),
);
}
Tabs widget - removed Container with a static width wrapper:
Widget build(BuildContext context) {
return DefaultTabController(
length: _tabs.length,
child: Column(
children: <Widget>[
TabBar(
labelColor: PickColors.black,
indicatorSize: TabBarIndicatorSize.tab,
tabs: _tabs,
),
TabsView(
tabIndex: _tabIndex,
firstTab: MenuTab(),
secondTab: ReviewsTab(),
)
],
));
}
New custom TabsView component currently handles only two tabs (since I only need two) but can be easily changed to handle dynamic numbers of tabs:
class TabsView extends StatelessWidget {
TabsView(
{Key key,
@required this.tabIndex,
@required this.firstTab,
@required this.secondTab})
: super(key: key);
final int tabIndex;
final Widget firstTab;
final Widget secondTab;
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
AnimatedContainer(
child: firstTab,
width: SizeConfig.screenWidth,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
transform: Matrix4.translationValues(
tabIndex == 0 ? 0 : -SizeConfig.screenWidth, 0, 0),
duration: Duration(milliseconds: 300),
curve: Curves.easeIn,
),
AnimatedContainer(
child: secondTab,
width: SizeConfig.screenWidth,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
transform: Matrix4.translationValues(
tabIndex == 1 ? 0 : SizeConfig.screenWidth, 0, 0),
duration: Duration(milliseconds: 300),
curve: Curves.easeIn,
)
],
);
}
}
P.S. SizeConfig is the same as MediaQuery.of(context).size.width.
Hope this helps someone like me! :)
How to solve Layout issues with nested StackViews?
Here is a layout that does not generate any layout warnings / ambiguities:
The stack views' properties are set as follows:
I designed one "Row Stack" in the Vertical "Outer Stack" and then just duplicated it 3 times.
Here is how it looks at run-time (labels have background colors to make it easy to see their frames):
and with the label backgrounds set to clear:
How to use Auto Height and Scroll View at the same time in iOS?
You need two height constraints - The aspect ratio constraint that you already have, plus a second height constraint of >= 40.
Set the priority of the aspect ratio constraint to a lower value than the new height constraint. E.g. Set the aspect ratio constraint to 750 and leave the new height constraint at the default of 1000.
With this set of constraints the minimum height of the view will be 40 (set by the required constraint) but can be greater (if set by the aspect ratio constraint). The different priorities avoids a conflicting constraints warning.
Related Topics
Uitableview Automatic Dimension Not Working Correctly
Alamofire Request Gets Stuck When Entering Background
Add 'For...In' Support to a Class in Swift 2
Stop Overscroll When Using "-Webkit-Overflow-Scrolling: Touch"
Cancel All Operations + Afnetworking 3.0
Swift Package Manager Issues with Unversioned Packages (Example: Firebase-Ios-Sdk)
Swift + Firebase Security Not Working
Uicollectionview - Horizontal Paging with One Cell at a Time
iOS Today Extension with Core Data
Indexpathforrowatpoint Returns Nil Only for First Cell in a UItableview
Apn Custom Notification Sound Issue
iOS Add Button to Widget Extension
Initialization of 'Unsafepointer<Int>' Results in a Dangling Pointer
How to Install Self-Signed Certificates in iOS 11
Pass a Nsdictionary as Parameter to UItapgesturerecognizer