gohash_mobile 0.0.2

  • README.md
  • Example
  • Installing
  • Versions
  • 63


go-hash Flutter API for mobile phones.

[0.0.1] - 2018/May/02.

  • Initial release.


import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gohash_mobile/gohash_mobile.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  final _biggerFont = const TextStyle(fontSize: 18.0);
  String _errorMessage = 'No errors!';
  GohashDb _database;

  initState() {

  /// Temporary function to read a go-hash database from assets, writing it
  /// to a file in the Documents dir, where it's accessible to Go code.
  Future<File> _loadDbFile() async {
    final dbBytes = await rootBundle.load('assets/gohash_db');
    final docsDir = await getApplicationDocumentsDirectory();
    final destinationFile = File("${docsDir.path}/gohash_db");
    return destinationFile.writeAsBytes(dbBytes.buffer.asUint8List());

  // Platform messages are asynchronous, so we initialize in an async method.
  initPlatformState() async {
    GohashDb database;
    var errorMessage = '';
    final dbFile = await _loadDbFile();
    final dbFileSize = await dbFile.length();

    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      database =
          await GohashMobile.getDb(dbFile.absolute.path, 'secret_password');
      errorMessage = '';
    } on PlatformException {
      errorMessage = 'Platform error';
    } on MissingPluginException {
      // method is missing
      errorMessage = 'Internal app error - missing method';
    } on Error catch (e) {
      errorMessage = 'Catastrophic error: $e';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _errorMessage = errorMessage;
      _database = database;

  Widget _buildGroup(Group group) {
    return new ListTile(
      title: new Text(
        style: _biggerFont,

  Widget _buildGroups() {
    final String error = (_database == null)
        ? 'Could not open the database'
        : _database.groups.isEmpty ? 'The database is empty' : null;

    if (error != null) {
      return new Column(
        children: <Widget>[new Text(error), new Text("Error: $_errorMessage")],

    final groupWidgets = _database.groups.map(_buildGroup).toList();

    return new ListView.builder(
        padding: const EdgeInsets.all(16.0),
        itemCount: groupWidgets.length,
        itemBuilder: (context, i) => groupWidgets[i]);

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('go-hash Mobile - Test App'),
        body: new Center(
          child: _buildGroups(),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  gohash_mobile: "^0.0.2"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:gohash_mobile/gohash_mobile.dart';
Version Uploaded Documentation Archive
0.0.2 May 3, 2018 Go to the documentation of gohash_mobile 0.0.2 Download gohash_mobile 0.0.2 archive
0.0.1 May 2, 2018 Go to the documentation of gohash_mobile 0.0.1 Download gohash_mobile 0.0.1 archive


We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4


Describes how popular the package is relative to other packages. [more]
37 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
72 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.


  • Fix dependencies in pubspec.yaml.

    Running flutter packages pub upgrade failed with the following output:

    ERR: The current Dart SDK version is 2.0.0-dev.60.0.flutter-a5e41681e5.
     Because gohash_mobile requires SDK version >=2.0.0-edge <2.0.0, version solving failed.
  • Fix platform conflicts.

    Error(s) prevent platform classification:

    Fix dependencies in pubspec.yaml.

  • Running dartdoc failed.

    Make sure dartdoc runs without any issues.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-edge <2.0.0