River_pod: Unused overrides array is not emptied correctly

Created on 30 Aug 2020  路  1Comment  路  Source: rrousselGit/river_pod

Describe the bug
Suppose you create a ProviderScope with more than one override, like this:

ProviderScope(
    overrides: [
    scopedProviderA.overrideWithValue(
        ModelAl(),
    ),
    scopedProviderB.overrideWithValue('example text')
    ],
    child: const Child(),
)

Then after running, we get this error:

Updated the list of overrides with providers that were not overriden before
'package:riverpod/src/framework/container.dart':
Failed assertion: line 247 pos 9: 'unusedOverrides.isEmpty'

And I may be wrong, there may be other reasons, but basically if you look at that line in container.dart, you'll find an assert for unusedOverrides.isEmpty. The problem is that the assert is _within_ the loop on the unusedOverrides array. And I can't see how the array could be empty after the first iteration, if it contains more than one object? I see an inner loop that checks within the _children array, but it's always empty.

To Reproduce

Just create a ProviderScope and use more than one override, as per the lines of code above.

Expected behavior
Shouldn't throw exception when using more than one ScopedProvider override, probably by moving the isEmpty check outside of the loop.

bug

Most helpful comment

Thanks for the issue! I fixed the bug in 0.8.0

>All comments

Thanks for the issue! I fixed the bug in 0.8.0

Was this page helpful?
0 / 5 - 0 ratings