Question
verify this code is working and verify data in firebase 1. configure firebase in firbase website and your application ( https://www.youtube.com/watch?v=fxDusoMcWj8&ab_channel=CodingWithTea if u find error
verify this code is working and verify data in firebase
1. configure firebase in firbase website and your application ( https://www.youtube.com/watch?v=fxDusoMcWj8&ab_channel=CodingWithTea
if u find error make sure pubspec.yahl has :
cloud_firestore: ^3.5.1 firebase_core: ^1.24.0 firebase_core_platform_interface: 4.5.1 firebase_crashlytics: ^2.9.0 firebase_remote_config: ^2.0.20 firebase_messaging: ^12.0.3 2. use this code and make it work
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; import 'package:flutter/material.dart';
Future
class MyApp extends StatelessWidget { const MyApp({super.key});
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( //add data to firebase floatingActionButton: FloatingActionButton( backgroundColor: Colors.green, child: Icon(Icons.add), onPressed: () { FirebaseFirestore.instance.collection('test').add({ 'ID': 2, 'class': '313cis', 'name': 'Huda', }); }, ), appBar: AppBar( title: Text('Title test'), ), body: ClassList(), ), ); } }
class ClassList extends StatefulWidget { const ClassList({super.key});
@override State
class _ClassListState extends State
return ListView( children: snapshot.data!.docs.map((document) { return Column( children: [ Container( child: Center(child: Text(document['ID'].toString())), ), Container( child: Center(child: Text(document['name'])), ), Container( child: Center(child: Text(document['class'])), ), ], ); }).toList(), ); }, ), ); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started