By the end of this quick start, you will have successfully run the Ditto Task Application on either iOS, Android, or both, and will be able to sync data without needing an internet connection.

Prerequisites

  • Installed code editor (preferably Visual Studio Code or Android Studio)
  • Flutter SDK installed on your machine
  • Git installed on your machine
  • Ditto Portal account with a Ditto Application (see Getting Playground Token Credentials)

For Android development:

  • Android Studio installed on your machine
  • A physical Android device or Android emulator

For iOS development:

  • macOS with the latest version of Xcode installed
  • A physical iOS device or iOS simulator

1. Clone the Repository

  • 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

2. Install Dependencies

  • Install the necessary dependencies.
flutter pub get

This command will fetch all the dependencies listed in the pubspec.yaml file.

3. Configure Ditto

Obtain App ID and Playground Token

  1. Log in to your Ditto Portal account
  2. Navigate to your application and obtain the App ID and Playground Token (see Getting Playground Token Credentials for more details)

Update Flutter Application with Ditto Credentials

  1. Open the lib/main.dart file or the appropriate configuration file where Ditto is initialized
  2. Update the code with the App ID and Playground Token from your Ditto Application
Dart
const appID = "REPLACE_ME_WITH_YOUR_APP_ID";
const token = "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN";

4. Run the Application

Run the Application on Android

  • 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):

Run the Application on iOS

  • 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):

5. Sync-Data Offline

  1. Launch the application on multiple devices, emulators, or simulators
  2. Disconnect from your current WiFi network while keeping WiFi enabled on the device to allow for LAN connections
    • Note: Android Emulators and iOS Simulators can only form offline connections with each other due to platform limitations
  3. Create new Tasks and update the Done status of existing tasks

Was this page helpful?