所以我开始使用RiverPod。在尝试读取context.read(myProvider)时,我收到以下消息:
Too many positional arguments: 0 expected, but 1 found.
我使用的是flutter_riverpod:^0.14.0+3
转到read函数定义-我转到具有以下函数的provider.dart文件:
T read<T>() {
return Provider.of<T>(this, listen: false);
}
我目前正在尝试使用颤振的河运舱进行研究,但是当我尝试放置flutter_riverpod包时,我遇到了一个问题,我得到了这个错误
Because riverpod depends on flutter_riverpod ^0.9.1 which depends on riverpod ^0.8.0, riverpod ^0.8.0 is required.
So, because riverpod is 1.0.0+1, version solving failed.
Running "flutter pub get" in riverpod...
pub get failed
我是Flutter的初学者,我正在尝试使用Riverpod。以下是示例代码
导入"package:flutter_riverpod/flutter_riverpod.dart";
class CounterNotifier extends ChangeNotifier {
int _value = 0;
int get value => _value;
void incrementValue() {
_value++;
notifyListeners();
}
}
但是我有错误,我找不到这样的ChangeNotifier和notifyLi
我想在Flutter应用程序StartUp上调用我的Remote Config实例,我已经按如下方式设置了Riverpod class ConfigService {
// Will Initialise here
final RemoteConfig _remoteConfig;
ConfigService(this._remoteConfig);
Future<void> initialise() async {
...// Will fetchAndActivate
}
final remoteConfigProvider = Provider<
我试着用以前的版本取代了riverpod的版本,但是没有什么效果。我也尝试过删除pubspec.lock文件,运行颤振清除命令等,但是没有任何效果。如果任何人谁使用的颤振2.2.2是能够使用河荚(任何版本),那么请帮助。
pubspec.yaml文件:
name: riverpod
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is pre
今天,当我编译我的flutter项目时,操作系统是macOS Big Sur,显示的错误如下: ../../../.pub-cache/hosted/mirrors.tuna.tsinghua.edu.cn%2547dart-pub/riverpod-1.0.0-dev.10/lib/src/async_value_converters.dart:223:39: Error: The method 'ignore' isn't defined for the class 'Future<State>'.
- 'Future'
我想上一堂课,把类似的方法放在一起。
Riverpod使用的是ref,它只能通过扩展获得,但是如何在没有任何扩展和构建方法的裸类中使用它。
模型
class User {
final String uid;
final String username;
final String email;
User({required this.uid, required this.username, required this.email});}
StateNotifier
import 'package:flutter_riverpod/flutter_riverpod.dart';
我有一个家庭参数的FutureProvider,如下所示:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class I_Rem_Params {
final String adminID;
final String companyID;
final int month;
I_Rem_Params(
{required this.adminID, requi
我正在尝试安装flutter_riverpod,但是它通过遵循安装软件包的正常方法给出了这些错误消息。那是来自pub.dev的
我在我的依赖项下添加了flutter_riverpod: ^1.0.4,但是给出了一个错误:
Because riverpod depends on flutter_riverpod ^1.0.4 which depends on riverpod 1.0.3, riverpod 1.0.3 is required.
So, because riverpod is 1.0.0+1, version solving failed.
pub get failed (1;
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:hooks_riverpod
- package:flutter_riverpod
- package:riverpod 我不明白,这些包不应该有这个问题,他们是空安全的。 当我运行flutter run --no-sound-null-safety时,会得到一堆错误,从下面这个开始: /D:/src/flutter/.pub-cache/hosted
我正在将我的应用程序移植到使用flutter_riverpod包。目前,我的应用程序正在使用provider包来管理/处理app状态。
在以BuildContext作为输入的多个实用程序类中有许多静态方法。我使用上下文访问提供程序,它允许我读取和修改状态:
// This relies on the provider package
abstract class SomeRandomUtilityClass {
static FutureOr<String?> redirect(BuildContext context) {
bool isSignedIn = con
有什么问题吗?我不能用这种方法。
错误码Too many positional arguments: 0 expected, but 1 found. Try removing the extra arguments.
在stat_managerment.dart中,我使用了这种方法。
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
final userLogged = StateProvider
在我的Flutter应用程序中,我必须在推送通知到达时立即更新提供者持有的状态,以便可以重建UI。PushNotifications服务是一个类(而不是小部件),如下所示:
class PushNotifications {
...
Future<void> init() async {
_firebaseMessaging.configure(onMessage: (Map<String, dynamic> data) {
// here I receive the data from the notification that