All Projects → flutter-view → flutter-view

flutter-view / flutter-view

Licence: BSD-3-Clause license
Create flutter view widgets using pug and sass

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to flutter-view

generator-espress
an opinionated yeoman generator that scaffolds a mvc express webapp completely in es6
Stars: ✭ 20 (-84.37%)
Mutual labels:  mvc, pug
kontent-boilerplate-express-apollo
Kontent Boilerplate for development of Express application using Apollo server and GraphQL.
Stars: ✭ 21 (-83.59%)
Mutual labels:  mvc, pug
MVVM-Design-Pattern-Demo
An Xcode 9 project written in Swift 4 code designed using the MVVM design pattern, truly extolling the virtues of MVVM over MVC.
Stars: ✭ 31 (-75.78%)
Mutual labels:  mvc
soosyze
🌠 Soosyze CMS is a minimalist content management system in PHP, without database to create and manage your website easily. https://soosyze.com
Stars: ✭ 39 (-69.53%)
Mutual labels:  mvc
RouteManager
iOS模块化,模块间解耦,路由中心设计
Stars: ✭ 45 (-64.84%)
Mutual labels:  mvc
ubereats-api
🍕 ubereats api for the ios: Express.js and Yelp api
Stars: ✭ 20 (-84.37%)
Mutual labels:  mvc
BotBlock.org
BotBlock - The List of Discord Bot Lists and Services
Stars: ✭ 29 (-77.34%)
Mutual labels:  pug
bit-css
用原子类赋予元素属性,减少甚至不写css
Stars: ✭ 19 (-85.16%)
Mutual labels:  pug
giada-www
Official website of Giada Loop Machine. Powered by NodeJS, SASS, Pug and other beautiful JavaScript machineries.
Stars: ✭ 13 (-89.84%)
Mutual labels:  pug
AspNetCoreMvcAngular
ASP.NET Core MVC with angular in MVC View OpenID Connect Hybrid Flow
Stars: ✭ 54 (-57.81%)
Mutual labels:  mvc
Fee-movie2.0
整合了几个常用的电影网站,获取资源更方便,更新中
Stars: ✭ 33 (-74.22%)
Mutual labels:  pug
auction-website
🏷️ An e-commerce marketplace template. An online auction and shopping website for buying and selling a wide variety of goods and services worldwide.
Stars: ✭ 44 (-65.62%)
Mutual labels:  mvc
simple-mvc
Simple push & pull MVC framework to realize a test-driven experience.
Stars: ✭ 24 (-81.25%)
Mutual labels:  mvc
spring-web-initializr
Spring Web Initializr is a library that helps you easily create Web Apps with Spring Boot.
Stars: ✭ 16 (-87.5%)
Mutual labels:  mvc
sinatras-skeleton
Basic Sinatra Skeleton MVC CRUD App with Sprockets, Warden, ActiveRecord and PostgresQL
Stars: ✭ 13 (-89.84%)
Mutual labels:  mvc
uJet
Umbraco Jet (uJet) is a Code First approach to building MVC applications in Umbraco 7.
Stars: ✭ 16 (-87.5%)
Mutual labels:  mvc
community
基于spring boot与mybatis搭建的社区
Stars: ✭ 18 (-85.94%)
Mutual labels:  mvc
puremvc-delphi-standard-framework
A Delphi implementation of PureMVC (http://puremvc.org/)
Stars: ✭ 44 (-65.62%)
Mutual labels:  mvc
Polyel-Framework
⚡️ Voltis Core: A PHP framework based on Swoole from the ground up
Stars: ✭ 22 (-82.81%)
Mutual labels:  mvc
web-starter-kit-gulp
Starter kit for automated front-end web development using Gulp, NPM, Bower, Babel, Sass, and Pug.
Stars: ✭ 35 (-72.66%)
Mutual labels:  pug

FLUTTER-VIEW

https://flutter-view.io

Flutter-view is a tool that makes writing reactive Flutter layouts a breeze. It lets you use Pug and Sass (or HTML and CSS if you prefer) to generate the Flutter Dart code that renders the views in your app.

You use it by running the flutter-view command in your terminal to let it monitor your project. When it detects changes in a Pug, HTML, Sass or CSS file, it automatically generates or updates a matching Dart file.

NOTE: From 2.0 on, Flutter-view generates null-safe code (Dart 2.12 and forward). Use an older version if you use an older version of Dart.

Why views in Flutter

In standard Flutter Dart code, the "state" of your application is mixed in with the presentation. This can make it hard to structure your code well.

Flutter-view is about creating views, which are functions that return a widget tree for presenting something. These functions act a bit like components. Flutter-view uses Pug to make layouts more terse and Sass to let you style faster and more easily. The state part comes into play when you make your view reactive. You can pass models (or streams) into your views. When these models change, the views automatically adapt.

Creating a view

A single flutter-view generates a Dart function that usually returns a widget tree. You use Pug to create a view, which gets transformed into HTML and then Dart code automatically:

Pug:

hello(flutter-view)
    .greeting Hello world!

Generated (internal) HTML:

<hello flutter-view>
    <div class="greeting">
        Hello world!
    </div>
</hello>

Generated Dart:

Container Hello() {
    return Container(
        child: Text("Hello world!")
    );
}

This generated function can be used like any other Dart code, and will return the code that gives the greeting.

Adding Styling

You can add Sass with CSS rules to style your view. Flutter-view contains plugins that take your CSS properties and convert them into code. For our example, you can easily add a text color, background color, some font properties, and add padding:

Pug:

hello(flutter-view)
    .greeting Hello world!

Sass:

.greeting
    color: red
    background-color: grey[200]
    text-transform: uppercase
    padding: 10 20

Generated Dart:

Hello() {
    return DefaultTextStyle.merge(
        style: TextStyle(
            color: Colors.red
        ),
        child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[200]
            ),
            padding: EdgeInsets.only(
                top: 10,
                right: 20,
                bottom: 10,
                left: 20
            ),
            child: Text("Hello world!".toUpperCase),
        )
    );
}

