Skip to content

Commit be9e50b

Browse files
blueneogeogitbook-bot
authored andcommitted
GitBook: [#117] No subject
1 parent 2b70d54 commit be9e50b

32 files changed

+220
-229
lines changed
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Introduction
22

3-
\*\*\*\*[**Flutter-view**](https://flutter-view.io) is an open source tool that makes writing reactive [Flutter](http://flutter.io) layouts a breeze. It lets you use [Pug](http://pugjs.org) and [Sass](http://sass-lang.com) \(or HTML and CSS if you prefer\) to generate the Flutter Dart code that renders the views in your app.
3+
****[**Flutter-view**](https://flutter-view.io) is an open source tool that makes writing reactive [Flutter](http://flutter.io) layouts a breeze. It lets you use [Pug](http://pugjs.org) and [Sass](http://sass-lang.com) (or HTML and CSS if you prefer) to generate the Flutter Dart code that renders the views in your app.
44

55
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.
66

7+
Flutter-view 2.0.0 fully supports writing null-safe code in Dart 2.13 and up.
8+
79
## Why views in Flutter
810

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

1113
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.
1214

13-
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.
15+
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.
1416

1517
## Creating a view
1618

@@ -116,7 +118,7 @@ You can also fully leverage both Pug and Sass mixin and function support, allowi
116118

117119
## Making it Reactive
118120

119-
Flutter-view does not force you into any particular Reactive model. For example it works well with streams. However, it comes with native [ScopedModel ](https://pub.dartlang.org/packages/scoped_model)support and a [small Dart support library](https://pub.dartlang.org/packages/flutter_view_tools) for terse reactive coding:
121+
Flutter-view does not force you into any particular Reactive model. For example it works well with streams. However, it comes with native [ScopedModel ](https://pub.dartlang.org/packages/scoped\_model)support and a [small Dart support library](https://pub.dartlang.org/packages/flutter\_view\_tools) for terse reactive coding:
120122

121123
{% tabs %}
122124
{% tab title="user.dart" %}
@@ -160,5 +162,4 @@ Widget Hello({user}) {
160162
{% endtab %}
161163
{% endtabs %}
162164

163-
The view \(hello.pug\) takes a User \(user.dart\) 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.
164-
165+
The view (hello.pug) takes a User (user.dart) 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.

faq.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ You use the Pug or HTML files to define flutter-views, which flutter-view will c
1212

1313
You can use the Sass or CSS files to add style properties to the widget trees.
1414

15-
For reactive programming, it uses the fantastic [**scoped\_model library**](https://pub.dartlang.org/packages/scoped_model), in combination with a new pattern where the model is passed into a view, and rendered with a ReactiveWidget. This removes the need for ScopedModel and ScopedModelDescendant, and separating the concerns of state and view. However you are also free to use other patterns, such as streams.
15+
For reactive programming, it uses the fantastic [**scoped\_model library**](https://pub.dartlang.org/packages/scoped\_model), in combination with a new pattern where the model is passed into a view, and rendered with a ReactiveWidget. This removes the need for ScopedModel and ScopedModelDescendant, and separating the concerns of state and view. However you are also free to use other patterns, such as streams.
1616

1717
## How stable and complete is it?
1818

19-
Flutter-view is pretty much complete at this point. We have been using it at my company for half a year, and fixed many bugs and contributed features in the process. With the 1.0.0 release, it is stable, fast and fully documented.
19+
Flutter-view is pretty much complete at this point. We have been using it at my company for half a year, and fixed many bugs and contributed features in the process. With the 1.0.0 release, it was stable, fast and fully documented. With the 2.0.0 release, null-safety is supported as well.
2020

2121
## Is it free? How is it licensed?
2222

23-
Flutter-view is completely free and open source, licensed throught the[ **BSD-3 open source license**](https://github.com/flutter-view/flutter-view/blob/master/LICENSE). Please enjoy!
23+
Flutter-view is completely free and open source, licensed through the[ **BSD-3 open source license**](https://github.com/flutter-view/flutter-view/blob/master/LICENSE). Please enjoy!
2424

2525
## Who built this and why?
2626

2727
Flutter-view was created by Christian Vogel. I am a software developer and entrepreneur who loves new technology. I found Flutter to have a great developer experience, but missed the clear separations of concerns and patterns that I enjoyed in frameworks like Vue.js and React. With Flutter-view I scratched my own itch, was able to use it in my company, and hope it can also help you. If you encounter any issues or have suggestions, please post an [issue on Github](https://github.com/flutter-view/flutter-view/issues), or contact me on Twitter at [http://twitter.com/christianvogel](http://twitter.com/christianvogel).
28-

get-started/examples.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ Examples can help to show some good patterns for creating elegant apps. These ar
44

55
### [Testdrive](https://github.com/flutter-view/examples/tree/master/testdrive)
66

7-
![](../.gitbook/assets/screen-shot-2018-12-02-at-2.53.13-pm.png)
7+
![](<../.gitbook/assets/Screen Shot 2018-12-02 at 2.53.13 PM.png>)
88

99
This is the **getting started project** as explained in the[ test drive chapter](test-drive.md) of the documentation. It shows a simple hello world using pug and sass.
1010

1111
### [Counter](https://github.com/flutter-view/examples/tree/master/counter)
1212

13-
![](../.gitbook/assets/screen-shot-2018-12-03-at-12.16.29-am.png)
13+
![](<../.gitbook/assets/Screen Shot 2018-12-03 at 12.16.29 AM.png>)
1414

15-
A flutter-view version of the Flutter starter project. It uses the **reactive** tag and the [flutter-view-tools library ](https://pub.dartlang.org/packages/flutter_view_tools)for responding and updating the count.
15+
A flutter-view version of the Flutter starter project. It uses the **reactive** tag and the [flutter-view-tools library ](https://pub.dartlang.org/packages/flutter\_view\_tools)for responding and updating the count.
1616

1717
Instead of having the counter state in the widgets, it is kept in the application model, and the HomePage flutter-view listenes to the model and updates itself when the user presses the + button.
1818

1919
### [Todolist](https://github.com/flutter-view/examples/tree/master/todolist)
2020

21-
![](../.gitbook/assets/screen-shot-2018-12-03-at-12.18.00-am.png)
22-
23-
An example of how you can build a simple todo app using flutter-view and the [flutter-view-tools library](https://pub.dartlang.org/packages/flutter_view_tools). It separates the app model from the page model. This is a structure that can scale as your app grows and you add more pages. The [Writing Reactive code](../guide/writing-reactive-code.md) chapter builds this app step by step.
21+
![](<../.gitbook/assets/Screen Shot 2018-12-03 at 12.18.00 AM.png>)
2422

23+
An example of how you can build a simple todo app using flutter-view and the [flutter-view-tools library](https://pub.dartlang.org/packages/flutter\_view\_tools). It separates the app model from the page model. This is a structure that can scale as your app grows and you add more pages. The [Writing Reactive code](../guide/writing-reactive-code.md) chapter builds this app step by step.

get-started/installation.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Install
22

3+
_Important: going from version 2.0.0 and forward, flutter-view supports Dart 2.13 and up, enforcing null-safety. This means **breaking changes**. If you have a legacy project, stay at a version below 2.0.0, in both flutter-view and the flutter-view-widgets library which has also been updated._
4+
35
## Requirements
46

57
Flutter-view is an npm project and requires a working [NodeJS](https://nodejs.org/en/) installation. Of course you should have a working Flutter install as well.
@@ -14,18 +16,20 @@ On a Mac add sudo:
1416

1517
> `sudo npm install -g flutter-view`
1618
19+
_Important: the modern version of flutter-view is for Dart 2.13 and higher, and support type safety. If you have an older project, install_ `flutter-view@1.0.3` _instead._
20+
1721
_Note: you may need to add **--unsafe-perm** for things to work due to an_ [_issue with node-gyp_](https://github.com/nodejs/node-gyp/issues/454)
1822

1923
To test your installation worked, type the flutter-view command in your Terminal or console:
2024

21-
> `flutter-view`
25+
> `>> flutter-view`
2226
>
23-
> `flutter-view - flutter template code generator
24-
> Converts html and css templates into Flutter view widget code.
25-
> Please pass a directory to scan.
26-
> flutter-view -h for help.`
27+
> `flutter-view - flutter template code generator` \
28+
> `Converts html and css templates into Flutter view widget code.` \
29+
> `Please pass a directory to scan.` \
30+
> `flutter-view -h for help.`
2731
28-
If you got the above text, your installation was succesfull.
32+
If you got the above text, your installation was successful.
2933

3034
## Installing flutter-view-widgets
3135

@@ -35,11 +39,15 @@ Flutter-view has an optional Dart tooling library. It allows you to use the reac
3539

3640
To install it, add the following dependency to your project **pubspec.yaml** file:
3741

38-
> `flutter_view_widgets: ^1.0.6`
42+
> `flutter_view_widgets: ^2.0.0-dev.1`
43+
44+
_Important: the modern version of flutter-view is for Dart 2.13 and higher, and support type safety. If you have an older project, use the following:_
45+
46+
> `flutter_view_widgets: 1.0.6`
3947
4048
Then perform a flutter packages get to pull in the new dependency.
4149

42-
_Note: for the latest version, check the_ [_flutter-view-widgets pub page_](https://pub.dev/packages/flutter_view_widgets)_._
50+
_Note: for the latest version, check the_ [_flutter-view-widgets pub page_](https://pub.dev/packages/flutter\_view\_widgets)_._
4351

4452
### Importing the tools
4553

@@ -50,4 +58,3 @@ To import the library in Dart:
5058
To import the library in a Pug file:
5159

5260
`import(package='flutter_view_widgets/flutter_view_widgets.dart')`
53-

get-started/test-drive.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Open the project in your favorite editor. [VS Code](https://code.visualstudio.co
1818

1919
Try running the test project in an emulator to see if it all works.
2020

21-
## Adding a screen using flutter-view
21+
## Adding a screen using flutter-view&#x20;
2222

2323
Now that we have a working project, let's create a flutter-view that shows a simple welcome screen.
2424

2525
In the lib directory of your project, add a directory called "**screens**". In it create a directory "**homepage**". In the homepage directory, create a file named **homepage.pug**.
2626

27-
![](../.gitbook/assets/screen-shot-2018-11-28-at-4.37.33-pm.png)
27+
![](<../.gitbook/assets/Screen Shot 2018-11-28 at 4.37.33 PM.png>)
2828

2929
Now let's create our first flutter-view. Open **homepage.pug** and put in the following pug code:
3030

@@ -78,15 +78,15 @@ Scaffold HomePage() {
7878
```
7979
{% endcode %}
8080

81-
You may notice the comments referring back to the Pug file. These can be turned off, but help the [VSCode flutter-view plugin](vs-code-support.md#linking-between-pug-and-generated-dart) \(and you\) easily navigate between the Pug file and the Dart file.
81+
You may notice the comments referring back to the Pug file. These can be turned off, but help the [VSCode flutter-view plugin](vs-code-support.md#linking-between-pug-and-generated-dart) (and you) easily navigate between the Pug file and the Dart file.
8282

83-
Also, notice comments are created for **\#title** and **.greeting** ids and classes in the pug file. These can also be turned off if you wish.
83+
Also, notice comments are created for **#title** and **.greeting** ids and classes in the pug file. These can also be turned off if you wish.
8484

8585
## Using the new homepage
8686

8787
A view is simply a Dart function that renders some widgets. This means you can use it in your application as any other Flutter function. Let's change **main.dart** to show our new homepage:
8888

89-
At the top of main.dart, import our new dart file:
89+
At the top of main.dart, import our new dart file:&#x20;
9090

9191
> `import 'screens/homepage/homepage.dart';`
9292

@@ -99,11 +99,11 @@ home: HomePage(),
9999

100100
Now refresh your app, and you should see this:
101101

102-
![](../.gitbook/assets/screen-shot-2018-11-28-at-5.18.29-pm.png)
102+
![](<../.gitbook/assets/Screen Shot 2018-11-28 at 5.18.29 PM.png>)
103103

104104
## Hot Reload
105105

106-
One of the powerful features in Flutter is hot reload. You can do the same thing with flutter-view.
106+
One of the powerful features in Flutter is hot reload. You can do the same thing with flutter-view.&#x20;
107107

108108
Start flutter-view in watch mode in your project directory:
109109

@@ -128,7 +128,7 @@ In the same directory as **homepage.pug**, create a new file called **homepage.s
128128

129129
Press hot refresh in your emulator and you will now see the greeting styled:
130130

131-
![](../.gitbook/assets/screen-shot-2018-12-02-at-3.16.58-pm.png)
131+
![](<../.gitbook/assets/Screen Shot 2018-12-02 at 3.16.58 PM.png>)
132132

133133
Now let's add an image. We can choose to use a NetworkImage directly, or to use a background decoration on a container. To do the latter, we need to add the cover container for the image. Since we want to have the image and text to be centered together, we can wrap them in a [FittedBox](https://docs.flutter.io/flutter/widgets/FittedBox-class.html) widget. To do so, change **homepage.pug**:
134134

@@ -158,7 +158,7 @@ Flutter-view has [shortcuts](../reference/css-properties.md) that recognise CSS-
158158

159159
The result should look like this:
160160

161-
![](../.gitbook/assets/screen-shot-2018-12-02-at-2.53.13-pm.png)
161+
![](<../.gitbook/assets/Screen Shot 2018-12-02 at 2.53.13 PM.png>)
162162

163163
If you look at the generated **homepage.dart**, you will see how flutter-view took homepage.pug and homepage.sass and merged them:
164164

@@ -222,4 +222,3 @@ Feel free to play around with some CSS styles to see effect. Some of the things
222222
* instead of a background image, give the **.cover** class a `background-color: blue`.
223223

224224
Currently you need to press the hot refresh button in your emulator to see changes. In the next section we add Visual Studio Code support so this will happen immediately when you change your .pug or .sass file.
225-

get-started/usage.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ The flutter-view command is:
44

55
> `flutter-view [options] <directory [, directory...]>`
66
7-
Flutter-view scans for Pug and HTML files in one or more directories. For it to work, you need to pass where your source code is. Normally this is the **lib** directory of your project.
7+
Flutter-view scans for Pug and HTML files in one or more directories. For it to work, you need to pass where your source code is. Normally this is the **lib** directory of your project.&#x20;
88

99
In almost every case, you want to go to your project directory and type:
1010

1111
> `flutter-view -w lib`
1212
13-
This will tell flutter-view to watch your lib directory, and keep watching \(-w\) for changes.
13+
This will tell flutter-view to watch your lib directory, and keep watching (-w) for changes.
1414

1515
When flutter-view creates or updates Dart files, it will tell you:
1616

17-
![](../.gitbook/assets/screen-shot-2018-12-04-at-12.36.39-am.png)
18-
17+
![](<../.gitbook/assets/Screen Shot 2018-12-04 at 12.36.39 AM.png>)

get-started/vs-code-support.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Enabling linking between Pug and Dart will make it easier to see the effects of
1111
* the [**flutter-view extension**](https://marketplace.visualstudio.com/items?itemName=blueneogeo.flutter-view-vscode) lets you link from Pug to generated Dart
1212
* the [**project-links extension**](https://marketplace.visualstudio.com/items?itemName=KyleDavidE.vscode-project-links) lets you link from links in the generated Dart to the source Pug
1313

14-
_Note: for this to work, the project link comments in flutter-view must be enabled \(default is on\)_
14+
_Note: for this to work, the project link comments in flutter-view must be enabled (default is on)_
1515

1616
## Enabling hot refresh for Pug and Sass files
1717

@@ -26,7 +26,7 @@ To enable this, we need to do two things:
2626

2727
### Adding the hot reload commands
2828

29-
After installing the extension, press `cmd+shift+P` to open the command palette in VSCode and pick the **Preferences: Open Settings \(JSON\)** command to open your settings.
29+
After installing the extension, press `cmd+shift+P` to open the command palette in VSCode and pick the **Preferences: Open Settings (JSON)** command to open your settings.
3030

3131
In the **JSON settings** under either _Workspace settings_ or _User settings_, add the following extra configuration:
3232

@@ -64,15 +64,14 @@ In the **JSON settings** under either _Workspace settings_ or _User settings_, a
6464

6565
Your settings should like something like this:
6666

67-
![](../.gitbook/assets/screen-shot-2018-12-01-at-4.05.42-pm.png)
67+
![](<../.gitbook/assets/Screen Shot 2018-12-01 at 4.05.42 PM.png>)
6868

6969
Save your settings afterwards.
7070

7171
### Testing the hot reload
7272

73-
Now try opening the test drive project from the previous chapter \(or your own flutter-view project\) and run it in the emulator.
73+
Now try opening the test drive project from the previous chapter (or your own flutter-view project) and run it in the emulator.
7474

7575
Changing the Pug or Sass and saving it should now automatically make the changes visible in your running application.
7676

7777
Congratulations, you are all ready to start making your flutter-view enabled Flutter app!
78-

0 commit comments

Comments
 (0)