I want to send a specific value 0 or 1 when I click onPressed.

Here is my code:

openGatePhoto() async {
    await Firebase.initializeApp();

    DatabaseReference referenceData =
        FirebaseDatabase.instance.reference().child("picture_has_changed");
    var picture_has_changed;
    if (picture_has_changed == 0) {
      picture_has_changed = 1;
    } else {
      picture_has_changed = 0;
    }

When trying importing the package import 'package:firebase_database/firebase_database.dart'; this error occurred:

Target of URI doesn't exist: 'package:firebase_database/firebase_database.dart'.

It displays that Undefined class 'DatabaseReference' and Undefined name 'FirebaseDatabase'. I have looked up and it said that it maybe because of my version of image core and firebase storage, and when I tried to update them

firebase_core : ^1.0.0
  image_picker: ^0.6.2
  firebase_storage: ^8.0.0

This error occurred:

Because firebase_storage >=8.0.0 <8.0.1 depends on firebase_storage_web ^1.0.0 and firebase_storage >=8.0.1 <8.0.2 depends on firebase_storage_web ^1.0.2, firebase_storage >=8.0.0 <8.0.2 requires firebase_storage_web ^1.0.0.

And because firebase_storage >=8.0.2 <8.0.4 depends on firebase_storage_web ^1.0.3, firebase_storage >=8.0.0 <8.0.4 requires firebase_storage_web ^1.0.0.

And because firebase_storage >=8.0.4 <8.0.5 depends on firebase_storage_web ^1.0.4 and firebase_storage >=8.0.5 <8.0.6 depends on firebase_storage_web ^1.0.5, firebase_storage >=8.0.0 <8.0.6 requires firebase_storage_web ^1.0.0.

And because firebase_storage >=8.0.6 depends on firebase_storage_web ^1.0.6 which depends on http ^0.13.0, firebase_storage >=8.0.0 requires http ^0.13.0.

So, because LPP depends on both http ^0.12.0+2 and firebase_storage ^8.0.0, version solving failed.
pub get failed (1; So, because LPP depends on both http ^0.12.0+2 and firebase_storage ^8.0.0, version solving failed.)

What I only want to do is when you press the button it will send 0 or 1 to the realtime database on firebase. Is there an easier method than this what I have tried. Thanks in advance :D


Solution 1: That Guy

You have to make sure all your packages are compatible with one another. These are the latest compatible versions:

cloud_firestore ^0.16.0+1
cloud_functions ^0.9.0
firebase_auth   ^0.20.1
firebase_core   ^0.7.0
firebase_crashlytics    ^0.4.0+1
firebase_storage    ^7.0.0
firebase_messaging  ^8.0.0-dev.15
firebase_remote_config  ^0.8.0-dev.0

Here's the guide: https://firebase.flutter.dev/docs/migration/