parsec 0.3.1 copy "parsec: ^0.3.1" to clipboard
parsec: ^0.3.1 copied to clipboard

Multi-platform `parsec` plugin for Flutter to calculate math equations using C++ library. Supports android.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:parsec/parsec.dart';

void main() {
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {
  TextEditingController controller = TextEditingController();
  String _parsecResult = '';
  final Parsec _parsecPlugin = Parsec();

  Future<void> calculate() async {
    dynamic parsecResult;
    try {
      parsecResult = await _parsecPlugin.eval(controller.text);
    } catch (e) {
      parsecResult = e.toString();
    }

    setState(() {
      _parsecResult = parsecResult.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Parsec plugin example app')),
        body: Center(
          child: Container(
            padding: const EdgeInsets.all(16),
            child: Column(
              children: [
                TextField(controller: controller),
                TextButton(
                  onPressed: () => calculate(),
                  child: const Text('Calculate'),
                ),
                const SizedBox(height: 30),
                Expanded(
                  child: SingleChildScrollView(
                    child: Text(
                      _parsecResult,
                      style: const TextStyle(
                        fontSize: 18,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
4
likes
140
points
1.45k
downloads

Publisher

verified publisheroxeanbits.com

Weekly Downloads

Multi-platform `parsec` plugin for Flutter to calculate math equations using C++ library. Supports android.

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, parsec_android, parsec_linux, parsec_platform_interface, parsec_windows

More

Packages that depend on parsec