Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Incorrect use of ParentDataWidget in my app and dont know what is wrong

I dont know why Incorrect use of ParentDataWidget error is showing while using a column widget . Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a SizedBox widget.

And code is:-

    class HomeWidget extends StatelessWidget {
  const HomeWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      margin: const EdgeInsets.symmetric(horizontal: 20),
      child: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            const SizedBox(
              height: 20,
            ),
            const ListTile(
              leading: CircleAvatar(
                child: Icon(Icons.person),
              ),
              title: Text('Welcome Username!'),
              subtitle: Text('Have a nice day'),
            ),
            const SizedBox(
              height: 20,
            ),
            
            const TextField(
              decoration: InputDecoration(
                hintText: 'Search',
                suffixIcon: Icon(Icons.search),
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.all(
                    Radius.circular(10),
                  ),
                ),
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            FirstListView(),
            const Text('Some Links'),
            const SizedBox(
              height: 10,
            ),
            SomeWidget(),
            const Text('some Places'),
            const SizedBox(
              height: 10,
            ),
            SomeWidget(),
            
            const Text('Recent Searches'),
            const SizedBox(
              height: 20,
            ),
            SomeWidget(),
            const SizedBox(
              height: 80,
            ),
          ],
        ),
      ),
    );
  }
}

The screenshot of error image is attached
error image

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just add shrinkWrap: true to the inner ListView (FirstListView) like:

 ListView(
              shrinkWrap: true,
              children: [
                SomeInnerWidget(),
                SomeInnerWidget2(),
              ],
            ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading