Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ProviderScope not defined issue

I am trying to migrate an old Flutter project to Null Safety.

This is the main.dart code:

import 'dart:async';
import 'dart:convert';

import 'package:capenergy_ns/pantallas/my_home_screen.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:riverpod/riverpod.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:splashscreen/splashscreen.dart';

import 'constantes/constantes.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SharedPreferences prefs = await SharedPreferences.getInstance();
  var email = prefs.getString('email');

  runApp(
    ProviderScope(
      child: EasyLocalization(
          path: "assets/translations",
          saveLocale: true,
          supportedLocales: [Locale('en', 'EN'), Locale('es', 'ES')],
          child: MaterialApp(
              debugShowCheckedModeBanner: false,
              localizationsDelegates: [
                GlobalMaterialLocalizations.delegate,
                GlobalWidgetsLocalizations.delegate,
              ],
              supportedLocales: [
                const Locale('es', 'ES'),
                const Locale('en', 'EN'),
              ],
              home: email == null || email == '' ? Splash2() : MyHomePage())),
    ),
  );
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Capenergy',
      theme: ThemeData(
        backgroundColor: Colors.white,
      ),
      home: MyHomePage(),
    );
  }
}

My current issue is that the line ProviderScope( is marked as error with this explanation:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The function 'ProviderScope' isn't defined

I think ProviderScope belongs to the package Riverpod, which is already installed.

What am I doing wrong?

>Solution :

And flutter_riverpod on pubspec.yaml, and import package:flutter_riverpod.

import 'package:flutter_riverpod/flutter_riverpod.dart';
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading