National Pest Management

    flutterjsx
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.17 • Public • Published

    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.

    Install

    npm i flutterjsx

    DownloadsWeekly Downloads

    42

    Version

    1.0.17

    License

    MIT

    Unpacked Size

    48.5 kB

    Total Files

    35

    Last publish

    Collaborators

    • danieldev