s5 0.2.0 copy "s5: ^0.2.0" to clipboard
s5: ^0.2.0 copied to clipboard

Use the S5 Network in your Flutter and Dart apps

example/s5_example.dart

import 'dart:convert';

import 'package:hive/hive.dart';
import 'package:s5/s5.dart';

void main(List<String> 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));
}
0
likes
140
pub points
23%
popularity

Publisher

verified publishersfive.net

Use the S5 Network in your Flutter and Dart apps

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

hive, lib5, lib5_crypto_implementation_dart

More

Packages that depend on s5