Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 607
巴赫哥德尔 Avatar asked Sep 12 '25 12:09

巴赫哥德尔


1 Answers

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

like image 81
AmrDeveloper Avatar answered Sep 14 '25 06:09

AmrDeveloper