GithubHelp home page GithubHelp logo

flutter_js_asset's Introduction

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.

flutter_js_asset's People

Contributors

hychen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.