feedback_kit 0.1.1
feedback_kit: ^0.1.1 copied to clipboard
In-app feedback boards, voting and a public roadmap for Flutter. Auth-agnostic: bring your own identity via a FeedbackIdentityProvider, or let the built-in anonymous device identity handle it. Pairs w [...]
example/lib/main.dart
import 'package:feedback_kit/feedback_kit.dart';
import 'package:flutter/material.dart';
/// Point this at a running Feedback service. Overridable at build time so the
/// example works against localhost, staging or production without an edit:
///
/// flutter run --dart-define=FEEDBACK_BASE_URL=http://10.0.2.2:3011 \
/// --dart-define=FEEDBACK_BOARD=<publicKey>
const _baseUrl = String.fromEnvironment(
'FEEDBACK_BASE_URL',
defaultValue: 'http://localhost:3011',
);
const _boardKey = String.fromEnvironment('FEEDBACK_BOARD');
void main() => runApp(const ExampleApp());
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'feedback_kit',
theme: ThemeData(
colorSchemeSeed: const Color(0xFF4F46E5),
useMaterial3: true,
),
darkTheme: ThemeData(
colorSchemeSeed: const Color(0xFF4F46E5),
brightness: Brightness.dark,
useMaterial3: true,
),
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
if (_boardKey.isEmpty) {
return const Scaffold(
body: Center(
child: Padding(
padding: EdgeInsets.all(24),
child: Text(
'Kein Board angegeben.\n\n'
'flutter run --dart-define=FEEDBACK_BOARD=<publicKey>',
textAlign: TextAlign.center,
),
),
),
);
}
// Anonymous mode: nothing to configure, no backend involved. Swap in a
// CallbackIdentityProvider to exercise an authenticated board.
final config = FeedbackConfig(
baseUrl: Uri.parse(_baseUrl),
boardPublicKey: _boardKey,
identityProvider: AnonymousDeviceIdentity(),
);
return Scaffold(
appBar: AppBar(title: const Text('Beispiel-App')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('So sieht die Einbindung als Menüpunkt aus:'),
const SizedBox(height: 16),
FilledButton.icon(
icon: const Icon(Icons.forum_outlined),
label: const Text('Feedback & Roadmap'),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => FeedbackBoardScreen(config: config),
),
),
),
],
),
),
);
}
}