River_pod: Export implementation classes such as AutoDisposeFutureProvider

Created on 11 Sep 2020  路  3Comments  路  Source: rrousselGit/river_pod

Describe the bug
In hooks_riverpod: ^0.9.2, I am attempting to create a AutoDisposeFutureProvider and all works fine if we didn't defined the AutoDisposeFutureProvider type.

But if I deciared AutoDisposeFutureProvider type, auto import package:riverpod/src/future_provider.dart and run flutter analyze command, the flutter compiler will get Don't import implementation files from another package. warning.

To Reproduce

/// will show "Don't import implementation files from another package." warning
import 'package:riverpod/src/framework.dart';
import 'package:riverpod/src/future_provider.dart';

Future<String> test = Future<String>.delayed(const Duration(seconds: 3), () {
  return 'testing';
});

/// `AutoDisposeFutureProvider` and `AutoDisposeProviderReference` doesn't show in the `riverpod.dart`
final AutoDisposeFutureProvider<String> testProvider =
    FutureProvider.autoDispose((AutoDisposeProviderReference ref) async {
  return await test;
});

Expected behavior

I have noticed that the package:riverpod/riverpod.dart have export src/future_provider.dart but only show FutureProvider. Maybe we should export all all necessary files such as AutoDisposeFutureProvider and AutoDisposeProviderReference.

enhancement

Most helpful comment

Currently, classes like AutoDisposeProvider & co are not exported to avoid polluting the auto-complete

Maybe we could have package:riverpod/all_providers.dart or something similar for those who wants to use always_specify_type.

All 3 comments

@ininmm I wonder. Have you same problem with this exempel?

Future<String> test = Future<String>.delayed(const Duration(seconds: 3), () {
  return 'testing';
});

锘縡inal testProvider = FutureProvider.autoDispose((ref) async {
  return ref.watch(test);
});

@iamarnas The argument should give a Provider instead of a Future.

Currently, classes like AutoDisposeProvider & co are not exported to avoid polluting the auto-complete

Maybe we could have package:riverpod/all_providers.dart or something similar for those who wants to use always_specify_type.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

venkatd picture venkatd  路  6Comments

0biWanKenobi picture 0biWanKenobi  路  5Comments

hayatae picture hayatae  路  7Comments

campanagerald picture campanagerald  路  9Comments

smiLLe picture smiLLe  路  3Comments