巴赫哥德尔
巴赫哥德尔

Reputation: 343

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?

Upvotes: 24

Views: 8977

Answers (1)

AmrDeveloper
AmrDeveloper

Reputation: 4682

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

Upvotes: 118

Related Questions