Giter Site home page Giter Site logo

appsup-dart / firebase_dart Goto Github PK

View Code? Open in Web Editor NEW
92.0 8.0 30.0 1.67 MB

A pure Dart implementation of the Firebase client

License: Other

Dart 98.56% Java 0.91% Kotlin 0.01% Ruby 0.22% Swift 0.14% Objective-C 0.01% HTML 0.12% Shell 0.04%
dart firebase firebase-client

firebase_dart's Introduction

❤️ sponsor

A pure Dart implementation of the Firebase client

Consists of two packages:

Sponsor

Creating and maintaining this package takes a lot of time. If you like the result, please consider to ❤️ sponsor. With your support, I will be able to further improve and support this project. Also, check out my other dart packages at pub.dev.

Many thanks to Tim Whiting for his support.

firebase_dart's People

Contributors

aitaro avatar igokom avatar kevmoo avatar rbellens avatar timwhiting avatar tomassasovsky avatar xclud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

firebase_dart's Issues

Method reauthenticateWithCredential fails

Hi,

I am attempting to re-authenticate a user using the reauthenticateWithCredential(AuthCredential credential) method. While the method operates correctly, it fails in the method:

when attempting to return a result to the caller with the exception:

Illegal argument in isolate message: object is unsendable - Library:'package:rxdart/src/subjects/behavior_subject.dart' Class: BehaviorSubject (see restrictions listed at SendPort.send() documentation for more information)
<- _updates in Instance of 'FirebaseUserImpl' (from package:firebase_dart/src/auth/impl/user.dart)
<- operationTypeSignIn in Instance of 'UserCredentialImpl' (from package:firebase_dart/src/auth/impl/auth.dart)
<- Instance of 'ValueResult' (from package:async/src/result/value.dart)

flutter doctor -v

[✓] Flutter (Channel stable, 3.19.1, on macOS 12.6 21G115 darwin-x64, locale en-UA)
• Flutter version 3.19.1 on channel stable at /Users/...
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision abb292a07e (3 days ago), 2024-02-20 14:35:05 -0800
• Engine revision 04817c99c9
• Dart version 3.3.0
• DevTools version 2.31.1

UPD: seems this issue relates to this comment.

Auth persistence

Hi,

I have see that the credential persistence is not supported for now.

But, is there a way to implement it by ourself, or an alternative?

By example, if at some point we receive a token and later we can authenticate with this token (by example)?
In such case, we can store the token locally (and not the user/password by example)

[ SocketException: Failed host lookup] is occurring when we close our internet connection

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SocketException: Failed host lookup: 's-apse1a-nss-2005.asia-southeast1.firebasedatabase.app' (OS Error: No such host is known.

, errno = 11001)
#0 _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:694:35)
#1 _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1855:26)
#2 RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
#3 RawSecureSocket.startConnect (dart:io/secure_socket.dart:297:22)
#4 SecureSocket.startConnect (dart:io/secure_socket.dart:77:28)
#5 _ConnectionTarget.connect (dart:_http/http_impl.dart:2462:26)
#6 _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2906:12)
#7 _HttpClient._getConnection (dart:_http/http_impl.dart:2911:12)
#8 _HttpClient._openUrl (dart:_http/http_impl.dart:2766:12)
#9 _HttpClient.openUrl (dart:_http/http_impl.dart:2604:7)
#10 _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1021:42)
#11 WebSocket.connect (dart:_http/websocket.dart:320:22)
#12 new IOWebSocketChannel.connect (package:web_socket_channel/io.dart:80:28)
#13 connect (package:firebase_dart/src/database/impl/connections/protocol/websocket_io.dart:4:60)
#14 Transport.open (package:firebase_dart/src/database/impl/connections/protocol/transport.dart:34:32)
#15 Connection.open (package:firebase_dart/src/database/impl/connections/protocol/connection.dart:36:15)
#16 PersistentConnectionImpl._openNetworkConnection (package:firebase_dart/src/database/impl/connections/protocol/persistent_connection.dart:617:58)
#17 PersistentConnectionImpl._tryScheduleReconnect. (package:firebase_dart/src/database/impl/connections/protocol/persistent_connection.dart:586:13)

