This is a basic task application that demonstrates how to use Ditto's peer-to-peer data sync within your Flutter Application.
- Clone the repository from GitHub. Open a terminal and run the following command:
git clone https://github.com/getditto/demoapp-flutter
- Navigate to the project directory:
cd demoapp-flutter
Install the necessary dependencies.
flutter pub get
- Log in to your Ditto Portal account
- Navigate to your application and obtain the App ID and Playground Token (see Sync Credentials for more details)
- Open the lib/main.dart file or the appropriate configuration file where Ditto is initialized
- Update the code with the App ID and Playground Token from your Ditto Application
const appID = "REPLACE_ME_WITH_YOUR_APP_ID";
const token = "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN";
- Ensure you have an Android Emulator running or connect a physical device
- Run the following command in the terminal from the root of the application
flutter run
- Select the Android Emulator/Device
[1]: sdk gphone64 arm64 (emulator-1234)
[2]: Mac Designed for iPad (mac-designed-for-ipad)
Please choose one (or "q" to quit):
- Ensure you have an iOS Simulator running or connect a physical iOS device Run the following command in the terminal and select the iOS Simulator/Device
flutter run
- Select the iOS Simulator/Device
[1]: iPhone 15 (5A8DFE9D-7BF0-4BEE-A675-A056B64CEE3F)
[2]: Mac Designed for iPad (mac-designed-for-ipad)
Please choose one (or "q" to quit):
- Launch the application on multiple devices, emulators, or simulators
- Disconnect from your current WiFi network while keeping WiFi enabled on the device to allow for LAN connections
- Create new Tasks and update the Done status of existing tasks
Note: Android Emulators cannot connect to iOS Simulators for offline sync due to platform limitations
Explore the following links and resources to learn more about Ditto: