am facing this problem for a while now and i've no flutter community in my country so am forced to post online if i get any help and i will be glad if i found one cuz am in the deployment face of this app and it is the only thing stopping from publishing and getting paid so please guys i need help
[![am getting this error for a week now
][1]][1]
this is my home
import 'package:connection_status_bar/connection_status_bar.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:taxi/Driver/HomeScreen.dart';
import 'package:taxi/Driver/carInfo..dart';
import 'package:taxi/Driver/loginPage.dart';
import 'package:taxi/config.dart';
import 'package:taxi/riders/Screens/HomeScreen.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';
import 'package:taxi/riders/Screens/PhoneAuthInfo.dart';
import 'package:taxi/riders/Screens/Profile.dart';
import 'package:taxi/riders/Screens/historyScreen.dart';
import 'package:taxi/riders/Screens/landingPage.dart';
import 'package:taxi/riders/Screens/loginPage.dart';
import 'package:taxi/riders/Screens/signUp.dart';
import 'package:taxi/riders/data/Data.dart';
import 'package:taxi/Driver/signUp.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
currentfirebaseUser = FirebaseAuth.instance.currentUser;
runApp(MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => AppData(),)
],
child: EasyLocalization(
child: MyApp(),
path: "images/resources",
saveLocale: true,
supportedLocales: [
Locale('am', 'ET'),
Locale('en', 'CA'),
Locale('en', 'US')
],
fallbackLocale: Locale('en', 'US'),
),
)
);
}
DatabaseReference userRef =
FirebaseDatabase.instance.reference().child("users");
DatabaseReference driverRef =
FirebaseDatabase.instance.reference().child("drivers");
DatabaseReference newRequestsRef =
FirebaseDatabase.instance.reference().child("Ride Request");
DatabaseReference rideRequestRef = FirebaseDatabase.instance
.reference()
.child("drivers")
.child(currentfirebaseUser.uid)
.child("newRide");
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Goosh',
theme: ThemeData(
cursorColor: Colors.black,
fontFamily: "Font regular",
primaryColor: Colors.amber,
),
builder: (context, _) => Stack(children: [
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Goosh',
theme: ThemeData(
cursorColor: Color(0xff5f86ba),
fontFamily: "Font regular",
primaryColor: Color(0xff5f86ba),
),
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
initialRoute: FirebaseAuth.instance.currentUser == null
? PhoneAuth.idScreen
: HomeScreen.idScreen,
// initialRoute: Login.idScreen,
routes: {
PhoneAuth.idScreen: (context) => PhoneAuth(),
Login.idScreen: (context) => Login(),
SignUp.idScreen: (context) => SignUp(),
HomeScreen.idScreen: (context) => HomeScreen(),
DriverSignUp.idScreen: (context) => DriverSignUp(),
DriverLogin.idScreen: (context) => DriverLogin(),
CarInfo.idScreen: (context) => CarInfo(),
DriverMainScreen.idScreen: (context) => DriverMainScreen(),
HistoryScreen.idScreen: (route) => HistoryScreen(),
PhoneAuthInfo.idScreen: (context) => PhoneAuthInfo(),
ProfilePage.idScreen: (context) => ProfilePage()
},
),
Align(
alignment: Alignment.topCenter,
child: ConnectionStatusBar(
lookUpAddress: 'google.com',
height: 32,
animationDuration: Duration(milliseconds: 100),
title: Material(
color: Colors.redAccent,
child: Text(
'Please check your internet connection',
style: TextStyle(color: Colors.white, fontSize: 16),
),
)),
)
]),
);
}
}
and this is how i navigate to this page
ListTile(
leading: Icon(Icons.local_taxi_outlined),
title: Text("My Gooshs".tr().toString()),
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => HistoryScreen()));
},
),
and this is my history screen code
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:taxi/riders/data/data.dart';
import 'package:taxi/riders/widget/historyItem.dart';
class HistoryScreen extends StatefulWidget {
static const String idScreen = "HistoryScreen";
@override
_HistoryScreenState createState() => _HistoryScreenState();
}
class _HistoryScreenState extends State<HistoryScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("History"),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(Icons.keyboard_arrow_left),
),
),
body: History());
}
}
class History extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.separated(
padding: EdgeInsets.all(0),
itemBuilder: (context, index) {
return HistoryItem(
history: Provider.of<AppData>(context, listen: false)
.tripHistoryDataList[index],
);
},
separatorBuilder: (BuildContext context, int index) => Divider(
height: 2.0,
thickness: 2.0,
),
itemCount: Provider.of<AppData>(context, listen: false).tripHistoryDataList.length,
physics: ClampingScrollPhysics(),
shrinkWrap: true,
);
}
}
and this is my single history item
import 'package:flutter/material.dart';
import 'package:taxi/riders/assistance/DriverAssistMethod.dart';
import 'package:taxi/riders/model/History.dart';
class HistoryItem extends StatelessWidget {
final History history;
HistoryItem({this.history});
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Column(
children: [
Container(
child: Row(
children: <Widget>[
Image.asset(
'images/pickicon.png',
height: 16.0,
width: 16.0,
),
SizedBox(width: 18.0),
Expanded(
child: Container(
child: Text(history.pickUp,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 18.0)))),
Text(
'${history.fares}',
style: TextStyle(fontFamily: 'Font bold', fontSize: 16.0),
)
],
),
),
SizedBox(
height: 8.0,
),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Image.asset(
'images/desticon.png',
height: 16.0,
width: 16.0,
),
Text(history.dropOff,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 18.0))
],
),
SizedBox(
height: 15.0,
),
Text(
DriverAssistantMethods.formatTripDate(history.createdAt),
style: TextStyle(color: Colors.grey),
)
],
),
);
}
}
and this is my provider data
import 'package:taxi/riders/model/History.dart';
import 'package:taxi/riders/model/adress.dart';
import 'package:flutter/material.dart';
class AppData extends ChangeNotifier{
Address pickupLocation, dropOffLocation;
int countTrips = 0;
List<String> tripHistoryKeys = [];
List<History> tripHistoryDataList = [];
void updatePickUpLocationAddress(Address pickUpAddress)
{
pickupLocation = pickUpAddress;
notifyListeners();
}
void updatedropOffLocationAddress(Address dropOffAddress)
{
dropOffLocation = dropOffAddress;
notifyListeners();
}
void updateTripsCounter(int tripCounter){
countTrips = tripCounter;
notifyListeners();
}
void updateTripKeys(List<String> newKeys){
tripHistoryKeys = newKeys;
notifyListeners();
}
void updateTripData(History eachhistory){
tripHistoryDataList.add(eachhistory);
notifyListeners();
}
}
and this is how i fetch data from the realtime database
static void retrieveHistory(context) {
//retrieve history and Trip History
newRequestsRef
.orderByChild("rider_name")
.once()
.then((DataSnapshot dataSnapshot) {
if (dataSnapshot.value != null) {
//update total number of trip to provider
Map<dynamic, dynamic> keys = dataSnapshot.value;
int tripCounter = keys.length;
Provider.of<AppData>(context, listen: false)
.updateTripsCounter(tripCounter);
//update trip keys of trip to provider
List<String> tripHistoryKeys = [];
keys.forEach((key, value) {
tripHistoryKeys.add(key);
});
Provider.of<AppData>(context, listen: false)
.updateTripKeys(tripHistoryKeys);
obtainTripRequestHistoryData(context);
}
});
}
static void obtainTripRequestHistoryData(context) {
var keys = Provider.of<AppData>(context, listen: false).tripHistoryKeys;
for (String key in keys) {
newRequestsRef.child(key).once().then((DataSnapshot dataSnapshot) {
if (dataSnapshot.value != null) {
newRequestsRef
.child(key)
.child("rider_name")
.once()
.then((DataSnapshot dsnap) {
String name = dsnap.value.toString();
if (name == userCurrentInfo.name) {
var history = History.fromSnapshot(dataSnapshot);
Provider.of<AppData>(context, listen: false).updateTripData(history);
}
});
}
});
}
}
[1]: https://i.sstatic.net/sRBAD.jpg