Welcome to the Flutter SDK Installation Guide. This document provides step-by-step instructions for installing and configuring the Ditto SDK, enabling you to sync, query, and insert data seamlessly within your existing Flutter application.
1.9.20
or later
./android/settings.gradle
org.jetbrains.kotlin.android
plugin to 1.9.20
ditto_live
will load a dynamic library called libdittoffi.so
. By
default, it will be included in builds produced by the flutter
CLI.
However, if you want to configure this path, you can set $LIBDITTOFFI_PATH
.
This may be required by some package managers, for example.
flutter test
, binaries will not be
provided, and you will get an error. In order to make flutter test
work, you
must set both $LIBDITTOFFI_PATH
and $XDG_DOCUMENTS_DIR
.Your desktop environment may already set $XDG_DOCUMENTS_DIR
, but if it does
not, $HOME/Documents
is a sensible default. For more information, see the
this wiki page on XDG directories.Here is an example of how you might run tests that depend on ditto_live
version 4.12.0
on Linux:ios/Runner/Info.plist
:android/app/src/main/AndroidManifest.xml
.android/app/src/main/AndroidManifest.xml
. Then edit the service metadata appropriately.small_app_icon
drawable must be monochrome white.The foreground service will be automatically started and stopped on startSync()
and stopSync()
, respectively.appID
, playground token
, authURL
, and websocketURL
for your application. These are required to initialize the Ditto SDK.Ditto
. This is the main entry point into all Ditto-related functionality.items
:
insertData
function wherever appropriate in your application, such as in a button press handler.
items
collection:
observeData
function, typically in the initState
method of a stateful widget to start observing when the widget is initialized.
dispose()
method to prevent resource leaks
startSync
. This enables this device to sync data with other peers including the Ditto Cloud.
items
collection:
syncData
function, typically when initializing your Ditto instance.
await Ditto.init()
. By default, assets are bundled with the application and loaded
from the same web server that serves the application. After running flutter build web
, you can find those in the
build/web/assets/packages/ditto_live/lib/assets
directory.
Alternatively, you can host the contents of that directory on a CDN or other web
server and configure Ditto to load assets from there. All contents of the
directory, excluding the ditto.wasm
file itself, must be reachable at the URL
given by the wasmShimUrl
parameter. The ditto.wasm
file can be served from a
separate URL given by the wasmUrl
parameter.
Configuration for loading all assets from a CDN: