https://github.com/s5-dev/s5-dart
Use the S5 Network in your Flutter and Dart apps
https://github.com/s5-dev/s5-dart
content-addressed dart flutter p2p-network s5
Last synced: about 1 month ago
JSON representation
Use the S5 Network in your Flutter and Dart apps
- Host: GitHub
- URL: https://github.com/s5-dev/s5-dart
- Owner: s5-dev
- License: mit
- Created: 2024-02-02T23:17:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-25T16:31:11.000Z (almost 2 years ago)
- Last Synced: 2025-03-21T15:18:28.217Z (about 1 year ago)
- Topics: content-addressed, dart, flutter, p2p-network, s5
- Language: Dart
- Homepage: https://pub.dev/packages/s5
- Size: 10.7 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# S5
This package makes it easy to use the S5 Network APIs in your Flutter and Dart apps.
## Features
- Runs a local S5 Node and connects to default nodes (can be configured)
- Provides all S5 APIs (file, registry, message) with full integrity verification
- Supports creating and restoring user identities and uploading to storage services
## Getting started
Install with `dart pub add s5`
## Example
```dart
import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:s5/s5.dart';
void main(List args) async {
// Initialize the Hive data directory (not needed on web)
Hive.init('data');
// Create a S5 Node and API Client
final s5 = await S5.create();
// Download and deserialize a metadata CID
final webAppMetadata = await s5.api.downloadMetadata(
CID.decode(
'z31rd7XSsfcDuuv716hjfbjitjCMRrfwPE24EWSuJntFKCdK',
),
) as WebAppMetadata;
// Print all files of this web app with their CID and size
for (final path in webAppMetadata.paths.entries) {
print('${path.key} ${path.value.cid} (${path.value.cid.size} bytes)');
}
// Download one of the CSS files and print its contents
final cssFileCID = webAppMetadata.paths['assets/css/default.min.css']!.cid;
final bytes = await s5.api.downloadRawFile(cssFileCID.hash);
print(utf8.decode(bytes));
}
```