2

I'm making a learning app. But here, I would like to bookmark only the problem I want out of hundreds of problems, so that the mark appears on the problem selection page next time.

The question is whether this can only be implemented in flutter without firebase or any other database.

Is it possible to implement it locally?

child: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          title: Text('1-1',
            style: TextStyle(
              color: Colors.blueAccent,
              fontSize: 20,
              fontWeight: FontWeight.bold,
            ),),
          centerTitle: true,
          leading: IconButton(
            onPressed: () {
              Navigator.pop(context);
            },
            color: Colors.black,
            iconSize: 25,
            icon: Icon(Icons.arrow_back),

          ),

          actions: <Widget>[
            IconButton(
                icon: Icon(Icons.bookmark_outline),
                iconSize: 25,
                color: Colors.black,
                onPressed: () {
                 //here
                }
            ),
          ],
        ),
1
  • yes, you can do it with the help of flutter shared preference package pub.dev/packages/shared_preferences/install. Data stored in system preferences won't be cleared unless user manually set it to empty (clear it manually) or uninstall the apps
    – HeIsDying
    Sep 28, 2021 at 1:21

1 Answer 1

2

Yes, in Flutter apps you have some options to store data in local storage permanently. For example, you can use one of these options:

  1. Shared preferences add this package to your pubspec.yaml file:
dependencies:
  shared_preferences: ^2.0.8

and run flutter pub get. Now, You are able to use it based on this example.

  1. SQLite add this package to your pubspec.yaml file:
dependencies:
  sqflite: ^2.0.0+4

and run flutter pub get. Now, You are able to use it based on this example.

Note: Usually, it is better to store a small amount of data using shared preferences and large data based on a database table. personally, I prefer shared preferences for your application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.