Supabase resets after App Reload

Database & APIs

Hi FlutterFolks ; ),

I'm having a little issue:

I'm building a quiz app, and I'm trying to implement a currency/score system where the user would get a score for a correct answer. I'm using the code below to increase the score, the +1 value is then being passed to Supabase, however, once user reloads the app and gets a +1 score - the score resets to 0 both in app and in Supabase row.

// Automatic FlutterFlow imports
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'dart:math';

int _number =
    0; // Define a global variable to preserve the number between function calls

Future<int> incBy1() async {
  _number++; // Increase the number by 1
  return _number; // Return the increased number
}

I would love your suggestions how can I make the score to survive an app reload, thank you!

What have you tried so far?

Chatted with ChatGPT, looked through community posts, but I'm new and I suck a little.

Did you check FlutterFlow's Documentation for this topic?
Yes
2
6 replies