flutter_exprtk 0.0.4 copy "flutter_exprtk: ^0.0.4" to clipboard
flutter_exprtk: ^0.0.4 copied to clipboard

outdated

flutter_exprtk is a FFI wrapper for the exptrk Mathematical Expression Toolkit Library

example/lib/main.dart

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_exprtk/flutter_exprtk.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  static Future<List<double>> computeExpression(dynamic param) async {
    final exp2 = Expression(
        expression: "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)",
        variables: {"x": 0});
    final List<double> results = [];

    for (double x = -5; x <= 5; x += 0.001) {
      exp2["x"] = x;
      results.add(exp2.value);
    }
    exp2.clear();

    return results;
  }

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Expression plugin example'),
        ),
        body: Center(
            child: OutlinedButton(
          onPressed: () async {
            final results = await compute(computeExpression, null);
            print("Results $results");
          },
          child: Text("Run"),
        )),
      ),
    );
  }
}
11
likes
0
pub points
0%
popularity

Publisher

unverified uploader

flutter_exprtk is a FFI wrapper for the exptrk Mathematical Expression Toolkit Library

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

ffi, flutter

More

Packages that depend on flutter_exprtk