publishable 0.0.10
publishable: ^0.0.10 copied to clipboard
Flutter-specific, opinionated, and convient package for implementing Publishable in your app.
publishable #
publishable is a Flutter-specific package that allows you to send data from your project directly to the Publishable console.
| Status | Comments |
|---|---|
| Current stable Flutter version | |
| Current beta Flutter version | |
| The oldest supported Flutter version |
Getting started #
- Add this package to your dependencies.
dependencies:
publishable: latest_version
- Get the dependencies.
flutter pub get
- Create a new instance with your API key.
final publishable = await PublishableFlutter.create(
// TODO: Replace with your token.
token: 'xxxx-xxxx-xxxx-xxxx',
// You can replace it with your own implementation if you have a custom configuration.
fromJson: PublishableConfiguration.fromJson,
fallback: PublishableConfiguration.fallback,
);
- Wrap your app in
FlutterPublishable.
runApp(
PublishableFlutter(
instance: publishable,
child: const MaterialApp(
// Rest of the app...
),
),
);
Example #
import 'package:flutter/material.dart';
import 'package:publishable/publishable.dart';
Future<void> main() async {
final publishable = await PublishableFlutter.create(
// TODO: Replace with your token.
'xxxx-xxxx-xxxx-xxxx',
);
runApp(
PublishableFlutter(
instance: publishable,
child: const MaterialApp(
home: Scaffold(
body: Center(
child: _Button(),
),
),
),
),
);
}
class _Button extends StatelessWidget {
const _Button();
@override
Widget build(BuildContext context) {
final publishable = PublishableFlutter.of(context);
return ElevatedButton(
onPressed: () => publishable.sendFeedback('Test!'),
child: const Text('Send Feedback'),
);
}
}
Usage with other packages #
import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart';
import 'package:publishable/publishable.dart';
class _Button extends StatelessWidget {
const _Button();
@override
Widget build(BuildContext context) {
final publishable = PublishableFlutter.of(context);
final feedback = BetterFeedback.of(context);
return ElevatedButton(
onPressed: () => feedback.show(
(feedback) => publishable.sendFeedback(
feedback.text,
attachment: feedback.screenshot,
properties: feedback.extra ?? const {},
),
),
child: const Text('Send Feedback'),
);
}
}
Advanced users #
For advanced users there is a package called package:publishable_core that may better suit your needs. It doesn't include most of the dependencies that publishable contains, so you can use packages of your choice.
Additional information #
- This package requires at least Flutter 3.32 and Dart 3.8 to work.
- If there are any issues feel free to go to GitHub Issues and report a bug.