I use Flutter's official approach.

How to create a view model

Pillars of this approach.

  1. View model
    1. State manager of a widget
    2. The only fields of a view model can be it's state and repositories
    3. Functions of a view model serve as the public API that the widget can use
    4. Implementation in the functions of view models should only be calling repository functions and manipulation of state
  2. State
    1. Stores any sort of data passed to the view model via constructor and the mutable data (state) of the view model
  3. Repository
    1. Implementation layer of a view model
    2. Try to write all implementation used by view model functions within repository functions
  4. Service
    1. API calls
  5. Result model
    1. Model used to represent a result of a service