This error is occurring even if I'm not pushing any data on firebase . Called only two firebase method FirebaseDart.setup(isolated: true); , FirebaseStorage.instanceFor(app: _firebaseApp);

Database looses connection after approx. 70 seconds

After writing more than 2 entries into the database. Trying to do so again after more than 70 seconds - just nothing happens.
It is necessary to delete the FirebaseApp and reinitilize it again to be able to write.
What can be the problem here?

Tested with:
Dart SDK version: 2.19.4 (stable)
firebase_dart: ^1.0.11 & firebase_dart: ^1.1.0-dev.10

Example:

const configMB = FirebaseOptions(
    apiKey: 'XXXX-XXXXXX-VpFyS3bbNo',
    authDomain: 'XXXX-XXX.firebaseapp.com',
    projectId: 'XXX-XXX',
    messagingSenderId: 'XXXXXXXX',
    databaseURL: 'https://XXX-XXX.firebaseio.com',
    storageBucket: 'XXX-XXXX',
    appId: '1:XXXX:ios:442813749dccf0d1');


class TKDatabase {
  static Future<void> configureDatabases() async {
    FirebaseDart.setup();
    await Firebase.initializeApp(name: "mb", options: configMB);
  }

  static Future<void> reinitialize() async {
    await Firebase.app("mb").delete();
    await Firebase.initializeApp(name: "mb", options: configMB);
  }

  static FirebaseDatabase mb() => FirebaseDatabase(app: Firebase.app("mb"));
}


void main(List<String> arguments) async {
  await TKDatabase.configureDatabases();
  log('✅ Firebase Database connected.');

 // FAILING TEST
  TKDatabase.mb().reference().child('test/a').set({'test': 'test123'});
  TKDatabase.mb().reference().child('test/a').set({'test': 'test1234'});
  Timer.periodic(Duration(seconds: 70), (_) async {
    log('The following write is just IGNORED');
 
    TKDatabase.mb().reference().child('appconfig/test').set('test');
  });

// SUCCESSFUL TEST

  Timer.periodic(Duration(seconds: 70), (_) async {
    log('The following workaround works...');
  await TKDatabase.reinitialize();
    TKDatabase.mb().reference().child('appconfig/test').set('test');
  });
}

firestore support

I really like your work.
Do you have any plan to support firestore in the future?

Please upgrade to intl: ^0.19.0

Because Flutter 3.22.0 depends on intl: ^0.19.0 it is not possible to use firebase_dart which depend on intl: ^0.18.0
Could you please upgrade it?

version for browser

Currently only works on server as it depends on the WebSocket class in dart:io.

Create a Transport that works with the WebSocket class in dart:html.

Persistence is not working on windows

I'm calling _database.setPersistenceEnabled(true) and also called FirebaseDart.setup(storagePath: 'E:/firebasedart');
but whenever i'm calling ref() but this is not working
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Failed host lookup: 'firebasestorage.googleapis.com'
#0 IOClient.send (package:http/src/io_client.dart:88:7)

#1 Future.timeout. (dart:async/future_impl.dart:871:15)

#2 HttpClient.send (package:firebase_dart/src/storage/impl/http_client.dart:34:9)

#3 BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32)

#4 ResourceClient.multipartUpload (package:firebase_dart/src/storage/impl/resource_client.dart:127:20)

#5 UploadTaskImpl._oneShotUpload (package:firebase_dart/src/storage/impl/task.dart:334:23)

#6 UploadTaskImpl._start. (package:firebase_dart/src/storage/impl/task.dart:146:9)

#7 objectSynchronized. (package:synchronized/src/extension_impl.dart:37:18)

#8 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:33:16)

#9 objectSynchronized (package:synchronized/src/extension_impl.dart:34:12)

please correct me if I'm doing something wrong

auth with service account

Is there a way to auth using service account json file like node.js sdk does:

var admin = require('firebase-admin');

var serviceAccount = require('path/to/serviceAccountKey.json');

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: 'https://<DATABASE_NAME>.firebaseio.com'
});

I tried auth with secret key (the same way you do in auth test but added admin flag) and it worked, but I was not able to read data that has read rule set to false.

How to get lists from the database?

In the official firebase implementations, you can store Json lists (internally they are just recognized as Maps that have sequential numbering starting from zero). When attempting to do that with this library, I am able to save lists, but when reading them back, they end up as maps. This causes problems with json serialization libraries.

Any recommended way to approach this? Making everything maps is not the solution I'm looking for.

Handle errors

In example:

var ref = new Firebase("https://n6ufdauwqsdfmp.firebaseio-demo.com/");

  ref.child("test").onValue.listen((e) {
    print(e.snapshot.val);
  });

If there's no internet or url is invalid or child does not exists - how to catch error? Without it, library is useless. Currently, if no internet connection, listen is never executed, but I am unable to catch there was some error.

Problems with listing files from a bucket: Duplicate path parts

Hi,
I'm using this for an app that will predominantly run on a desktop (not mobile).
My files are stored in the default bucket, in a folder named audio at the root.

I can get all the files from that folder using a function like:

Future<ListResult> listAll() async {
  var app = await Firebase.initializeApp(
      options: FirebaseOptions.fromMap(json.decode(File('firebase-config.json').readAsStringSync()))
  );
  var storage = FirebaseStorage.instanceFor(app: app);
  var results = await storage.ref("audio").listAll();
  return results;
}

Note: Also tried with await.storage.ref().child('audio').listAll();

But when I loop the returning files, each one appears with the root folder "duplicated".
For example, the fullPath property of each Reference is audio/audio/file.mp3 instead of audio/file.mp3.
This results in a "file not found" when i'm trying to get a download url. The url comes as: gs://bucket-name.appspot.com/audio/audio/file.mp3 - with double audio/audio.

Update: I can get the right reference by doing something convoluted like: Reference? realItem = item.parent?.parent?.child(item.name); when looping the results, but that feels a bit off.

Any idea what I'm doing wrong?

Many thanks!

get() occasionally waits forever

I've been seeing an issue that pops up every once in a while. A get() on a piece of the database just waits forever and times out. All of the following get() calls do the same. We think that it might have something to do with re-authentication with a service account using the firebase_admin package

Failed assertion in tracked_query.dart: line 343 pos 12: 'existing == null || existing.id == query.id': is not true.

Running my flutter app in debug mode using firebase_dart 1.1.0-dev.10 sometimes the following error is thrown:

