Skip to content

IPFS-Meshkit/Flutter-IPFS-pilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPFS Flutter — Dart Client Library

A production-ready Dart client library for the IPFS HTTP API, built with Chopper and fully migrated to Dart 3 + Null Safety.

Originally forked from hackyguru/IPFS-Flutter and upgraded to modern Dart/Flutter standards.


What is this project?

IPFS (InterPlanetary File System) is a decentralized, peer-to-peer protocol for storing and sharing data. This library acts as a Dart HTTP client that lets you interact with a locally running IPFS node directly from your Dart or Flutter application — without any platform-specific native code.

You can:

  • Add any data (text, bytes) to IPFS and get back a unique content hash (CID)
  • Retrieve any data from IPFS using its CID
  • Integrate IPFS into any Dart or Flutter project with just a few lines of code

Features

  • Add data to IPFS — upload bytes/strings and receive a content identifier (CID/hash)
  • Read data from IPFS — fetch content by its hash using the /api/v0/cat endpoint
  • Type-safe responses — strongly typed Add and Cat response models
  • Full Dart 3 Null Safety — no nullable surprises at runtime
  • Chopper HTTP client — auto-generated, interceptor-based HTTP layer
  • JSON serialization — powered by json_annotation + json_serializable
  • Zero platform code — works on any Dart/Flutter target (mobile, web, desktop, CLI)

Upgrades Made (from original)

This project was fully modernized from its original 2021 state:

Area Before After
Flutter Not installed 3.44.2 (latest stable)
Dart SDK >=2.10.0 <3.0.0 >=3.8.0 <4.0.0
Null Safety Pre-null-safety Full Dart 3 Null Safety
chopper 3.0.6 8.6.0 (+5 major versions)
chopper_generator 3.0.6 8.6.1
json_annotation 3.1.0 4.12.0
json_serializable 3.3.0 6.14.0
build_runner 1.0.0 2.4.0
logging 0.11.4 1.3.0
test 1.14.4 1.25.0
Lint package pedantic (deprecated) lints 5.0

Code-level changes:

  • Migrated all models (Add, Cat) to null-safe fields with ?
  • Updated ChopperClient.baseUrl from StringUri
  • Replaced deprecated @Post@POST, @multipart@Multipart()
  • Moved json_serializable from dependenciesdev_dependencies (bug fix)
  • Regenerated all .g.dart and .chopper.dart files for compatibility
  • dart analyzeNo issues found

Requirements


Setup & Installation

1. Install Flutter

brew install --cask flutter
flutter --version

2. Install IPFS (Kubo)

brew install ipfs
ipfs init
ipfs daemon

Keep the daemon running in a terminal. You'll see Daemon is ready when it's up.

3. Clone the repo

git clone https://github.com/Vanisha1606/IPFS-Flutter.git
cd IPFS-Flutter

4. Install dependencies

dart pub get

5. Regenerate code (optional — already included)

dart run build_runner build

Usage

Import

import 'package:dart_ipfs_client/dart_ipfs_client.dart';

Initialize

final ipfs = Ipfs(url: 'http://127.0.0.1:5001');

Add data to IPFS

import 'dart:convert';

final addRes = await ipfs.add(utf8.encode('Hello World!'));
print(addRes.body?.toJson());
// {Bytes: null, Hash: Qmf1rtki74jvYmGeqaaV51hzeiaa6DyWc98fzDiuPatzyy, Name: ..., Size: 20}

Retrieve data from IPFS

final catRes = await ipfs.cat(addRes.body!.hash!);
print(catRes.body?.toJson());
// {Body: Hello World!}

Run the example

dart run example/main.dart

Run tests

dart test

Project Structure

lib/
├── dart_ipfs_client.dart              # Public export
└── src/
    ├── response/
    │   ├── add.dart                   # Add response model
    │   ├── add.g.dart                 # Generated JSON serializer
    │   ├── cat.dart                   # Cat response model
    │   └── cat.g.dart                 # Generated JSON serializer
    └── service/
        ├── ipfs.dart                  # Public Ipfs class
        ├── ipfs_service.dart          # Chopper service definition
        ├── ipfs_service.chopper.dart  # Generated Chopper client
        └── json_to_type_converter.dart  # Custom response converter
example/
└── main.dart                          # Runnable example
test/
└── ipfs_test.dart                     # Unit tests

Demo Screenshots

IPFS Daemon Running

IPFS Daemon

Kubo v0.42.0 daemon successfully started — RPC API listening on 127.0.0.1:5001, Daemon is ready.

dart run example/main.dart

Dart Run Output

"Hello World!" successfully added to IPFS and retrieved back — showing the full HTTP request/response cycle via Chopper.

dart test — All Tests Passed

Dart Test

All 2 tests passed after full upgrade to Dart 3 + Chopper v8.


License

MIT © Vanisha

About

Integrating flutter with IPFS meshkit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages