I'm starting my journey on Flutter, mostly following some tutorials and codes on the web. I've been using a pre-made project which are making a single call to every FirebaseAnimatedList on the app (there are more than 6 FirebaseAnimatedList in different pages). The code below is a example on how I'm making those calls.
I've some questions that would help me a lot!
- How would be a better and smarter way to make one single call for the entire app?
- How I would change those FirebaseAnimatedList to another widget displaying the same content?
- Is there a way to cache these data coming from the Firebase Realtime Database?
- Any other suggestion I highly appreciated!
Thanks again!
class ExampleCode extends GetView {
ExampleCode({Key? key}) : super(key: key);
Query dbRef = FirebaseDatabase.instance.ref().child('moedas');
DatabaseReference reference = FirebaseDatabase.instance.ref().child('moedas');
@override
Widget build(BuildContext context) {
FirebaseDatabase.instance.setPersistenceEnabled(true);
return FirebaseAnimatedList(
shrinkWrap: true,
query: dbRef,
itemBuilder: (BuildContext context, DataSnapshot snapshot,
Animation animation, int index) {
Map moedas = snapshot.value as Map;
moedas['key'] = snapshot.key;
return appCardDefault(
child: Column(
children: [
Row(
children: [
Text(
moedas['moedaName'],
style: appTextTheme.headline2,
),
Text(moedas['currentValue'], style: appTextTheme.headline1),
],
),
CachedNetworkImage(imageUrl: moedas['moedaImg']!, width: 60),
],
),
);
},
);
}
}
