Flutter Firebase Remote Config Fetch JSON as Map
2,422
So the remote config value was fine, but in the app I had made wrong default value for test
and it got fetched:
const defaultValue = {
"title": "Hello, World!",
}
config.setDefaults({
'test': defaultValue,
});
And it should have been:
config.setDefaults({
'test': json.encode(defaultValue),
});
I thought it was Remote Config's fault
![Dennis Barzanoff](https://lh4.googleusercontent.com/-HBKhV4EJFQ8/AAAAAAAAAAI/AAAAAAAAABk/cF-BHi84-2I/photo.jpg?sz=256)
Author by
Dennis Barzanoff
Updated on December 26, 2022Comments
-
Dennis Barzanoff over 1 year
In Firebase Remote Config I have a valid json field named
test
:{ "title": "Hello, World!" }
In the application I call
jsonDecode(config.getString('test'))
and it does not work becauseconfig.getString('test')
spits out:{title=Hello, World!}
I tried all possible methods on the config:
jsonDecode(config.getAll()['test'].asString());
and
jsonDecode(config.getValue('test').asString())
The app crashes since that is not valid JSON.
-
Hussnain Haidar over 3 yearsjsonDecode(config.getString('test'))["data"]["title"]
-
Dennis Barzanoff over 3 yearsNope,
jsonDecode
throws an exception becausegetString
returns that strange Kotlin-like format
-