import 'package:firebase_remote_config/firebase_remote_config.dart';
class FirebaseRemoteConfigClass {
final remoteConfig = FirebaseRemoteConfig.instance;
Future initRemoteConfig() async {
print("remote config is");
print(remoteConfig);
// try {
await remoteConfig.fetchAndActivate();
var temp = remoteConfig.getString("appbar_color");
return temp;
}}
in this code, I try to fetch "appbar_color", which is defined in my firebase console, but I got that error. the remoteConfig object is not null.
In my main.dart, this is the only place I refered to initRemoteConfig()
@override
void initState() {
super.initState();
getVal();
}
getVal() async {
var scs = await FirebaseRemoteConfigClass().initRemoteConfig();
print(scs);
}
I tried deleting 'appbar_color' on my firebase console and reset and re-published it, but it still did not work. firebase console seems disconnected with my project.
It looks like you are trying to retrieve a value from Firebase Remote Config and encountering a type error. The error message "_TypeError (type 'Null' is not a subtype of type 'int')" suggests that the variable temp is inferred as Null instead of an int.
Firebase Remote Config values can be of various types, and the method getString is returning a String. When you try to return temp, which is inferred as a String, to a variable or function that expects an int, you get a type error.
To resolve this issue, you should ensure that the type of the value you are fetching matches the expected type. If the value is supposed to be an int, you should use getInt instead of getString. Here's an updated version of your code.