Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Transpile jsx to dart widgets

Resources

Stars

54 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages