简体   繁体   中英

Flutter Firebase Database Class in multiple files

I have a big project and manage a lot of data with firebase. For this I have a class "MyFirestoreDatabase" in which I have every single firebase function, which I then call from my providers.

The problem is, that the MyFirestoreDatabase class has gotten really really big and I would want to split it up into sub classes and different files .

Every time I call a firebase function I use MyFirestoreDatabase.instance.functionName(), so I don't think I want different classes, because then I would have multiple instances of the database open at the same time right?

Would it work to extend the class?

Calling FirebaseFirestore.instance always returns the same (default) instance, no matter how many times you call it. This is the essence of the singleton pattern .

So calling it in each separate class won't make any change in resource consumption, nor in the number of connections to the backend servers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM