Describe the bug
I am not sure this is a Flutter bug or Riverpod bug.
When using StateNotifierProvider.family.autoDispose, it causes a grey screen on Flutter Web. Only happens on Release build, Debug is fine. If I don't use autoDispose it is also fine. I think I didn't experience this before the family.autoDispose style new syntax. My current work-around is not to use autoDispose.
I get this on the web console:
Another exception was thrown: Instance of 'minified:iu<void>'
Possibly related:
In my case, it was an static method uninitialized unexpectedly that triggered this issue. Seems like a webdev bug , only failed on web release build.
To Reproduce
StateNotifierProvider.family.autoDisposeRegards
Using:
Flutter 1.21.0-1.0.pre • channel dev • https://github.com/flutter/flutter.git
Framework • revision f25bd9c55c (3 weeks ago) • 2020-07-14 20:26:01 -0400
Engine • revision 99c2b3a245
Tools • Dart 2.9.0 (build 2.9.0-21.0.dev 20bf2fcf56)
This is a bug in dart2js https://github.com/dart-lang/sdk/issues/41449
Try upgrading your sdk to the latest version possible
I will close this as it isn't an issue with Riverpod but the Dart SDK. If the issue persists, ping the Dart team on https://github.com/dart-lang/sdk/issues/41449
Has anyone found a workaround or found a version that is compatible with StateNotifier on web? I'm on a pretty recent version (1.22.0-1.0.pre) but I am still having the exceptions.
I saw a comment here https://github.com/dart-lang/sdk/issues/41449#issuecomment-655654274 but was unable to get my build working properly. I may not be understanding their exact recommendation though.
Great, thanks!
Edit confirming your workaround also worked for me. Assigning X.autoDispose.family to variables and using them worked for me. For example:
```dart
final providerAutodisposeFamily = Provider.autoDispose.family;
final _paginatedMessageListProvider =
providerAutodisposeFamily
final auth = ref.watch(_authServiceProvider);
final api = ref.watch(_apiProvider);
final fileUploadService = ref.watch(_fileUploadServiceProvider);
return PaginatedMessageList(
api: api,
auth: auth,
fileUploadService: fileUploadService,
chatId: chatId,
);
});
`
Most helpful comment
Has anyone found a workaround or found a version that is compatible with StateNotifier on web? I'm on a pretty recent version (1.22.0-1.0.pre) but I am still having the exceptions.
I saw a comment here https://github.com/dart-lang/sdk/issues/41449#issuecomment-655654274 but was unable to get my build working properly. I may not be understanding their exact recommendation though.