fireside_flutter 0.3.0 copy "fireside_flutter: ^0.3.0" to clipboard
fireside_flutter: ^0.3.0 copied to clipboard

Run a Fireside Interview inside your Flutter app as a full-screen native modal. A thin Dart wrapper over the Fireside Android and iOS SDKs.

example/lib/main.dart

import 'package:fireside_flutter/fireside_flutter.dart';
import 'package:flutter/material.dart';

const String apiKey = String.fromEnvironment('FIRESIDE_API_KEY');
const String studyId = String.fromEnvironment('FIRESIDE_STUDY_ID');
const String userId = String.fromEnvironment(
  'FIRESIDE_USER_ID',
  defaultValue: 'example-user',
);

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Fireside.init(apiKey);
  Fireside.identify(userId);
  runApp(const ExampleApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Fireside example',
      home: InterviewScreen(),
    );
  }
}

class InterviewScreen extends StatefulWidget {
  const InterviewScreen({super.key});

  @override
  State<InterviewScreen> createState() => _InterviewScreenState();
}

class _InterviewScreenState extends State<InterviewScreen> {
  bool _presenting = false;
  String _outcome = 'No interview run yet.';

  bool get _configured => apiKey.isNotEmpty && studyId.isNotEmpty;

  Future<void> _present() async {
    setState(() {
      _presenting = true;
      _outcome = 'Presenting…';
    });

    final result = await Fireside.present(studyId);
    if (!mounted) return;

    setState(() {
      _presenting = false;
      _outcome = _describe(result);
    });
  }

  static String _describe(InterviewResult result) => switch (result) {
    InterviewCompletedNoReviewNeeded() => 'Submitted — nothing left to do.',
    InterviewCompletedPendingReview() => 'Submitted — a review is pending.',
    InterviewScreenedOut() => 'Did not qualify for this study.',
    InterviewUserExited() => 'Closed part-way through.',
    InterviewStudyUnavailable() => 'This study is not open right now.',
    InterviewPermissionDenied() => 'Camera or microphone was denied.',
    InterviewFailed(:final reason) => 'Could not run: ${reason.name}.',
    InterviewTechRejected(:final reason) => 'Rejected: ${reason.name}.',
  };

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Fireside example')),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(24),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(_outcome, textAlign: TextAlign.center),
              const SizedBox(height: 24),
              FilledButton(
                onPressed: _presenting || !_configured ? null : _present,
                child: const Text('Start interview'),
              ),
              if (!_configured) ...[
                const SizedBox(height: 24),
                const Text(
                  'Run with --dart-define=FIRESIDE_API_KEY=… and '
                  '--dart-define=FIRESIDE_STUDY_ID=… to enable the button.',
                  textAlign: TextAlign.center,
                ),
              ],
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
186
downloads

Documentation

API reference

Publisher

verified publisherfireside.ai

Weekly Downloads

Run a Fireside Interview inside your Flutter app as a full-screen native modal. A thin Dart wrapper over the Fireside Android and iOS SDKs.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on fireside_flutter

Packages that implement fireside_flutter