Flutter SDK

Let's explore how to make a simple SendingNetwork client with the ability to sync messages, create a chat room, and post messages in the room.

When you complete this quickstart, you’ll have a fully running application that can send and receive messages on a demo app. To integrate and initialize SDK written in Dart, follow these steps:

1 Get the code

https://github.com/Sending-Network/sendingnetwork-dart

2 Configure the wallet address and private key

String privKey wallet private Private key"; 
String addressHexAll = "wallet address";

3 Configure the dependencies in your pubspec.yaml file

Add the following dependencies in the same directory:

sendingnetwork_flutter_demo
sendingnetwork_dart_sdk
sendingnetworkdart_api_lite

In the same pubspec.yaml file, include sendingnetwork_dart_sdk as a local path dependency:

sdn_api_lite:
  path: ../sendingnetworkdart_api_lite
Similarly, include sendingnetwork_flutter_demo as a local path dependency:
sdn:
  path: ../sendingnetwork_dart_sdk/
Refer to the configuration of sendingnetwork_flutter_demo for more details.

4 Import the SDK:

import 'package:sdn/sdn.dart';

5 import package:sdn/sdn.dart;

Create a client and provide the server domain:

final client = Client('SDN Example Chat', databaseBuilder: (_) async {
  final dir = await getApplicationSupportDirectory();
  final db = HiveCollectionsDatabase('sdn_example_chat', dir.path);
  await db.open();
  return db;
});
client.sdnnode = Uri.parse('https://XXX.network'); // Replace with your server's domain

6 Run the demo:

flutter pub get
flutter run

By running the demo, you should be able to log in, create rooms, and send messages. You will be able to see rooms created on other platforms that have integrated with SendingNetwork as well.

Last updated