flutter_which 0.0.1 copy "flutter_which: ^0.0.1" to clipboard
flutter_which: ^0.0.1 copied to clipboard

A flutter plugin which provides 'which' rust crate

example/lib/main.dart

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

Future<void> main() async {
  await FlutterWhichLib.init();
  runApp(const MyApp());
}

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

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

enum _Mode { which, whichAll }

class _MyAppState extends State<MyApp> {
  var paths = const <String>[];
  var mode = _Mode.whichAll;
  Object? error;

  void _handleChange(String value) {
    try {
      which(binaryName: value);
      paths = switch (mode) {
        _Mode.which => [which(binaryName: value)],
        _Mode.whichAll => whichAll(binaryName: value),
      };
      setState(() {
        error = null;
      });
    } catch (e) {
      setState(() {
        error = e;
        paths = const [];
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('flutter_rust_bridge quickstart')),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            TextField(onChanged: _handleChange),
            if (error != null)
              Text('An error occurred: $error'),
            Expanded(
              child: ListView(
                children: [for (final path in paths) Text('Found: $path')],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter plugin which provides 'which' rust crate

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_rust_bridge, freezed_annotation, plugin_platform_interface

More

Packages that depend on flutter_which