Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have firebase realtime database. When I manually change data on the Firebase console, vscode stops responding and throws the following error.

Error: TypeError: Instance of '_Exception': type '_Exception' is not a subtype of type 'JavaScriptObject'


Main.dart:

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:realtimedbtest/firebase_options.dart';


String result = "";

void main()  async { 
WidgetsFlutterBinding.ensureInitialized(); 
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,   
 );

DatabaseReference ref = FirebaseDatabase.instance.ref('widget/image/name'); 
ref.onValue.listen((DatabaseEvent event)     { 
result =   event.snapshot.value.toString();
});

runApp(const MainApp());
}

class MainApp extends StatelessWidget {
 const MainApp({super.key});

@override
  Widget build(BuildContext context) {
   return  MaterialApp(
    home: Scaffold(
      body: Center(
       child: Text("result: $result"),
      ),
     ),
   );
  }
}


What I have tried:

I put async

DatabaseReference ref = FirebaseDatabase.instance.ref('widget/image/name'); 
ref.onValue.listen((DatabaseEvent event) async { //<-- I put async here.
result = event.snapshot.value.toString();
});
Posted
Comments
wseng 15-Apr-24 2:00am    
error pointed on which line?
gacar 15-Apr-24 16:03pm    
The error is not received on any line. After running, the application stops responding and this error message appears in debug console.
gacar 15-Apr-24 16:06pm    
Actually this is a bug. I wrote the error on the firebase github page. It is currently being examined there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900