`[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:firebase_dart/src/database/impl/persistence/tracked_query.dart': Failed assertion: line 343 pos 12: 'existing == null || existing.id == query.id': is not true.
tracked_query.dart:343
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      TrackedQueryManager.cacheTrackedQuery
tracked_query.dart:343
#3      new TrackedQueryManager
tracked_query.dart:126
#4      new DefaultPersistenceManager
default_manager.dart:24
#5      BaseFirebaseDatabase.persistenceManager.<anonymous closure>
firebase_impl.dart:56
#6      DelegatingPersistenceManager.delegateTo
manager.dart:114
#7      DelegatingPersistenceManager.delegateTo (package:firebase_dart/src/database/impl/persistence/manager.dart)
manager.dart:1
#8      DelegatingPersistenceManager.serverCache
manager.dart:133
#9      SyncPoint.createMasterViewForFilter
synctree.dart:394
#10     SyncPoint.processNewQueries
synctree.dart:281
#11     SyncPoint.minimalSetOfQueries
synctree.dart:239
#12     SyncTree.handleInvalidPaths
synctree.dart:772
#13     new DelayedCancellableFuture.<anonymous closure>
utils.dart:246

The cause of this exception seems to be located in the storage file firebase-db-persistence-storage-.hive
Removing this file results in the assertion error not be thrown anymore.

Windows app stucked on release mode

Hello,

Everything work fine on debug mode, but when I build my app on release mode with the command "flutter build windows" and then run the .exe on the same computer, the app is stucked on a white screen.
It doesn't happen when I comment this line:

await Firebase.initializeApp(
    options: FirebaseOptions.fromMap(json
        .decode(File('example/firebase-config.json').readAsStringSync())));

I found a Stackoverflow issue with a similar problem: https://stackoverflow.com/a/69221938

The reason for not finding that in release mode can be one of the following,

You are using some dll (package that depends on a dll) that is available on a specific path in your system, but when you are release the app that (absolute) path is not valid anymore.

Thank you for you help and for this amazing package!

Can't find files when bucket is provided

When I try to instantiate the storage with a custom bucket a object not found error occurs when trying to upload or receive metadata, etc.

  var storage = FirebaseStorage.instanceFor(
          app: cloudStorageApp,
          bucket: 'gs://...'
        );

Error message:

flutter: [storage/object-not-found] Object 'path/to/object' does not exist.

I double checked that there is a file in the expected location in firebase console.
When I use the default bucket it works perfectly fine.

Please upgrade jose package

@rbellens,
Because of dependency on X.509 which was throwing warnings:

../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/x509_base.dart:176:59: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
                (sequence.elements[2] as ASN1OctetString).contentBytes()!),
                                                          ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/x509_base.dart:195:62: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
        algorithm, (sequence.elements[1] as ASN1OctetString).contentBytes()!);
                                                             ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/certificate.dart:137:19: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
      version = e.valueAsBigInteger!.toInt() + 1;
                  ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/certificate.dart:154:32: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
            ex = (ASN1Parser(o.contentBytes()!).nextObject() as ASN1Sequence)
                               ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/certificate.dart:164:52: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
        serialNumber: (elements[0] as ASN1Integer).valueAsBigInteger!.toInt(),
                                                   ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/extension.dart:47:54: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
            ASN1Parser(sequence.elements[octetIndex].contentBytes()!)
                                                     ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/extension.dart:355:16: Warning: Operand of null-aware operation '!' has type 'bool' which excludes null.
        cA = o.booleanValue!;
               ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/util.dart:39:50: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
  var privateKey = toBigInt(sequence.elements[1].contentBytes()!);
                                                 ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/util.dart:41:32: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
  var l = sequence.elements[1].contentBytes()!.length;
                               ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/util.dart:55:45: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
    var e = ASN1Parser(sequence.elements[i].contentBytes()!).nextObject()
                                            ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/util.dart:101:55: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
  var modulus = (sequence.elements[0] as ASN1Integer).valueAsBigInteger!;
                                                      ^
../../../../.pub-cache/hosted/pub.dev/x509-0.2.3/lib/src/util.dart:102:56: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
  var exponent = (sequence.elements[1] as ASN1Integer).valueAsBigInteger!;

firebase_dart also suffers from it.

Since jose has been already published by you (appsup-dart/jose#53) could you please also upgrade firebase_dart?
We'd also love to see intl and http packages upgraded.

Thank you in advance

signInWithCustomToken throws HandshakeException

When I try to authenticate using custom token, this line:

auth.signInWithCustomToken(customAuthToken)

throws:

HandshakeException: Handshake error in client (OS Error:
I/flutter (15029): 	CERTIFICATE_VERIFY_FAILED: certificate is not yet valid(handshake.cc:393))
I/flutter (15029): 	#0      _SecureFilterImpl._handshake (dart:io-patch/secure_socket_patch.dart:99:46)
I/flutter (15029): #1      _SecureFilterImpl.handshake (dart:io-patch/secure_socket_patch.dart:142:25)
I/flutter (15029): #2      _RawSecureSocket._secureHandshake (dart:io/secure_socket.dart:915:54)
I/flutter (15029): #3      _RawSecureSocket._tryFilter (dart:io/secure_socket.dart:1044:19)

could you please fix that?

Is persistence supported?

Does this package support offline storage for the realtime db? I set the desired persistence path, but it does not seem any files are written there, and if I try to get some data when I got no internet connection, the code is stock within the get method.

If this is not supported, what would be the preferred way to store the data and sync when going online again?

Thanks for your help!

How to do? Firestore Database

Hi, I'm New to this.

may I know how to push and fetch data To & From Firebase Database.

i tried but it doesn't works

 var ref = db.reference().child('test');
    await ref.set({
      'Value': {'One': 1, 'Two': 2, 'Three': 3}
    });
    await ref.set({'Box': json});
    await ref.update({"Box": json});

Thanks For Your Contribution.

any better documentation and samples?

It would be good if the makers of this were to do a video or something.
The sample is not working.
I find this not usable.

I can get firedart to work, but I guess this package has better support and is a newer and current fork.

On your package...
I'm able to setup and initialize but cannot do much else. Errors flow on sign in and when i comment out the user stuff errors flow when I ask for storage.

I assumed the file to initialize was a google-services.json, but that did not load from assets, so I manually added my options locally in code. That worked.. but cannot do anything else.

I should note that I'm using flutter 2.10.5 because of another project requires a downgrade.

Null check operator used on a null value?

just trying the library and I can't even get authenticated lol.

C:\Users\someUser\Desktop\dart\projects\firebase_test>dart run
Building package executable...
Built firebase_test:firebase_test.
Unhandled exception:
Null check operator used on a null value
#0      _processResponse (package:openid_client/src/http_util.dart:34:26)
#1      get (package:openid_client/src/http_util.dart:17:10)
<asynchronous suspension>
#2      Issuer.discover (package:openid_client/src/openid.dart:127:16)
<asynchronous suspension>
#3      Client.forIdToken (package:openid_client/src/openid.dart:151:18)
<asynchronous suspension>
#4      RpcHandler._credentialFromIdToken (package:firebase_dart/src/auth/rpc/rpc_handler.dart:245:9)
<asynchronous suspension>
#5      FirebaseAuthImpl.signInWithEmailAndPassword (package:firebase_dart/src/auth/impl/auth.dart:95:13)
<asynchronous suspension>
#6      main (file:///C:/Users/someUser/Desktop/dart/projects/firebase_test/bin/firebase_test.dart:18:14)
<asynchronous suspension>

what I have done:

  • created a user with email and password
  • tried to sign in

am I doing something incorrectly?

Future<void> main() async {
  FirebaseDart.setup(storagePath: 'storage');

  var app = await Firebase.initializeApp(
      options: FirebaseOptions.fromMap(
          json.decode(File('firebase-config.json').readAsStringSync())));

  var auth = FirebaseAuth.instanceFor(app: app);

  var user = await auth.signInWithEmailAndPassword(
      email: '[email protected]',
      password: 'someRandomPassword88');

  print(user.user?.email);
}

Add firestore support

Hi thank you for your package, I just wander if you going to firestore support in this package any time soon,
Thank you.

Decoded headers map from token doesn't contain kid key.

Hello and many thanks for this awesome package. I was trying to create to validate tokens sent from the client to my server. Using the package firebase_auth_admin_verify successfully verifies tokens generated from firebase_core and firebase_auth., but when I try with this package, it says No kid available.

Could you please assist me with pointing out this issue or if the problem is in the firebase_auth_admin_verify package?

import 'package:firebase_auth_admin_verify/firebase_auth_admin_verify.dart';
import 'package:firebase_dart/firebase_dart.dart';
import 'package:firebase_dart/implementation/testing.dart';
import 'package:test/test.dart';

void main() {
  test('verifies token successfully', () async {
    final token = await _getTestToken();
    final jwt = await verifyFirebaseToken(
      token,
      serviceFilePath: 'service-account.json',
      projectId: 'my_project',
    );
  });
}

Future<String> _getTestToken() async {
  await FirebaseTesting.setup();

  final app = await Firebase.initializeApp(
    options: FirebaseOptions(
        appId: 'my_app_id',
        apiKey: 'apiKey',
        projectId: 'my_project',
        messagingSenderId: 'ignore',
        authDomain: 'my_project.firebaseapp.com'),
  );
  var backend = FirebaseTesting.getBackend(app.options);

  final email = '[email protected]';
  final password = 'password';

  final user = await backend.authBackend.createUser(
    email: email,
    password: password,
  );

  // final token = await backend.authBackend.generateIdToken(uid: uid, providerId: providerId)
  var auth = FirebaseAuth.instanceFor(app: app);
  final cred = await auth.signInWithEmailAndPassword(
    email: email,
    password: password,
  );
  return await backend.authBackend.generateIdToken(
    uid: cred.user!.uid,
    providerId: cred.additionalUserInfo!.providerId!,
  );
}


How does this package store the signed in user?

I am trying to implement this library into my app and found something I don't understand:
When I sign in with email and password, I get back the UserCredentials.
Now the official Firebase auth package does not need any additional code to stay signed in. If I reload the app, I am still signed in.

When I use this package and reload after I signed in, it seems I am not anymore. Do I have to store something like a token after I sign in?

putData not working but not setting the metadata

putData() function when called on storage reference along by passing settablemetadata uploads the data but with no metadata.
Here is the code

UploadTask task = storage
      .refFromURL('location_url')
      .child('${map['id']}.mp4')
      .putData(uint8List, metadata);

Also no errors are being generated as I am also checking it afterwards

task.snapshotEvents.listen((event) {
    if (event.state == TaskState.error) {
      print('Some serious error is coming');
    } else {
      print('It works');
    }
  });

It works gets printed.
The code works on a flutter app but not inside the script.

Please upgrade to intl: ^0.18.0

Because Flutter 3.10.0 depends on intl: ^0.18.0 it is not possible to use firebase_dart which depend on intl: ^0.17.0
Could you please upgrade it?

Connection error doesnt respond as onError

WhatsApp Image 2022-01-30 at 23 40 20
WhatsApp Image 2022-01-30 at 23 37 48

Sometimes i get these errors while uploading data to firebase storage. However when i put UploadTask in try catch block, catch part doesnt work and also when i listen uploadtask onError part doesnt work too. For example it doesnt print "upload get err1 or err2".

try {
      uploadTask = ref.putData(File(file.filePath).readAsBytesSync());
      await uploadTask.snapshotEvents.listen((snapshot) {
        uploadingValue =
            ((snapshot.bytesTransferred / snapshot.totalBytes) * 100).toInt() /
                100;
        print('Progress: %${uploadingValue * 100}');
      }, onDone: () async {
        print("UPLOAD DONE!!!");
        print("uploadFail:$cloudFail");
        if (!cloudFail) {
          setState(() {
            uploaded = true;
          });
          await triggerStorageFiles();
          saveDb();
        }
      }, onError: (e) {
        print("upload get err1:$e");
        cancellUpload();
        cloudFail = true;
        saveDb();
      });
    } catch (e) {
      print("upload get err2:$e");
    }

By the way its happening while connected wifi. I dont get this err when i connected with cable.

Edit:
same error
Unhandled Exception: SocketException: OS Error: Operation timed out, errno = 60, address = firebasestorage.googleapis.com, port = 51294
its happening while uploading big file or 20-30 small files. So i think its becoming timed out with wifi connection. How can i fix it :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.