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

SDKDart

Creates a .dart file containing constants that included javascript code read from specified files by using @TextAsset annotation.

Inspired by aspen but specified for using npm modules in flutter_js

Features #

  • Creates a .dart file containing constants that included javascript code read from specified files by using @TextAsset annotation.

Getting started #

flutter pub add -d build_runner
flutter pub add flutter_js_asset

To build, type

flutter pub run build_runner build

To test, type

flutter pub run build_runner test

Usage #

  1. Create a npm module in web folder or any other folders are whitelisted because by default package:build only allows you to use assets from a pre-defined whitelist of directories.

  2. Installs packages you'd like to use and

  3. Create a index.js and exports modules to global object like this:

module.exports.lib = require('name/of/module');
  1. Generates a bundle.js by using webpack.
  2. Creates a dart file like this:
library example;

import 'package:flutter_js_asset/annotations.dart';

part 'example.g.dart';

@TextAsset('asset:example/web/dist/bundle.js')
const String jsCode = $jsCodeContent;
  1. Generates $jsCodeContent by typing:
flutter pub run build_runner build

see example for more details.

2
likes
90
pub points
3%
popularity

Publisher

verified publishercuilian.io

Creates a .dart file containing constants that included javascript code read from specified files by using @TextAsset annotation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

analyzer, build, source_gen

More

Packages that depend on flutter_js_asset