I am having a problem with real time database not working, I copied a project from GitHub and made a new project in firebase with my app ID, added the JSON file to my app and changed the write and read rules to true but still not working or showing anything in the terminal
source code :
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class CustomData extends StatefulWidget {
CustomData({this.app});
final FirebaseApp app;
@override
_CustomDataState createState() => _CustomDataState();
}
class _CustomDataState extends State<CustomData> {
final refrenceDatabase = FirebaseDatabase.instance;
final MovieController = TextEditingController();
@override
Widget build(BuildContext context) {
final ref = refrenceDatabase.reference();
return Scaffold(
appBar: AppBar(title: Text('Real Time DataBase'),backgroundColor: Colors.red,),
backgroundColor: CupertinoColors.systemGrey,
body: SingleChildScrollView(
child: Column(children: [
Center(child:
Container(
color: Colors.blue,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Column(
children: [
Text('Movie title',style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), textAlign: TextAlign.center,),
TextField(controller: MovireController, textAlign: TextAlign.center,),
FlatButton(
color: Colors.orange,
onPressed: (){
ref.child('Movies').push().child('movie title').set(MovieController).asStream();
}, child: Text('Submit'))
],
),
),)
],),
),
);
}
}
Database rules:
{
"rules": {
".read": true, // 2021-3-23
".write": true, // 2021-3-23
}
}
google-services.jsonfile properly and well, has it been connected to Firebase Analytics or any other firebase service properly? Are you receiving any error?google-services.jsonin the proper place underapp, I also added the database rules. @Preet Shah