Skip to main content

heardock_flutter 0.1.0 copy "heardock_flutter: ^0.1.0" to clipboard
heardock_flutter: ^0.1.0 copied to clipboard

In-app feedback for Flutter. Drop a native bottom sheet into your app, collect context (version, device, screen) automatically, and read every note in one private inbox.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:heardock_flutter/heardock_flutter.dart';

const String _baseUrl = String.fromEnvironment(
  'HEARDOCK_BASE_URL',
  defaultValue: 'http://localhost:3000',
);

const String _publicKey = String.fromEnvironment(
  'HEARDOCK_PUBLIC_KEY',
  defaultValue: 'hd_pub_demo_fieldnote',
);

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  Heardock.configure(
    HeardockConfig(
      publicKey: _publicKey,
      baseUrl: _baseUrl,
      debug: true,
      theme: const HeardockTheme(
        // A slightly deeper orange keeps white button text at 4.5:1.
        primaryColor: Color(0xFFC9431C),
        borderRadius: 16,
      ),
    ),
  );

  // Optional: tell Heardock which screen the user is on. Route changes can
  // call this again (or simply let the SDK read the ModalRoute name).
  Heardock.setContext(
      page: '/today', metadata: <String, dynamic>{'plan': 'pro'});

  runApp(const FieldnoteApp());
}

class FieldnoteApp extends StatelessWidget {
  const FieldnoteApp({super.key});

  @override
  Widget build(BuildContext context) {
    const seed = Color(0xFFE4572E);
    return MaterialApp(
      title: 'Fieldnote',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        useMaterial3: true,
        colorSchemeSeed: seed,
        scaffoldBackgroundColor: const Color(0xFFF3EDE2),
        appBarTheme: const AppBarTheme(
          backgroundColor: Color(0xFFF3EDE2),
          surfaceTintColor: Colors.transparent,
          elevation: 0,
          centerTitle: false,
        ),
      ),
      home: const NotesHome(),
    );
  }
}

class NotesHome extends StatelessWidget {
  const NotesHome({super.key});

  static const List<({String title, String body, String tag})> _notes =
      <({String title, String body, String tag})>[
    (
      title: 'Export the Q4 field report',
      body: 'Try the new PDF layout — appendix first, maps last.',
      tag: 'PDF',
    ),
    (
      title: 'Site visit · North pier',
      body: 'Photos and measurements from the morning walk.',
      tag: 'Field',
    ),
    (
      title: 'Follow up with Ana',
      body: 'Share the revised timeline before Friday.',
      tag: 'Work',
    ),
  ];

  Future<void> _openFeedback(
    BuildContext context, {
    FeedbackPresentation? presentation,
  }) async {
    final result = await Heardock.show(context, presentation: presentation);
    if (!context.mounted || result == null) return;

    final message = result.queued
        ? 'Saved on this device. It will send when you are back online.'
        : 'Thanks — the team reads every note. Reference ${result.displayReference}.';
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        content: Text(message),
        behavior: SnackBarBehavior.floating,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final textTheme = theme.textTheme;

    return Scaffold(
      appBar: AppBar(
        titleSpacing: 20,
        title: Text(
          'Fieldnote',
          style: textTheme.titleLarge?.copyWith(
            fontWeight: FontWeight.w700,
            letterSpacing: -0.4,
          ),
        ),
        actions: <Widget>[
          IconButton(
            tooltip: 'Feedback',
            onPressed: () => Heardock.open(context),
            icon: const Icon(Icons.feedback_outlined),
          ),
          IconButton(
            tooltip: 'Quick feedback (sheet)',
            onPressed: () => _openFeedback(
              context,
              presentation: FeedbackPresentation.sheet,
            ),
            icon: const Icon(Icons.web_asset_outlined),
          ),
          const SizedBox(width: 8),
        ],
      ),
      body: ListView(
        padding: const EdgeInsets.fromLTRB(20, 8, 20, 32),
        children: <Widget>[
          Text(
            'WEDNESDAY, NOVEMBER 4',
            style: textTheme.labelSmall?.copyWith(
              letterSpacing: 1.2,
              fontWeight: FontWeight.w600,
              color: theme.colorScheme.onSurfaceVariant,
            ),
          ),
          const SizedBox(height: 4),
          Text(
            'Today',
            style: textTheme.displaySmall?.copyWith(
              fontWeight: FontWeight.w700,
              letterSpacing: -1,
            ),
          ),
          const SizedBox(height: 18),
          for (final note in _notes) ...<Widget>[
            _NoteCard(title: note.title, body: note.body, tag: note.tag),
            const SizedBox(height: 10),
          ],
          const SizedBox(height: 10),
          Container(
            padding: const EdgeInsets.all(18),
            decoration: BoxDecoration(
              color: const Color(0xFF1C1917),
              borderRadius: BorderRadius.circular(18),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                const Icon(Icons.record_voice_over_outlined,
                    color: Color(0xFFFFD9C8)),
                const SizedBox(height: 12),
                Text(
                  'Help shape Fieldnote',
                  style: textTheme.titleMedium?.copyWith(
                    color: const Color(0xFFFDF8EF),
                    fontWeight: FontWeight.w600,
                  ),
                ),
                const SizedBox(height: 4),
                Text(
                  'Bugs, ideas, questions — it goes straight to the team, with your version and screen attached.',
                  style: textTheme.bodySmall?.copyWith(
                    color: const Color(0xFFB9AC9C),
                    height: 1.45,
                  ),
                ),
                const SizedBox(height: 14),
                FilledButton.icon(
                  onPressed: () => _openFeedback(context),
                  icon: const Icon(Icons.send_rounded, size: 17),
                  label: const Text('Send feedback'),
                  style: FilledButton.styleFrom(
                    backgroundColor: const Color(0xFFE4572E),
                    foregroundColor: Colors.white,
                    minimumSize: const Size.fromHeight(46),
                  ),
                ),
              ],
            ),
          ),
          if (kDebugMode) ...<Widget>[
            const SizedBox(height: 16),
            Text(
              'POST $_baseUrl/v1/feedback · $_publicKey',
              textAlign: TextAlign.center,
              style: textTheme.labelSmall?.copyWith(
                color:
                    theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.7),
                fontFamily: 'monospace',
                fontSize: 9,
              ),
            ),
          ],
        ],
      ),
    );
  }
}

class _NoteCard extends StatelessWidget {
  const _NoteCard({required this.title, required this.body, required this.tag});

  final String title;
  final String body;
  final String tag;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return Container(
      padding: const EdgeInsets.fromLTRB(16, 14, 16, 14),
      decoration: BoxDecoration(
        color: const Color(0xFFFFFDF8),
        borderRadius: BorderRadius.circular(16),
        border: Border.all(color: const Color(0xFFE4DACB)),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(title,
              style: theme.textTheme.titleSmall
                  ?.copyWith(fontWeight: FontWeight.w600)),
          const SizedBox(height: 4),
          Text(
            body,
            style: theme.textTheme.bodySmall?.copyWith(
              color: theme.colorScheme.onSurfaceVariant,
              height: 1.45,
            ),
          ),
          const SizedBox(height: 10),
          Container(
            padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
            decoration: BoxDecoration(
              color: const Color(0xFFF2EBDD),
              borderRadius: BorderRadius.circular(999),
            ),
            child: Text(
              tag,
              style: theme.textTheme.labelSmall?.copyWith(
                color: const Color(0xFF6D6353),
                fontSize: 9,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
0
likes
150
points
41
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

In-app feedback for Flutter. Drop a native bottom sheet into your app, collect context (version, device, screen) automatically, and read every note in one private inbox.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, heardock_core

More

Packages that depend on heardock_flutter