A Key Value Storage Flutter Plugin Sync multiple iOS and Mac


A Key Value Storage Flutter Plugin Sync multiple iOS & Mac Devices base on iCloud.




NOTE: It is recommended to use real device testing for iOS devices as the iOS simulator may not synchronize in real-time. Mac devices can be compiled and tested directly. Only the same iCloud account needs to be logged in on different Apple devices to synchronize lightweight Key Value data.

  • FirstStep:

Enable your iOS Or Mac Project iCloud Key Value Services.


  • And Then Enjoy It.

Sample Code.

import 'package:icloud_kv_storage/icloud_kv_storage.dart';

var iCloudStorage = CKKVStorage();

Update A Key

void _incrementCounter() {
    setState(() {
      iCloudStorage.writeString(key: key, value: _counter.toString());

Read A Key

iCloudStorage.getString('k_storage_count').then((value) {
      if (value != null) {
        setState(() {
          _counter = int.parse(value);

Delete A Key

void _clearCounter() {
    setState(() {
      _counter = 0;

Real Time Call Back Key Value Update on other devices

      onCallBack: (kvMap) {
        print('receive icloud_key_update map $kvMap');
        //if receive remove key will rec {flutter.k_storage_count: null}
        //if receive update key will rec {flutter.k_storage_count: 1}
        //because have prefix flutter. so need use my method to get real key.
        var key = iCloudStorage.getRealKey('k_storage_count');
        if (kvMap.containsKey(key)) {
          String? value = kvMap[key];
          setState(() {
            if (value != null) {
              _counter =
            } else {
              _counter = 0;

Release Log


Based on Apple CloudKit, lightweight Key value storage data can be synchronized between different Apple devices, such as iOS and Mac devices. For the time being, only String data can be synchronized.


Currently, only String data is supported, and basic data types such as int and double will be added in the future


# Miscellaneous

# IntelliJ related

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.


# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
# This file should be version controlled.

  revision: 62bd79521d8d007524e351747471ba66696fc2d4
  channel: stable

project_type: plugin

# Tracks metadata for the flutter migrate command
    - platform: root
      create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
      base_revision: 62bd79521d8d007524e351747471ba66696fc2d4
    - platform: ios
      create_revision: 62bd79521d8d007524e351747471ba66696fc2d4
      base_revision: 62bd79521d8d007524e351747471ba66696fc2d4

  # User provided section

  # List of Local paths (relative to this file) that should be
  # ignored by the migrate tool.
  # Files that are not part of the templates will be ignored by default.
    - 'lib/main.dart'
    - 'ios/Runner.xcodeproj/project.pbxproj'

Download details:

Author: JerryFans
Source: https://github.com/JerryFans/icloud_kv_storage

License: MIT license

#flutter #dart 

A Key Value Storage Flutter Plugin Sync multiple iOS and Mac
2.05 GEEK