Working with platform channels
We will be implementing a new feature in our candy_store
app. The feature is a Favorites page that will display a list of items that we have favorited within the app. This list will be saved and persist between app restarts. There are various ways to store different types of data on a device, but the method depends on the operating system being used. For example, in native iOS, we can use UserDefaults
to store basic key-value data, while in native Android, we have SharedPreferences
for that purpose. Fortunately, Flutter provides an official plugin called shared_preferences
(https://pub.dev/packages/shared_preferences) that abstracts these APIs and offers a convenient Dart interface. This plugin is typically the recommended choice for handling basic data storage. However, for the purpose of demonstrating how to work with platform channels, we will create our own implementation that is tailored to our application. Let’s begin by selecting the appropriate...