samedi 5 février 2022

How to move data across different dart classes

I have a layered flutter application with object box database. The database has the capability to emit data using stream whenever any database change happens. My class structure is as shown below.


class UserRepo {
  
  void createSubscription() {
    // method to get stream from database
    //Stream stream = _database.getUser();
  }  
}


class RepoHandler {
  
  // select repo
  // get data from repo
  
}


class BusinessLogic {
  
  // get user
  // do something

  // get another data
  // combine another class to get modified user

}


class UIController {
  
  // get modified user from business logic
  // has stream 
  
}


class UI {
  
  // get user from UI controller
  // consumes UI controller stream and uses stream builder
  
}

At the business logic, different models are combined to create view models which is fed to controller and ultimately to UI.

Earlier, we were fetching simple dart models from database. Now the requirement changed to get the changes realTime. I am not sure how to use the stream at the repo class to bring the data all the way down to the UIController class. The dart models change at every layer. Can someone please guide me here. Thanks.

Aucun commentaire:

Enregistrer un commentaire