Giter Site home page Giter Site logo

flutterjsx's Introduction

Flutter.js Transpile JSX to dart widgets

NPM Version

Install

npm i -g flutterjsx

Beta Version

Hello Home !

As you know Flutter comes with dirty syntax, therefore I decided to develop jsx transpiler for flutter.

Demo in Youtube

Usage

$ cd YOUR_FLUTTER_APP_PATH

and Run:

$ flutterjsx

1 - Flutter Widget (flutter_app/lib/HomePage.dart):

import 'package:flutter/material.dart';
class HomePageView extends StatelessWidget {
  static final jsxView = "HomePageView.jsx";
  static final spaces = "  ";

  build(BuildContext context) {
  }
  // afterBuild
}

jsxView is required.

spaces is optional.

// afterBuild is required.

2 -JSX (flutter_app/lib/HomePageView.jsx):

const style = {
  wrapper: {
    padding: "32.0",
    margin: { top: 30, bottom: 10 },
  },
  text: {
    fontSize: 20,
  },
};

export default (
  <Container
    {...style.wrapper}
    decoration={<BoxDecoration borderRadius={{ topLeft: 20 }} color="#111" />
  >
    <Text style={style.text} text={"This is a simple text"} />
  </Container>
);

Other ways:

<Container decoration={<BoxDecoration borderRadius={10} color="#111" />}/>
<Container decoration={<BoxDecoration borderRadius={'50 50 0 0'} color="#111" />}/>

and after save hit (ctrl + f5 in vscode) to force hot reload.

3 - Output

I wish to make it prettier in future.

import 'package:flutter/material.dart';

class HomePageView extends StatelessWidget {
  static final jsxView = "HomePageView.jsx";
  static final spaces = "  ";

  build(BuildContext context) {
    return Container(
      child: Text("This is a simple text",
          style: TextStyle(
            fontSize: 15,
            color: Color(0xFF111111),
          )),
      padding: EdgeInsets.all(32.0),
      margin: EdgeInsets.only(top: 30, bottom: 10),
      color: Colors.red,
    );
  }
  // afterBuild
}

That's it Javascript + Flutter will kill it.

License

WTF.

flutterjsx's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

5vwhm wangzhengbo

flutterjsx's Issues

How did you do this?

Hey-- how did you manage to do this?

I want to be able to convert JSX in Dart (but in the same file).

I can use babel, but I don't get how you made this work, can Babel output dart?

Let me know if you're still around please

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.