Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion flutter_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ This is a basic task application that demonstrates how to use Ditto's peer-to-pe
- Android SDK installed
- IDE of choice (Android Studio, VS Code, etc)

### MacOS Development
This has been tested with XCode 26.2 on MacOS 26.6 with Flutter 3.29.3.

### Windows Development
To build the Windows version of this Flutter app requires Visual Studio 2022 specifically be
installed and configured with C++ and cmake installed from the Visual Studio Installer. This has
been tested with Flutter version 3.29.3 on Windows.

## Getting Started

### 1. Clone the Repository
Expand Down Expand Up @@ -78,7 +86,7 @@ Please choose one (or "q" to quit):
> If you are going to use a physical iPhone, you will need to update the Team under Signing & Capabilities in XCode. You can open the ios/Runner.xcodeproj file in XCode and then set your team from the Runner Target -> Signing & Capabilities tab.
>

- Ensure that cocoapods is up to date
- Ensure that cocoapods is up to date (or you can use Homebrew with `brew install cocoapods`)

```bash
gem install cocoapods
Expand Down
16 changes: 8 additions & 8 deletions flutter_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- ditto_live (4.13.1):
- DittoFlutter (= 4.13.1)
- ditto_live (5.0.0-dev-weekly.20260126.180):
- DittoFlutter (= 5.0.0-dev-weekly.20260126.180)
- Flutter
- DittoFlutter (4.13.1)
- DittoFlutter (5.0.0-dev-weekly.20260126.180)
- Flutter (1.0.0)
- integration_test (0.0.1):
- Flutter
Expand Down Expand Up @@ -36,12 +36,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler_apple/ios"

SPEC CHECKSUMS:
ditto_live: 93459c7d7c067ba16d4104925ea80c54dd13bf67
DittoFlutter: 26e21d5665e9bcc11660c4eceb1ec66b8ba64667
ditto_live: 73f44820c4eba49dc680be36f3b3eb966a0f5036
DittoFlutter: ffc0d73eafbe5655d186613b9c1c1c3eefee2e09
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d

PODFILE CHECKSUM: 1959d098c91d8a792531a723c4a9d7e9f6a01e38

Expand Down
3 changes: 3 additions & 0 deletions flutter_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
DEVELOPMENT_TEAM = 3T2VMFZPPQ;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -685,6 +686,7 @@
DEVELOPMENT_TEAM = 3T2VMFZPPQ;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -710,6 +712,7 @@
DEVELOPMENT_TEAM = 3T2VMFZPPQ;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
44 changes: 21 additions & 23 deletions flutter_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class _DittoExampleState extends State<DittoExample> {
dotenv.env['DITTO_APP_ID'] ?? (throw Exception("env not found"));
final token = dotenv.env['DITTO_PLAYGROUND_TOKEN'] ??
(throw Exception("env not found"));
final authUrl = dotenv.env['DITTO_AUTH_URL'];
final authUrl =
dotenv.env['DITTO_AUTH_URL'] ?? (throw Exception("env not found"));
final websocketUrl =
dotenv.env['DITTO_WEBSOCKET_URL'] ?? (throw Exception("env not found"));

Expand Down Expand Up @@ -70,26 +71,22 @@ class _DittoExampleState extends State<DittoExample> {

await Ditto.init();

final identity = OnlinePlaygroundIdentity(
appID: appID,
token: token,
enableDittoCloudSync:
false, // This is required to be set to false to use the correct URLs
customAuthUrl: authUrl);

final ditto = await Ditto.open(identity: identity);

ditto.updateTransportConfig((config) {
// Note: this will not enable peer-to-peer sync on the web platform
config.setAllPeerToPeerEnabled(true);
config.connect.webSocketUrls.add(websocketUrl);
DittoLogger.isEnabled = true;
DittoLogger.minimumLogLevel = LogLevel.debug;

//new configuration - https://docs.ditto.live/sdk/latest/ditto-config
final config = DittoConfig(
databaseID: appID, connect: DittoConfigConnectServer(url: authUrl));
final ditto = await Ditto.open(config);
await ditto.auth.setExpirationHandler((ditto, timeUntilExpiration) async {
final authResult = await ditto.auth
.login(token: token, provider: Authenticator.developmentProvider);
if (authResult.exception != null) {
throw authResult.exception!;
}
});

// Disable DQL strict mode
// https://docs.ditto.live/dql/strict-mode
await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");

ditto.startSync();
ditto.sync.start();

if (mounted) {
setState(() => _ditto = ditto);
Expand Down Expand Up @@ -167,19 +164,20 @@ class _DittoExampleState extends State<DittoExample> {

Widget get _syncTile => SwitchListTile(
title: const Text("Sync Active"),
value: _ditto!.isSyncActive,
value: _ditto!.sync.isActive,
onChanged: (value) {
if (value) {
setState(() => _ditto!.startSync());
setState(() => _ditto!.sync.start());
} else {
setState(() => _ditto!.stopSync());
setState(() => _ditto!.sync.stop());
}
},
);

//TODO review to see if we want to add in the order by title asc back in by making the dql builder use two queries.
Widget get _tasksList => DqlBuilder(
ditto: _ditto!,
query: "SELECT * FROM tasks WHERE deleted = false ORDER BY title ASC",
query: "SELECT * FROM tasks WHERE deleted = false",
builder: (context, result) {
final tasks = result.items.map((r) => r.value).map(Task.fromJson);
return ListView(
Expand Down
12 changes: 6 additions & 6 deletions flutter_app/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PODS:
- ditto_live (4.13.1):
- DittoFlutter (= 4.13.1)
- ditto_live (5.0.0-dev-weekly.20260126.180):
- DittoFlutter (= 5.0.0-dev-weekly.20260126.180)
- FlutterMacOS
- DittoFlutter (4.13.1)
- DittoFlutter (5.0.0-dev-weekly.20260126.180)
- FlutterMacOS (1.0.0)
- path_provider_foundation (0.0.1):
- Flutter
Expand All @@ -26,10 +26,10 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin

SPEC CHECKSUMS:
ditto_live: a46b3eba63227c95adffe6094d3153a74c060d0c
DittoFlutter: 26e21d5665e9bcc11660c4eceb1ec66b8ba64667
ditto_live: 488af92a7482f27bcae748002fd9db4c413850fa
DittoFlutter: ffc0d73eafbe5655d186613b9c1c1c3eefee2e09
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564

PODFILE CHECKSUM: 7eb978b976557c8c1cd717d8185ec483fd090a82

Expand Down
2 changes: 2 additions & 0 deletions flutter_app/macos/Runner/DebugProfile.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
Loading
Loading