evrything is ok in emulator but it crashed in real device , i call this class from botton inside list tile, here is my error this is the error screenshot in real device when i call this class is there any problem if i using variables in collections when call firebase collection,
here is my calling button :
onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(name))); }, here is my code :
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; class DetailPage extends StatefulWidget { final String index; DetailPage(this.index); @override _DetailPageState createState() => _DetailPageState(); } class _DetailPageState extends State<DetailPage> { var filepath; var response; @override Widget build(BuildContext context) { return FutureBuilder(builder: (context, snapshot) { return Scaffold( appBar: AppBar( backgroundColor: Color(0xff0fd1c0), centerTitle: true, title: Text( '${widget.index}', textDirection: TextDirection.rtl, ), ), body: Container( child: StreamBuilder( stream: FirebaseFirestore.instance .collection(widget.index) .snapshots(), builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) { if (snapshot.data == null) return Center(child: CircularProgressIndicator()); else return ListView.builder( itemCount: snapshot.data.docs.length, itemBuilder: (context, index1) { DocumentSnapshot exams = snapshot.data.docs[index1]; return new Padding( padding: new EdgeInsets.symmetric( vertical: 8.0, horizontal: 16.0, ), child: new Card( elevation: 16.0, shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(16.0), ), child: new Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new ClipRRect( child: new Image.network( exams.data()['image'], loadingBuilder: (context, child, progress) { return progress == null ? child : Container( color: Colors.black26, child: Center( child: SizedBox( height: 250.0, width: 200.0, child: Center( child: SizedBox( width: 130.0, height: 130.0, child: CircularProgressIndicator( strokeWidth: 14.0, backgroundColor: Color(0xff0fd1c0), ), ))), ), ); }, ), borderRadius: BorderRadius.only( topLeft: new Radius.circular(16.0), topRight: new Radius.circular(16.0), ), ), new Padding( padding: new EdgeInsets.all(16.0), child: new Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ new FloatingActionButton( onPressed: () {}, heroTag: null, child: Icon(Icons.share_outlined), backgroundColor: Colors.orangeAccent, ), SizedBox( width: 16.0, height: 10.0, ), new FloatingActionButton( onPressed: () { }, heroTag: null, child: Icon(Icons.arrow_downward), backgroundColor: Colors.yellow, ) ], ), new SizedBox(height: 16.0), new Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ new Text(exams .data()["name"] .toString()), new Text( exams.data()["maj"].toString()), new Text(exams .data()["name"] .toString()), ], ), ], ), ), ], ), ), ); }, ); }))); } ); } } Android/gradle/wrapper/gradle-wrapper.properties content:
#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip android/build.gradle content:
buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.google.gms:google-services:4.3.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } android/app/build.gradle content:
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { compileSdkVersion 30 sourceSets { main.java.srcDirs += 'src/main/kotlin' } lintOptions { disable 'InvalidPackage' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.ramiahmad.cordoba_university" minSdkVersion 21 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true } signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } } flutter { source '../..' } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-analytics:17.6.0' implementation 'com.android.support:multidex:1.0.3' implementation 'com.google.firebase:firebase-auth:19.4.0' }} apply plugin: 'com.google.gms.google-services'