Ad

How To Add Other Components Additional To Gridview On Same Page In Flutter

...
            if (snapshot.data == null) {
              return Container(
                  child: Center(
                child: Text("Loading..."),
              ));
            } else {
              return GridView.builder(
                  itemCount: snapshot.data.length,
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 3),
                  itemBuilder: (context, index) => Card(
                          child: GridTile(
                        child: Center(
                          child: Text(snapshot.data[index].service_type),
                        ),
                      )));
            }
...

When this code is executed, the result is as follows,

In this, I need to add an image component on top of the grids. Please help me on achieving that. The below image is the expected result design.

Ad

Answer

Using shrinkWrap on big lists is a bad practice, you should wrap your GridView/ ListView with expanded when you want something above or below it, also don't nest scroll views like that. You should use CustomScrollView or NestedScrollView instead. What they said in the docs.

Shrink wrapping the content of the scroll view is significantly more expensive than expanding to the maximum allowed size because the content can expand and contract during scrolling, which means the size of the scroll view needs to be recomputed whenever the scroll position changes.

Ad
source: stackoverflow.com
Ad