'2 positional argument(s) expected, but 0 found bypass via another class
I created a class where I write a theme model:
import 'package:flutter/material.dart';
import 'theme_preference.dart';
class ThemeModel extends ChangeNotifier {
bool _isDark;
ThemePreferences _preferences;
bool get isDark => _isDark;
ThemeModel(this._preferences, this._isDark) {
_isDark = false;
_preferences = ThemePreferences();
getPreferences();
}
set isDark(bool value) {
_isDark = value;
_preferences.setTheme(value);
notifyListeners();
}
getPreferences() async {
_isDark = await _preferences.getTheme();
notifyListeners();
}
}
to use the change I had to add create: (_) => ThemeModel(this._preferences, this._isDark), in the main class. But when I do it so, I get an error like this: The getter '_isDark' isn't defined for the type '_ToDoState'. I can´t initialise the variables in the main class so my question is, if there is a way that I can cast these thinks in the other class where I initialised it?
By the way I am following this tutorial: https://www.flutterant.com/switching-themes-in-flutter-apps/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
