Flutter Settings Screen with Shared Preferences

First stable version of Flutter came out on 4th of December, 2018. Even though the community is growing rapidly since then, there is no built-in solution for managing your application’s settings neither on Flutter nor on Android.

But almost every application needs settings and a way to manage it, probably with Shared Preferences, right?

After I got familiar with the Flutter development I decided to make a library to solve this problem.

You can create a list based menu structure and choose from different input widgets like toggle screen, checkbox, radio button, switch, slider, color picker, and simple text field. A screen with a checkbox looks like this:

SettingsScreen(
    title: "Application Settings",
    children: 
        CheckboxSettingsTile(
            settingKey: 'key-of-your-setting',
            title: 'This is a simple Checkbox',
        ),
    ,
);

To retrieve these values anywhere in your application code, use the simple StreamBuilder based async methods like:

Settings().onBoolChanged(
    settingKey: 'key-of-your-setting',
    defaultValue: false,
    childBuilder: (BuildContext context, bool value){
        return Text(value.toString());
    },
);

Check out the project repo for more examples and detailed documentation.

Do you like this library? Star it or comment below.

Share:FacebookX
Written by
Barnabás Bartha
Barnabas Bartha