'Error: could not find the correct Provider<List<Parking>> above this ParkingList Widget
import 'package:flutter/material.dart';
import 'package:flutter_user_profile/home/parking_tile.dart';
import 'package:provider/provider.dart';
import 'parking_tile.dart';
import '../model/parking.dart';
class ParkingList extends StatefulWidget {
  
  @override
  State<ParkingList> createState() => _ParkingListState();
}
class _ParkingListState extends State<ParkingList> {
  @override
  Widget build(BuildContext context) {
    final parkings = Provider.of<List<Parking>>(context);
    return ListView.builder(
      itemCount: parkings.length,
          itemBuilder: (context,index){
        return ParkingTile(parking: parkings[index]);
    },
    );
    return Container();
  }
}
And heres my coding for main.dart file
import 'package:flutter_user_profile/services/auth.dart';
import 'package:provider/provider.dart';
import 'package:flutter_user_profile/model/user.dart';
Future <void> main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
      options: FirebaseOptions(apiKey: "AIzaSyD59Nz0y4Z8S-rVpeu5E5lslsW_8WYrEiE",
          appId: "XXX", messagingSenderId: "XXX", projectId: "parkingtech-f1449") );
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return StreamProvider<Client?>.value(
        initialData: null,
      value: AuthService().user,
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
      home: Wrapper(),
    )
    );
  }
}
when I run the app it could not find the correct provider and I'm not sure how to solve this,I've tried most of the solution but it seems that I still cant find the right way to do it. I'm still new to flutter please help
Solution 1:[1]
Have you registered this Parking in your main.dart ? If didn't, look at the mine answer.. Thanks
Solution 2:[2]
You have to wrap you main app (parent class) with a provider (depending on the use case)!
Please check out the official documentation of Provider package to understand how to add a provider in the main app.
Link to the original package on pub: https://pub.dev/packages/provider
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | |
| Solution 2 | Milton | 
