I updated Provider. Now it's not working
lib/di/global_providers.dart:13:6: Error: Type 'SingleChildCloneableWidget' not found. List globalProviders = [ ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/di/global_providers.dart:18:6: Error: Type 'SingleChildCloneableWidget' not found. List independentServices = [ ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/di/global_providers.dart:23:6: Error: Type 'SingleChildCloneableWidget' not found. List dependentServices = [ ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/main.dart:18:16: Error: The argument type 'List' can't be assigned to the parameter type 'List'. - 'List' is from 'dart:core'. - 'SingleChildWidget' is from 'package:nested/nested.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/nested-0.0.4/lib/nested.dart'). providers: globalProviders, ^ lib/di/global_providers.dart:13:6: Error: 'SingleChildCloneableWidget' isn't a type. List globalProviders = [ ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/di/global_providers.dart:18:6: Error: 'SingleChildCloneableWidget' isn't a type. List independentServices = [ ^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/di/global_providers.dart:23:6: Error: 'SingleChildCloneableWidget' isn't a type. List dependentServices = [
Code
List<SingleChildCloneableWidget> globalProviders = [
...independentServices,
...dependentServices,
];
List<SingleChildCloneableWidget> independentServices = [
Provider.value(value: YelloChatDb()),
Provider.value(value: YelloChatClient()),
];
List<SingleChildCloneableWidget> dependentServices = [
ProxyProvider<YelloChatDb, CategoryDao>(
update: (context, yelloChatDb, categoryDao) => CategoryDao(yelloChatDb)),
ProxyProvider<YelloChatDb, SubCategoryDao>(
update: (context, yelloChatDb,subCategoryDao) => SubCategoryDao(yelloChatDb)),
ProxyProvider<YelloChatDb, UserDao>(
update: (context, yelloChatDb, userdAO) => UserDao(yelloChatDb),
),
ProxyProvider<YelloChatDb, EnquiriesDao>(
update: (context, yelloChatDb, enquiriesDao) => EnquiriesDao(yelloChatDb),
),
ProxyProvider<YelloChatClient, CategoryService>(
update: (context, yelloChatClient, categoryService) =>
CategoryService.create(yelloChatClient.chopperClient),
dispose: (context, categoryService) => categoryService.client.dispose()),
ProxyProvider2<CategoryDao, CategoryService, CategoriesRepository>(
update: (context, categoryDao, categoryService, categoryRepository) =>
CategoriesRepository(categoryDao: categoryDao, categoryService: categoryService)),
ProxyProvider2<UserDao, CategoryService, UserRepository>(
update: (context, userDao, categoryService, categoryRepository)=>
UserRepository(userDao: userDao, categoryService: categoryService)
),
ProxyProvider2<SubCategoryDao, CategoryService, SubCategoriesRepository>(
update: (context, subCategoryDao, categoryService, subCategoryRepository) =>
SubCategoriesRepository(categoryDao: subCategoryDao, categoryService: categoryService)),
ProxyProvider2<EnquiriesDao, CategoryService, EnquiriesRepository>(
update: (context, enquiriesDao, categoryService, enquiriesRepository) =>
EnquiriesRepository(enquriesDao: enquiriesDao, categoryService: categoryService))
];
From Provider v4.0.0
The SingleChildCloneableWidget
interface is removed, and replaced by a SingleChildWidget
interface and two implementations:
MultiProvider
will accept a SingleChildWidget
instead of SingleChildCloneableWidget
.
See this issue in GitHub.
Try
import 'package:provider/single_child_widget.dart';
And Replace
List<SingleChildCloneableWidget> independentServices
with
List<SingleChildWidget> independentServices
It works. I have checked with dependency provider: ^4.3.2+3
To begin with, I would not recommend doing that. Consider creating this list directly inside your MultiProvider.
Doing what you're currently doing adds unnecessary complexity & ceremony for no real benefits. In fact you're actually decreasing testability.
If you insist on doing that though, the Readme is pretty clear about it:
Replace SingleChildCloneableWidget by SingleChildWidget (from provider/single_child_widget.dart)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With