shared_preferences_settings icon indicating copy to clipboard operation
shared_preferences_settings copied to clipboard

Difficulty with Settings().onStringChanged

Open SubutaDan opened this issue 4 years ago • 2 comments

Hello,

I am enjoying working with shared_preferences_settings. Thanks for making it available.

I have run into a possible issue when using the example code in my app for the first time after uninstalling the app (which flushes its storage) and then reinstalling it. I encounter a failed assertion in the Settings().onStringChanged example, apparently because "value" is null when the screen is being drawn. If I hack a non-null value in for "value" like this:

 childBuilder: (BuildContext context, String value) {
            //return Text(value);
            return Text("Gleeb");
          }

and hot reload then the problem goes away. If I revert the hack and hot reload again, the problem reappears.

Note that I have commented out the provider and auth_provider imports as they appear to be unused.

Can you suggest what I might be doing wrong or let me know how to resolve this?

Thanks.

-Dan

SubutaDan avatar Jan 30 '21 16:01 SubutaDan

Hi Dan, Thanks for your email. Can you use a workaround, for example, with a null check? Maybe we need this null check inside the library to avoid such calls.

Barnabas.

barnabasbartha avatar Jan 30 '21 17:01 barnabasbartha

Hi Barnabas,

Thanks for getting back to me. I can certainly use a work-around.

-Dan

On 30 January 2021 17:42:40 GMT, "Barnabás BARTHA" [email protected] wrote:

Hi Dan, Thanks for your email. Can you use a workaround, for example, with a null check? Maybe we need this null check inside the library to avoid such calls.

Barnabas.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/BarthaBRW/shared_preferences_settings/issues/24#issuecomment-770249676

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

SubutaDan avatar Jan 30 '21 18:01 SubutaDan