eno2
eno2

Reputation: 73

I want to add a page favorites button with flutter that is saved even in local context

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
                }
            ),
          ],
        ),

Upvotes: 2

Views: 350

Answers (1)

Abbasihsn
Abbasihsn

Reputation: 2171

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.

Upvotes: 2

Related Questions