Skip to main content

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

Thin Flutter wrapper around the raptorq Rust crate (RaptorQ, RFC 6330).

example/lib/main.dart

import 'dart:async';

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await RaptorQFlutter.init();
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _status = 'Running encode/decode round-trip…';

  @override
  void initState() {
    super.initState();
    _runDemo();
  }

  Future<void> _runDemo() async {
    try {
      final data = List<int>.generate(1024 * 127, (i) => i & 0xFF);
      final encoder = await RaptorQEncoder.newInstance(data: data, mtu: 512);
      final oti = encoder.oti();
      final packets = await encoder.getEncodedPackets(
        repairPacketsPerBlock: 100,
      );

      final decoder = await RaptorQDecoder.newInstance(oti: oti);
      for (final packet in packets) {
        final recovered = await decoder.addPacket(packet: packet);
        if (recovered != null) {
          setState(
            () =>
                _status = 'Round-trip OK – recovered ${recovered.length} bytes',
          );
          return;
        }
      }
      setState(() => _status = 'Decoding failed');
    } catch (e) {
      setState(() => _status = 'Error: $e');
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('RaptorQ Flutter example')),
        body: Center(child: Text(_status)),
      ),
    );
  }
}
0
likes
150
points
497
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Thin Flutter wrapper around the raptorq Rust crate (RaptorQ, RFC 6330).

Repository
View/report issues

Topics

#raptorq #fountain-code #forward-error-correction #ffi #rust

License

MIT (license)

Dependencies

code_assets, flutter, flutter_rust_bridge, hooks, native_toolchain_rust

More

Packages that depend on raptorq_flutter