title: Flutter Getx Store Data locally
body: <p>I am currently working on an app where the user can mark ListTimes as favorites.
  These favorites are then displayed on a second page.</p>
  <p>I am using GetX for this and the functionality works. But as soon as the app gets closed the state of the app resets and the favorites are deleted.</p>
  <p>Does anyone knows how I can store the favorites locally?</p>
  <p>Here is my code:</p>
  <p>GetX controller:</p>
  <pre><code>import 'package:get/state_manager.dart';
  
  class FavouriteController extends GetxController {
    var favItems = &lt;Entries&gt;[].obs;
    int get count =&gt; favItems.length;
  
    addToCart(Entries product) {
      favItems.add(product);
    }
  </code></pre>
  <p>Favorites page:</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:get/get.dart';
  
  
  class Favs extends StatelessWidget {
    final favouritesController = Get.put(FavouriteController());
    final entriesController = Get.put(EntriesController());
  
    Favs({Key? key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        backgroundColor: backGround,
        appBar: AppBar(
          backgroundColor: appbarColor,
          title: const Text('Favs'),
        ),
        body: SafeArea(
          child: Column(
            children: [
              const SizedBox(height: 10),
              Expanded(
                child: GetX&lt;FavouriteController&gt;(
                  builder: (controller) {
                    return ListView.builder(
                      itemCount: controller.favItems.length,
                      itemBuilder: (context, index) {
                        return Card(
                            margin: const EdgeInsets.all(12),
                            color: container,
                            shape: RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(15.0)),
                            child: ListTile(
                              title: Text(
                                controller.favItems[index].name,
                                style: const TextStyle(
                                    fontSize: 16, color: Colors.white),
                              ),
                              trailing: IconButton(
                                onPressed: () {
                                  favouritesController
                                      .deleteEntries(controller.favItems[index]);
                                },
                                icon: const Icon(
                                  Icons.delete_forever,
                                  color: titleColor,
                                ),
                              ),
                              onTap: () {
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) =&gt; controller
                                            .favItems[index].navigation));
                              },
                            ));
                      },
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>