前提
Riverpodの勉強をしていたのですが、ProviderScopeを実装(定義?)したところエラーが発生しました。(エラーメッセージ欄に記載)
flutter pub add riverpod
を実行後、pubspec.yamlの
dependencies:
riverpod: ^2.1.1
が追記されてあることを確認後、一応flutter pub getを実行し
import 'package:riverpod/riverpod.dart';
を記載しました。
何が足りないのでしょうか?
以下参考にしたサイト
https://pub.dev/packages/riverpod
https://www.flutter-study.dev/firebase-app/riverpod
https://zenn.dev/kiiimii/articles/e588de0513c22d(もともとはflutter_screenutilを使いたかったので先のサイトも参考にしました)
エラーメッセージ
Try importing the library that defines 'ProviderScope', correcting the name to the name of an existing function, or defining a function named 'ProviderScope'.
該当のソースコード
Dart
1import 'package:riverpod/riverpod.dart'; 2 3void main() async { 4 runApp( 5 ProviderScope( 6 child: MyApp(), 7 ), 8 ); 9}
試したこと
pubspec.yaml に記載したdependencies:を riverpod: ^2.1.1からflutter_riverpod: ^2.0.0-dev.9に変更してflutter pub getを実行したが変わらずエラーのままでした。(riverpodとflutter_riverpodのちがいはわかってはいませんが。。。)
補足情報(FW/ツールのバージョンなど)
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0.1 22A400 darwin-arm, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.73.0)

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/11/13 06:50