StreamBuilder(
stream: _trip.snapshots(),
builder: (context, AsyncSnapshot<QuerySnapshot> streamSnapshot) {
if (streamSnapshot.hasData) {
return ListView.builder(
itemCount: streamSnapshot.data!.docs.length,
itemBuilder: (context, index) {
final DocumentSnapshot documentSnapshot =
streamSnapshot.data!.docs[index];
DateTime dt2 =DateFormat('dd-MM-yyyy').parse(documentSnapshot['enddate']);
if(dt2.isAfter(new DateTime.now())){
return Card(margin: const EdgeInsets.all(10),
child: ListTile(leading: Image.asset("assets/images/baggage.png"),
title: Column(crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Trip: ${documentSnapshot['tripname']}",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 16),),
SizedBox(height: 7,),
Text("Location: ${documentSnapshot['location']} "),
SizedBox(height: 10,)],),
subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text( "Starts: ${documentSnapshot['startdate']}",
style: TextStyle(fontSize: 15.5),),
SizedBox(height: 7,),
Text("Ends: ${documentSnapshot['enddate']}",style: TextStyle(fontSize: 15.5),),],),
trailing: SizedBox(
width: 100, height: 100,
child: Row(children: [IconButton(
onPressed: () => _update(documentSnapshot),
icon: Icon(Icons.edit,),),IconButton(
onPressed: () {setState(() {Navigator.of(context).push( MaterialPageRoute(builder: (context) => ShowPlans(tripid: documentSnapshot['tripid'])));});},
icon: Icon(Icons.arrow_forward_ios,),),],), ),),elevation: 3,);}
return const SizedBox(); },);}
return const Center(child: CircularProgressIndicator(),);},),
I have stored and retrieved data from firebase 'trip' collection here. Now I want to store them in local storage and retrieve them. How can I do that? Please help..
You could use a local No-SQL Database like hive to save data in the local storage. Firebase plugins already cache data locally though, so the question is what do you want to achieve and is maybe the firebase plugin enough?
PS: for simple key value storage, you could also use the localstorage plugin for flutter, or you could use path_provider to store files directly, but this is most likely not what you want, depending on the desired outcome.