Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hychen/flutter_js_context

Enhances the interoperability between Dart and flutter_js.
https://github.com/hychen/flutter_js_context

flutter

Last synced: about 2 months ago
JSON representation

Enhances the interoperability between Dart and flutter_js.

Awesome Lists containing this project

README

        

This package enhances the interoperability between Dart and [flutter_js](https://pub.dev/documentation/flutter_js/latest/).

## Features

Use this package to

- Track which variables are defined.
- Decode evaluated results that the type is assumed as JSON always.
- Load JavaScript file properly.

## Getting started

```shell
flutter pub add flutter_js_context
```

## Usage

```dart
import 'package:flutter_js_context/flutter_js_context.dart';

void main() {
final context = JsContext();

JsRef obj = JsRef.define(context, 'myvar', '1');

// equals 'var myvar[ref.key] = 4;' in JavaScript.
obj.update("4");

// plus the object's value which is 4 and 4 in javascript runtime.
context.evaluate("${obj.toJsCode()} + 4"); // 8

// plus the object's value which is 8 and 4 in dart.
print(obj.value + 4); // 12
}
```

See `test` for more usage.

##