reason
The tabbarview
component occupies as much space as the parent component. Generally, the outer layer of this layout is scrollable, similar to singlechildscrollview
, but there is no clear height constraint in the column
, that is, infinite height, so an error is reported.
Solution:
1. Fixed height
It directly solves the problem locally, but there is a big disadvantage. The components loaded by tabbarview
may have different heights, so the predetermined height should be their maximum height, and the layout is not good-looking.
SingleChildScrollView(
child: Column(
children: [
MyTabBar(),
SizedBox(
height: 500,
child: TabBarView(
children:[
MyTabView1(),
MyTabView2(),
],
),
),
],
),
)
2. Do not use the tabbarview
component
It is recommended to use the indexedstack
component instead. The disadvantage is that it lacks the sliding animation of the original tabbarview
component, but it can be customized with the animatedswitcher
component. Click to learn more
SingleChildScrollView(
child: Column(
children: [
MyTabBar(),
IndexedStack(
index: currentIndex, //currentIndex is the value of my example, in reality it may come from TabController, or Provider, etc.
children:[
MyTabView1(),
MyTabView2(),
],
),
),
],
),
)
3. To be continued
Read More:
- [Solved] Vsync Error: this error in animationcontroller in fluent
- [Solved] ViewBinding Error: java.lang.ClassCastException: android.widget.RelativeLayout cannot be
- Solve the problem of incorrect display of dialogfragment width
- [Solved] Flyter uses screenutil to obtain screen width and height initialization error
- [Solved] error Component name “index“ should always be multi-word vue/multi-word-component-names
- Runtime error prompt in Android Studio: arrayadapter requires the resource ID to be a textview problem
- [Fixed] Typeerror: error 1009: Cannot access properties or methods referenced by an empty object
- Using elementui El-dialog as a subcomponent to close an error
- Qt Error: Debug Assertion Failed [How to Solve]
- Flash back problem when Android studio plays music in sdcard through intent
- Vue3 Warning: [Vue warn]: Extraneous non-emits event listeners (changeParentProps) were passed to component
- The tree component in easyUI does not display data or displays undefined solutions
- [Solved] Android Studio Compile Error: Execution failed for task ‘:APP_MIDI:lintVitalRelease‘.
- [Solved] Android Develop Error: xxx does not have a NavController set on xxx
- Linux: tar Unpack .tar.bz2 File Error tar: Child returned status 2 tar: Error is not recoverable: exiting now
- [Solved] kubeflow pipeline visualization component Error: WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager…
- [Solved] Android9.0 App Install Android4.4 Error: InflateException-You must supply a layout_height attribute.
- ElementUI Error in callback for watcher “data”: “Error: [ElTable] prop row-key is required”
- [Solved] element-plus Error: Failed to resolve component
- How to Solve Error Swift 4 Expression type ‘@value CGRect’ is ambiguous without more context