No type arguments expected for class Flow

I encountered a problem with Kotlin Flow.

I copied the following code code from the Official guide

fun simple(): Flow<Int> = flow { for (i in 1..3) { delay(100) emit(i) }
}

But the Android Studio prompts a following error:

No type arguments expected for class Flow

What am I doing wrong?

1 Answer

Make sure you use import kotlinx.coroutines.flow.Flow not java.util.concurrent.Flow, it gives you this error because Java concurrent Flow class take 0 type arguments, but Coroutines Flow take one

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like