The following layout is working fine on connected real device:

But when run on built apk, it shows the following:

I can't figure out the problem, as it shows no errors or warnings while running the app on real device. Is there a way to debug an APK?

If i comment out the Gridview.builder the apk works same as that on real device.

This is the code i implemented:

  Container myArticles(String imageVal,int index,String univid)
  {
    return Container(
      child:Align(
        alignment: Alignment.center,
        child: Card(
          child:Container(
            child: FlatButton(
              color: Colors.white,
            splashColor: Colors.white,
              child:Stack(
               children: <Widget>[
                  Image.asset(imageVal),
              Positioned(
                top: 120,
                left: 8,
                child: Center(
                    child:Container(
                      width: 130,
                      child: Text(widget.data[index]["subject_name"],
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 11.0,
                        fontWeight: FontWeight.bold,
                      ),
                  ),
                    ),

                ),
              ),
              Positioned(
                top: 160,
                left: 40,
                child: Center(
                  child: Text("₹"+widget.data[index]["price"],
                    style: TextStyle(
                      fontSize: 20.0,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
               ],
              ),
            onPressed: ()async {}
             },
            ),
          ),
          ),
        ),
    );
  }
  @override

  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.deepPurple,
      body: ListView(

      children:<Widget>[
         Column(
        children: <Widget>[
          Column(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.fromLTRB(0, 10, 100, 0),
                child: Container(
                  padding: EdgeInsets.fromLTRB(0, 30,200,0),
                  child: IconButton(icon: Icon(Icons.arrow_back,),
                    color: Colors.black,
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                ),
              ),
              SizedBox(height: 20,),
              Text('Semester '+ widget.id,
                style: TextStyle(color: Colors.white,
                    fontSize: 35),
              ),
              SizedBox(height: 25,),
              Text('Subjects: '+widget.subcount,
                style: TextStyle(color: Colors.white,
                    fontSize: 17),
              ),

            ],
          ),
          SizedBox(height: 40,),
          Container(
            height: MediaQuery.of(context).size.height - 185,
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.only(topLeft: Radius.circular(75.0)),
            ),
           child: Padding(
             padding: const EdgeInsets.fromLTRB(0,100,0,50),
             child: Expanded(
                    child: GridView.builder(
                      physics: ScrollPhysics(),
                    itemCount: widget.data.length,
                    shrinkWrap: true,
                    scrollDirection: Axis.vertical,
                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 2,
                    ),
                    itemBuilder: (BuildContext context, int index){
                      return Container(
                        child: myArticles("assets/NewSub/1.png",index,widget.data[index]["univ_spec_sub_id"].toString()),

                      );
                    },
                  ),
                ),
           ),
          ),

        ],
  ),
      ],
      ),
    );
  }
}


Solution 1: Aman Malhotra

After you build an apk, install it in real android device. You can still see the app logs. Hoping that you have all the adb and sdk things properly set up (as you are able to run the app on the device while building so) Follow the below steps to debug the apk.

  1. Install apk on device
  2. Open the app
  3. Connect the device to your system(which you are using to build flutter apps) with usb.
  4. Open your console
  5. Type flutter logs
  6. You'll see all the logs from the any flutter running app on your android device.

This wont resolve your list view not showing problem but will let you see all the logs as to why you are not able to see the list and than from the logs you an figure out what is the error.