-1

Here I have below Widget in my bttomsheet (showModalBottomSheet) :

 Flexible(
              child: ListView.separated(
                  separatorBuilder: (context, index) => Container(
                        height: 20.h,
                      ),
                  itemCount: 22,
                  itemBuilder: (context, index) {
                    return NagarTiming("test");
                  }),
            ),

This works file while I run the application i.e. I can see list of widgets properly. But then I have generated the .apk file using command in android studio,

and then I have installed that apk in my android device, The issue is : bottomsheet opens but it has blank content, there is no list of widget and it giving below error :

the following assertion was thrown while applying parent data.: Incorrect use of ParentDataWidget.

The ParentDataWidget Flexible(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.

Usually, this means that the Flexible widget has the wrong ancestor RenderObjectWidget. Typically, Flexible widgets are placed directly inside Flex widgets. The offending Flexible is currently placed inside a SizedBox widget.

The ownership chain for the RenderObject that received the incompatible parent data was: _ScrollSemantics-[GlobalKey#f71a8] ← NotificationListener ← Scrollable ← PrimaryScrollController ← ListView ← Flexible ← SizedBox ← Column ← Padding ← Container ← ⋯ When the exception was thrown, this was the stack: #0 RenderObjectElement._updateParentData. (package:flutter/src/widgets/framework.dart:5960:11)

What might be the issue? Thanks.

Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72

1 Answers1

1

First you have to know what Flexible() widget does and where it can be applied

1: If it is a direct child Row() widget

Row(
children[
 //your widget
 
         Flexible(
            child: ListView.separated(
                separatorBuilder: (context, index) => Container(
                      height: 20.h,
                    ),
                itemCount: 22,
                itemBuilder: (context, index) {
                  return NagarTiming("test");
                }),
          ), 
 ]

 )

2: If it is a direct child Column() widget

Column(
children[
 //your widget
 
         Flexible(
            child: ListView.separated(
                separatorBuilder: (context, index) => Container(
                      height: 20.h,
                    ),
                itemCount: 22,
                itemBuilder: (context, index) {
                  return NagarTiming("test");
                }),
          ), 
 ]

 )

If you still don't attain your desired appearance remove the Flexible() and wrap with SizedBox() or Container() with desired height of course or you could use Wrap() widget instead. Fo more see this api

Davis
  • 1,219
  • 2
  • 8
  • 17