github_issues 1.0.1 github_issues: ^1.0.1 copied to clipboard
Flutter package to create Github issues
Use Github issues to collect user feedback.
Getting started #
- Create a repository to store the user feedback (or use an existing one).
- Get a token with read and write access on issues for your repository
Option 1: Generate a personal access token
Option 2: Create a Github App -> Install your own Github App -> Generate a private key for your Github App.
Usage #
Dart #
import 'dart:io';
import 'package:github_issues/github_issues.dart';
const appId = 385403;
const owner = 'abichinger';
const repo = 'nonobattle-issues';
// Personal access token
Future<String> get personalToken {
return File('assets/token.txt').readAsString();
}
// Installation token of Github app
Future<String> get installationToken async {
final pem = await File('assets/private.pem').readAsString();
return PrivateKeyAuth(id: appId, pem: pem)
.getInstallationToken(owner: owner, repo: repo);
}
void main() async {
final token = await personalToken;
// final token = await installationToken;
final github = Github(Authentication.token(token));
github.createIssue(
owner: owner,
repo: repo,
issue: const IssueRequest(
title: 'Hello World!',
body: '...',
labels: ['bug'],
),
);
}
Flutter #
import 'package:github_issues/github_issues.dart';
Widget _buildDialog(
BuildContext context, {
bool showTitle = true,
IssueRequest? initialValue,
}) {
return AlertDialog(
scrollable: true,
title: const Text(
'Thanks for your feedback!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
content: Column(
children: [
const Text('Let us know how we can improve this example.'),
const SizedBox(height: 16),
GithubIssueForm(
showTitle: showTitle,
initialValue: initialValue,
onClose: () {
Navigator.pop(context);
},
onSubmit: (issue) async {
final token = await personalToken;
final github = Github(Authentication.token(token));
await github.createIssue(
owner: 'abichinger',
repo: 'nonobattle-issues',
issue: issue,
);
Navigator.pop(context);
},
),
],
),
);
}