flutter_gh_fetch 0.0.3
flutter_gh_fetch: ^0.0.3 copied to clipboard

Flutter Android iOS Linux macOS Windows

Minimal package for fetching GitHub user info and paginated list of repositories

flutter_gh_fetch #

Minimal package for fetching GitHub user info and paginated list of repositories. The project is similar to my NPM library github-repo-fetch, with the exception that, obviously, it's written in Dart, and that it supports pagination, as well as filterning of private and public repositories.

Installation #

Depend on the package

  flutter_gh_fetch: ^0.0.3

and then import it inside your Dart code

import 'package:flutter_gh_fetch/flutter_gh_fetch.dart';

Usage #

This library uses GitHub GraphQL API in order to fetch data related to the user and their repositories. The authentication is conducted through the use of Personal Access Token, which you need to generate.

First, you need to create an instance of FlutterGHFetch class and call init() method.

final FlutterGhFetch ghFetch = FlutterGHFetch('token');
await ghFetch.init();

To fetch user details, call queryUserData() method

Map<String, dynamic> userData = await ghFetch.queryUserData();

For fetching repositories, you have three options: you can simply query first n repositories

final reposData = await ghFetch.queryRepositoryData(n);

or use a cursor to achieve pagination, so first n repositories after cursor

final reposData = await ghFetch.queryRepositoryData(n, after: cursor);

Lastly, you can filter out private repositories (so you only display public ones) by setting filterPrivate optional argument to true

final reposData = await ghFetch.queryRepositoryData(n, filterPrivate: true);

In order to fetch the total repository count for the user (both public and private repositories, you can call queryTotalRepoCount method

final totalCount = await ghFetch.queryTotalRepoCount();

Development and License #

The library is not gonna get any additional development after the last version, but feel free to fork the project and work on it. Upon cloning it, install necessary dependencies with flutter pub get.

The test directory holds a single test file which tests all public methods of the FlutterGHFetch class. You will need to hardcore your Personal Access Token, and cursor string.

This project is licensed under the MIT license.

pub points

Minimal package for fetching GitHub user info and paginated list of repositories

Repository (GitLab)
View/report issues


API reference






flutter, graphql


Packages that depend on flutter_gh_fetch