title: Flow exception transparency is violated : Emission from another coroutine is detected
body: <p>I'm tring to implement NetworkBoundResource class in my project and this is what i'm trying. Everything work correctly getting response, caching but when im emiting value inside flowBuilder then it crashes and showing this error.</p>
  <p>error i'm getting:</p>
  <pre><code>    Emission from another coroutine is detected.
      Child of ProducerCoroutine{Active}@df26eb9, expected child of FlowCoroutine{Active}@a0bb2fe.
      FlowCollector is not thread-safe and concurrent emissions are prohibited.
      To mitigate this restriction please use 'channelFlow' builder instead of 'flow')' has been detected.
                    Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.
                    For a more detailed explanation, please refer to Flow documentation.
  </code></pre>
  <p>NetworkBoundResource class:</p>
  <pre><code>
  abstract class NetworkBoundResource&lt;ResultType, RequestType&gt; {
  
      fun invoke(): Flow&lt;Resource&lt;ResultType&gt;&gt; = flow {
          val rawData = loadFromDb()
  
          if (shouldFetch(rawData)) {
              fetchDataFromServer()
                  .onStart { emit(Resource.loading(rawData)) } // emit() causing issue
                  .catch { emit(Resource.error(it, null)) } // emit() causing issue
                  .collectLatest { }
          }
      }
  
      // Save API response result into the database
      protected abstract suspend fun cacheInDb(items: RequestType)
  
      // Need to fetch data from server or not.
      protected abstract fun shouldFetch(data: ResultType?): Boolean
  
      // Show cached data from the database.
      protected abstract suspend fun loadFromDb(): ResultType
  
      // Fetch the data from server.
      protected abstract suspend fun fetchDataFromServer(): Flow&lt;ApiResponse&lt;List&lt;Category&gt;&gt;&gt;
  
      // when the fetch fails.
      protected open fun onFetchFailed() {}
  }
  </code></pre>
  <p>Repository class:</p>
  <pre><code>    fun getCategories(): Flow&lt;Resource&lt;List&lt;Category&gt;&gt;&gt; {
          return object : NetworkBoundResource&lt;List&lt;Category&gt;, List&lt;Category&gt;&gt;() {
  
              override suspend fun cacheInDb(items: List&lt;Category&gt;) {
                  withContext(Dispatchers.IO) { database.getCategories().insert(items) }
              }
  
              override fun shouldFetch(data: List&lt;Category&gt;?): Boolean {
                  return true
              }
  
              override suspend fun loadFromDb(): List&lt;Category&gt; {
                  return withContext(Dispatchers.IO) { database.getCategories().read() }
              }
  
              override suspend fun fetchDataFromServer(): Flow&lt;ApiResponse&lt;List&lt;Category&gt;&gt;&gt; {
                  return flow { emit(RetrofitModule.getCategories()) }
              }
  
          }.invoke()
      }
  </code></pre>
  <p>myViewModelClass:</p>
  <pre><code>    init {
          viewModelScope.launch {
              repository.getCategories().collectLatest {
                  if(it.data!=null){
                      _categories.value = it.data
                      Log.d(&quot;appDebug&quot;, &quot; ViewModel : $it&quot;)
                  }
              }
          }
      }
  </code></pre>