Flutter-view supports many CSS properties, and makes it easy to change styles and immediately see the effect. Since single CSS rules can apply to many elements, small CSS changes may have big code effects.

You can also fully leverage both Pug and Sass mixin and function support, allowing for some powerful patters, such as different styling based on running Android or iOS.

Making it Reactive

Flutter-view does not force you into any particular Reactive model. For example it works well with streams. However, it comes with native ScopedModel support and a small Dart support library for terse reactive coding:

user.dart:

class User extends Model {
    User({this.name, this.age});

    String name;
    int age;
}

hello.pug:

hello(flutter-view :user)
    reactive(watch='user')
        .greeting Hello ${user.name}!

generated hello.dart:

Widget Hello({user}) {
    return ReactiveWidget(
        watch: user as Listenable,
        builder: (context, $) {
            return Container(
                child: Text("Hello ${user.name}!")
            )
        },
    );
}

The view now takes a User as a parameter and watches it for changes. Now when we change the the user name and call user.notifyListeners(), the view will automatically update.

Requirements

  • Flutter
  • A working Typescipt installation (install using npm install -g typescript)

Getting Started

In your terminal of choice type:

npm install -g flutter-view

Building Locally

Only necessary if you want to modify flutter-view yourself.

Steps to build the project locally:

  1. clone this repository
  2. change to the project directory
  3. npm install
  4. tsc
  5. npm link

Typing flutter-view in any directory should now work.

Usage

In a terminal, go into the directory of your Flutter project, and type flutter-view -w lib. This should start the tool watching on your lib directory.

In general, use is as follows:

> flutter-view [-w] <directory>

You can use the following flags:

-V, --version        output the version number
-w, --watch          Watch for changes
-c, --config <file>  Optional config file to use (default: flutter-view.json)
-h, --help           output usage information

Full documentation

For a guide and reference to the pug and sass styles, check the online documentation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].