Click here to Skip to main content
15,878,970 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to save a bool value (The value is already made in my Firebase Realtime Database whith a default value of false), but when I save the value it doesn't save. I follow the videos I use their code examples (modified to work for my code ofc) but it still doesn't save...(The name of the Database is People and the value I want to change is called Joined so I'm referencing the database when I say People['Joined']):
//Reference Database
  Query dbRef = FirebaseDatabase.instance.ref().child('People');
  DatabaseReference reference = FirebaseDatabase.instance.ref().child('People');
//This is just a block with all the database's info
Widget listItem({
    required Map People,
  }) {
    //shared Preferences start
      savebool() async {
      SharedPreferences prefs = await SharedPreferences.getInstance();
      await prefs.setBool("People['Joined']", true);
    //shared prefs end
    return Slidable(
      startActionPane: ActionPane(
        motion: const BehindMotion(),
        extentRatio: 1 / 5,
        children: [
            icon: Icons.add,
            label: 'Join',
            onPressed: (BuildContext context) {
              setState(() {
                //change value from false to true
                People['Joined'] = true;
              //now i save it
              //but when I refresh it didn't save//

What I have tried:

I tried adding the getbool and super.initsate but I'm still struggling to add that code into my code, because it keeps brining up errors. If you know how to add the code in the context of my code, help will be greatly appreciated.
wseng 19-Mar-23 2:57am    
what errors?

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