0

how to reverse this or how to display data in descending order when we using firebaseanimationlist i see lots content but i cannot find the solution please help me on this topic when we use firebaseanimationlist or fetch data from firebasedatabase it comes in accending order please provide answer on this topic

import 'package:college_notification_app/notificationScreen/singleDataScreen.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:firebase_database/ui/firebase_animated_list.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'displayData.dart';

class AllNotificationScreen extends StatefulWidget {
  const AllNotificationScreen({Key? key}) : super(key: key);
  static const String routeName = '/allNotificationScreen';

  @override
  State<AllNotificationScreen> createState() => _AllNotificationScreenState();
}

class _AllNotificationScreenState extends State<AllNotificationScreen> {
  final query = FirebaseDatabase.instance.ref('Post');
  final fileRef = FirebaseStorage.instance.ref('/file');
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        shadowColor: Colors.transparent,
        backgroundColor: const Color(0xFF7877BB),
        systemOverlayStyle: const SystemUiOverlayStyle(
          statusBarColor: Color(0xFF7877BB),
          statusBarIconBrightness: Brightness.dark,
        ),
        title: const Text(
          'All Notification',
          style: TextStyle(
            color: Colors.white,
            fontFamily: 'OpenSans',
            fontWeight: FontWeight.bold,
          ),
        ),
      ),

      body: Column(
        children: [
          Expanded(
              child: FirebaseAnimatedList(

                query: query,
                itemBuilder: (context, snapshot, animation, index) {
                  String id = snapshot.child('id').value.toString();
                  String subject = snapshot.child('subject').value.toString();
                  String message = snapshot.child('message').value.toString();
                  String fileUrl = snapshot.child('fileUrl0').value.toString();
                  String dateTime = snapshot.child('dateTime').value.toString();

                  return InkWell(
                    onTap: () {
                      print(id);
                      Navigator.push(
                        context,
                        MaterialPageRoute(
                            builder: (context) => SingleDataScreen(childId: id)),
                      );
                    },
                    child: ContentCard(
                        subject: subject, message: message, fileUrl: fileUrl),
                  );
                },
              )),
          Container(color: Colors.transparent)
          //start
          //end
        ],
      ),

    );
  }
}

TP SINGH
  • 31
  • 1
  • 5

0 Answers0