Decentralized, End-to-end Verifiable Governance Platform Client Library for Dart

Decentralized, End-to-end Verifiable Governance Platform Client Library for Dart

A Flutter plugin that provides communication capabilities to interact with decentralized governance processes running on the Vocdoni platform.

DVote Flutter

A Flutter plugin that provides communication capabilities to interact with decentralized governance processes running on the Vocdoni platform.

It provides Dart libraries as well as native modules written in Go.

More details: https://pub.dev/packages/dvote

Getting Started

Import the Dart library on your project and use the static functions available on the Dvote class

import 'package:dvote/dvote.dart';

Entity API

Use a Vocdoni Gateway to fetch the metadata of an Entity

import 'package:dvote/dvote.dart';

EntityReference entityRef = EntityReference();
entityRef.entityId = "0x1234...";

final gwInfo = await getRandomDefaultGatewayInfo("goerli");
final DVoteGateway dvoteGw = DVoteGateway(gwInfo.dvote, publicKey: gwInfo.publicKey);
final Web3Gateway web3Gw = Web3Gateway(gwInfo.web3);

final entityMeta = await fetchEntity(entityRef, dvoteGw, web3Gw);
dvoteGw.disconnect();

Process API

Use a Vocdoni Gateway to fetch the active voting processes of an Entity

import 'package:dvote/dvote.dart';

EntityReference entityRef = EntityReference();
entityRef.entityId = "0x1234...";

final gwInfo = await getRandomDefaultGatewayInfo("goerli");
final DVoteGateway dvoteGw = DVoteGateway(gwInfo.dvote, publicKey: gwInfo.publicKey);
final Web3Gateway web3Gw = Web3Gateway(gwInfo.web3);

// All active from an Entity
final List<ProcessMetadata>> processes = await fetchActiveProcesses(entityRef, dvoteGw, web3Gw);

// A specific Voting Process
final pid = "0x1234...";
final ProcessMetadataprocessMeta = await getProcessMetadata(pid, dvoteGw, web3Gw);

dvoteGw.disconnect();

File API

Use a Vocdoni Gateway to fetch static content from the net

import 'package:dvote/dvote.dart';

final gwInfo = await getRandomDefaultGatewayInfo("goerli");
final DVoteGateway dvoteGw = DVoteGateway(gwInfo.dvote, publicKey: gwInfo.publicKey);
final Web3Gateway web3Gw = Web3Gateway(gwInfo.web3);

final contentUri = ContentURI("ipfs://QmSsfizN4rpSDLRZw3X3WooCPpnBktZ5bEShvmLZuf88iw,https://my-server/file.txt");

final content = await fetchFileString(contentUri, dvoteGw, web3Gw);

Data models and storage

DVote Flutter exports multiple Dart classes that allow to wrap, parse, serialize and deserialize the most relevant data schemes used within the platform.

import 'package:dvote/dvote.dart';

// Parse from JSON
Entity entity = parseEntityMetadata("{ ... }");
print(entity.name["en"]);
print(entity.media.avatar);

// Serialize into a binary file
File file1 = File("./my-entity.dat");
file1.writeAsBytes(entity.writeToBuffer());

// Reading back from a file
File file3 = File("./my-entity.dat");
final entityBytes = await file3.readAsBytes();
Entity entity2 = Entity.fromBuffer(entityBytes);
print(entity2.name["en"]);

// Storing a collection of entities
EntitiesStore store = EntitiesStore();
store.entities.addAll([entity, entity2]);
File file2 = File("./entities.dat");
await file2.writeAsBytes(store.writeToBuffer());

Classes

The following classes are exported:

  • Entity
    • EntityMetadataStore
    • EntityMetadata
    • EntityMetadata_VotingProcesses
    • EntityMetadata_Media
    • EntityMetadata_Action
    • EntityMetadata_Action_ImageSource
    • EntityMetadata_EntityReference
  • Process
    • ProcessMetadataStore
    • ProcessMetadata
    • ProcessMetadata_Census
    • ProcessMetadata_Details
    • ProcessMetadata_Details_Question
    • ProcessMetadata_Details_Question_VoteOption
  • Feed
    • FeedsStore
    • Feed
    • FeedPost
    • FeedPost_Author
  • Gateway
    • BootNodeGateways
    • BootNodeGateways_NetworkNodes
    • BootNodeGateways_NetworkNodes_DVote
    • BootNodeGateways_NetworkNodes_Web3
  • Identity
    • IdentitiesStore
    • Identity
    • Identity_Peers
    • Identity_Claim
    • PeerIdentity
  • Key

Parsers

Raw JSON data can't be directly serialized into a Protobuf object. For this reason, several parsers are provided:

  • EntityMetadata parseEntityMetadata(String json)
    • List<Entity_Action> parseEntityActions(List actions)
    • List<Entity_EntityReference> parseEntityReferences(List entities)
  • ProcessMetadata parseProcessMetadata(String json)
    • List<Process_Details_Question> _parseQuestions(List items)
  • ProcessResults parseProcessResults(Map<String, dynamic> response)
  • ProcessResultsDigested parseProcessResultsDigested(ProcessResults rawResults, ProcessMetadata processMetadata)
  • Feed parseFeed(String json)
  • BootNodeGateways parseBootnodeInfo(String json)
    • BootNodeGateways_NetworkNodes _parseBootnodeNetworkItems(Map item)

Example

  • See example/lib/main.dart for a usage example.

Development

  • Clone the git repo
  • Run flutter pub get
  • Run git submodule update --init --recursive to fetch the protobuf subrepo

Download Details:

Author: vocdoni

Source Code: https://github.com/vocdoni/dvote-flutter

flutter dart mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Google's Flutter 1.20 stable announced with new features - Navoki

Google has announced new flutter 1.20 stable with many improvements, and features, enabling flutter for Desktop and Web

Top 25 Flutter Mobile App Templates in 2020

Flutter has been booming worldwide from the past few years. While there are many popular mobile app development technologies out there, Flutter has managed to leave its mark in the mobile application development world. In this article, we’ve curated the best Flutter app templates available on the market as of July 2020.

Flutter App Development Trends 2020

As the new decade dawns upon us, a slew of technologies has been making a lot of noise to grab the developers’ attention. While native app development is going strong, the trade winds are now blowing towards going cross-platform.

How To Succeed In Mobile App Wireframe Design?

This article covers everything about mobile app wireframe design: what to do and what not, tools used in designing a mobile or web app wireframe, and more.

What is Flutter and why you should learn it?

Flutter is an open-source UI toolkit for mobile developers, so they can use it to build native-looking Android and iOS applications from the same code base for both platforms. Flutter is also working to make Flutter apps for Web, PWA (progressive Web-App) and Desktop platform (Windows,macOS,Linux).