rrousselGit / provider

InheritedWidgets, but simple
https://pub.dev/packages/provider
MIT License
5.11k stars 512 forks source link

Null check operator used on a null value #864

Closed ezrac0des closed 8 months ago

ezrac0des commented 8 months ago

This used to work completely great. However, when I opened my app today I started getting the error below:

======== Exception caught by widgets library =======================================================
The following _TypeError was thrown building Consumer<UserModal>(dirty, dependencies: [MediaQuery, _InheritedProviderScope<UserModal?>]):
Null check operator used on a null value

The relevant error-causing widget was: 
  Consumer<UserModal> Consumer:

The error points to the return Consumer<UserModal>(builder: (context, modal, child) { line

  @override
  Widget build(BuildContext context) {
    Responsive responsive = Responsive(context);
    GlobalKey<FormState> basicFormKey = GlobalKey<FormState>();
    return Consumer<UserModal>(builder: (context, modal, child) {
      return SafeArea(
        child: SingleChildScrollView(
          child: Column(
          ),
        ),
      );
    });
  }

And my UserModal looks as below

import 'package:flutter/foundation.dart';

class UserModal extends ChangeNotifier {
  String? name;
  String? lastName;
  String? email;
  String? password;
  String? phoneNumber;
  String? career;
  String? country;
  String? birthdate;
  String? sex;

  int activeIndex = 0;
  int totalIndex = 2;

  changeStep(int index) {
    activeIndex = index;
    notifyListeners();
  }
}

I was using 6.0.2. I upgraded it to 6.1.2. Yet the issue is still there. What should I do?