I created a flutter app and Add Firebase to the app. I configure firebase according to the documentation of firebase. But when running the app, the app is working but in debugging, the console below error message shows. How I am going to fix this issue?
this the main.dart file
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
import './routes/chat_route.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home:ChatRoute() ,
);
}
}
This is the second warring message when I am trying to fetch data from firebase
This is the route I used to fetch data from firebase import 'package:flutter/material.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
class ChatRoute extends StatelessWidget {
ChatRoute({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Chat')),
body: StreamBuilder(
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(),
);
}
final documents = snapshot.data!.docs;
return ListView.builder(
itemCount: documents.length,
itemBuilder: ((ctx, index) => Container(
padding: const EdgeInsets.all(8),
child: Text(documents[index]['text']),
)));
},
stream: FirebaseFirestore.instance
.collection('chats/vpgBHNKfkqOGirS3S3BX/messages')
.snapshots(),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () {
FirebaseFirestore.instance
.collection('chats/vpgBHNKfkqOGirS3S3BX/messages')
.add({'text': 'This the dummy data'});
},
),
);
}
}

