Skip to main content

sayspec_flutter_recorder 0.9.0 copy "sayspec_flutter_recorder: ^0.9.0" to clipboard
sayspec_flutter_recorder: ^0.9.0 copied to clipboard

SaySpec Flutter recording SDK. Emits widget-level interaction evidence that SaySpec turns into Patrol tests.

example/lib/main.dart

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

final GlobalKey recordingSurfaceKey = GlobalKey();

const String recordingUrl = String.fromEnvironment('SAYSPEC_RECORDING_URL');
const String recordingSessionId = String.fromEnvironment(
  'SAYSPEC_RECORDING_SESSION',
);
const String recordingSessionToken = String.fromEnvironment(
  'SAYSPEC_RECORDING_TOKEN',
);
const String recordingProjectId = String.fromEnvironment(
  'SAYSPEC_RECORDING_PROJECT',
);

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  if (recordingUrl.isNotEmpty) {
    await SaySpecRecorder.instance.initialize(
      SaySpecRecorderOptions(
        baseUrl: recordingUrl,
        projectId: recordingProjectId,
        sessionId: recordingSessionId,
        sessionToken: recordingSessionToken.isEmpty
            ? null
            : recordingSessionToken,
        appId: 'dev.sayspec.recorder_example',
        screenshotBoundaryKey: recordingSurfaceKey,
        autoStart: true,
      ),
    );
  }
  runApp(const RecorderExample());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: <NavigatorObserver>[SaySpecRecorder.instance],
      builder: (BuildContext context, Widget? child) => RepaintBoundary(
        key: recordingSurfaceKey,
        child: child ?? const SizedBox.shrink(),
      ),
      home: const _CounterPage(),
    );
  }
}

class _CounterPage extends StatefulWidget {
  const _CounterPage();

  @override
  State<_CounterPage> createState() => _CounterPageState();
}

class _CounterPageState extends State<_CounterPage> {
  int count = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Recorder example')),
      body: Center(
        child: Text(
          'Count: $count',
          key: const ValueKey<String>('counter_value'),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        key: const ValueKey<String>('counter_increment'),
        onPressed: () {
          setState(() => count += 1);
          SaySpecRecorder.instance.mark('counter incremented');
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
0
likes
0
points
350
downloads

Publisher

verified publisherjoe-it-solutions.com

Weekly Downloads

SaySpec Flutter recording SDK. Emits widget-level interaction evidence that SaySpec turns into Patrol tests.

Homepage

Topics

#testing #flutter #automation #qa

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on sayspec_flutter_recorder