0

Currently I have 3 screens, a home which has a streambuilder, a widget which receives the information by parameter and when clicked, I send the data to another screen called detail but which are sent by argument using Getx. I would like that when updating the data in Firebase, the detail screen updates the information, but since I send it by argument, it is not updated.

Home Screen

 StreamBuilder(
              stream: FirebaseFirestore.instance
                  .collection('investment')
                  .where('visible', isEqualTo: true)
                  .where('uid', isEqualTo: controller.auth.currentUser!.uid)
                  .snapshots(),
              builder: (context,
                  AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>> snapshot) {
                if (!snapshot.hasData) {
                  return const Center(
                    child: CircularProgressIndicator(
                      color: darkGreen,
                    ),
                  );
                } else if (snapshot.connectionState ==
                    ConnectionState.waiting) {
                  return const Center(
                    child: CircularProgressIndicator(color: darkGreen),
                  );
                } else if (snapshot.hasData) {
                  return ListView.builder(
                    padding: const EdgeInsets.only(top: 10.0),
                    physics: const NeverScrollableScrollPhysics(),
                    itemCount: snapshot.data!.docs.length,
                    scrollDirection: Axis.vertical,
                    shrinkWrap: true,
                    itemBuilder: ((context, index) {
                      return Padding(
                        padding: const EdgeInsets.symmetric(vertical: 5),
                        child: Tarjeta(
                            investment: snapshot.data!.docs[index].data()),
                      );
                    }),
                  );
                } else {
                  return const Center(child: Text('Sin Inversiones'));
                }
              }),

Tarjetas

class Tarjeta extends StatelessWidget {
  const Tarjeta({
    super.key,
    required this.investment,
  });

//Este widgent necesita recibir la informaciòn de la lista de inversiones
  // ignore: prefer_typing_uninitialized_variables
  final investment;

  @override
  Widget build(BuildContext context) {
    // ignore: non_constant_identifier_names
    var vf_format = NumberFormat.decimalPattern('es_CL');
    // ignore: non_constant_identifier_names
    var p_format =
        NumberFormat.decimalPercentPattern(locale: 'es_CL', decimalDigits: 1);

    return InkWell(
      onTap: () {
        Get.toNamed('/detail', arguments: investment); //Here i send de data to detailscreen in arguments.
      },

Detail Screen

class DetailScreen extends StatefulWidget {
  const DetailScreen({Key? key}) : super(key: key);

  @override
  State<DetailScreen> createState() => _DetailScreenState();
}

class _DetailScreenState extends State<DetailScreen> {
  @override
  Widget build(BuildContext context) {
    final data = Get.arguments; //
    // ignore: non_constant_identifier_names
    var vf_format = NumberFormat.decimalPattern('es_CL');

    return Scaffold(
      appBar: AppBar(
        foregroundColor: Colors.black,
        elevation: 0,
        title: Text(data['nombre']), //Here i show the data from arguments.
        backgroundColor: Colors.white,
        centerTitle: false,

I think I should create a controller and make the data observable, but I'm not sure how I should receive the information from the stream to display later.

0 Answers0