You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using lint rule always_specify_types together with depend_on_referenced_packages we are forced to add an import of package nested:
import 'package:nested/nested.dart';
to the file using a MultiProvider, to be able to specify the type of list with providers.
To Reproduce
To reproduce this issue you need the right linter combination, a sample repo with this it is provided further below. Sample is based on the Provider example.
import'package:flutter/foundation.dart';
import'package:flutter/material.dart';
// We have to add this import to be able to specify type <SingleChildWidget>// However, since we do not use and have nested in our pubspec, it triggers:// > The imported package 'nested' isn't a dependency of the importing package. depend_on_referenced_packages// lint rule, forcing us to also add `nested` to our pubspec to be able to commit code without lint rules triggered.import'package:nested/nested.dart';
import'package:provider/provider.dart';
voidmain() {
runApp(
MultiProvider(
// We cannot add the type <SingleChildWidget> without adding:// import 'package:nested/nested.dart';// above, but Nested is not used directly and we should not have to add it to our// pubspec or import it. It is not in pubspec in this example, the import// still works as it is in cached deps via Provider's transitive deps
providers:<SingleChildWidget>[
ChangeNotifierProvider<Counter>(
create: (BuildContext context) =>Counter(),
),
],
child:constMyApp(),
),
);
}
Expected behavior
Expect to be able to specify the type of a MultiProvider's list of providers as type <SingleChildWidget> without adding the package nested to pubspec.yaml or importing it in a file using Multiprovider.
Current choice of Provider not exporting SingleChildWidget forces us to also add package nested to our pubspec.yaml and import it in files using MultiProvider. This works, but is a bit of a dependency import smell.
Describe the bug
When using lint rule
always_specify_types
together withdepend_on_referenced_packages
we are forced to add an import of packagenested
:import 'package:nested/nested.dart';
to the file using a
MultiProvider
, to be able to specify the type of list withproviders
.To Reproduce
To reproduce this issue you need the right linter combination, a sample repo with this it is provided further below. Sample is based on the
Provider
example.Expected behavior
Expect to be able to specify the type of a
MultiProvider
's list ofproviders
as type<SingleChildWidget>
without adding the packagenested
to pubspec.yaml or importing it in a file usingMultiprovider
.Current choice of
Provider
not exportingSingleChildWidget
forces us to also add packagenested
to our pubspec.yaml and import it in files usingMultiProvider
. This works, but is a bit of a dependency import smell.Sample repo:
https://github.com/rydmike/multi_provider_issue
with needed lint combination to trigger the issue preconfigured.
The text was updated successfully, but these errors were encountered: