title: How to initialize a flow in viewmodel with a suspend function as parameter
body: <p>I am working with room database and datastore .
  Here is my code</p>
  <p>ViewModel</p>
  <pre><code>@HiltViewModel
  class SubscriptionViewModel @Inject constructor(
      private val userDataStore: UserDataStore,
      private val walletDao: WalletDao
  ) : ViewModel() {
  
  val flow: Flow&lt;List&lt;Transaction&gt;&gt; = walletDao.getAllTransactions(userDataStore.getId()) 
   // This shows an error as userDataStore.getId() is a suspend function in DataStore
  
  
   init {
          viewModelScope.launch(IO) {
              getWalletAmount()
          }
      }
  }
  </code></pre>
  <p>DataStore</p>
  <pre><code> suspend fun getId(): String {
          val preferences = dataStore.data.first()
          return preferences[USER_ID] ?: &quot;&quot;
      }
  </code></pre>
  <p>WalletDao</p>
  <pre><code> @Query(&quot;SELECT * FROM recent_transactions where user_id=:user_id&quot;)
      fun getAllTransactions(user_id: String): Flow&lt;List&lt;Transaction&gt;&gt;
  </code></pre>
  <p>The problem is I am unable to initialise the flow. I tried initialising it in the init{ } block using lateinit , but while accessing in the fragment it crashes saying flow has not been initialised.</p>
  <p>Any solution would help.</p>