Skip to content

Commit 8f5f930

Browse files
blueneogeogitbook-bot
authored andcommitted
GitBook: [#119] No subject
1 parent be9e50b commit 8f5f930

11 files changed

+124
-156
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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) to generate the Flutter Dart code that renders the views in your app.
44

5-
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.
5+
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 or Sass file, it automatically generates or updates a matching Dart file.
66

77
Flutter-view 2.0.0 fully supports writing null-safe code in Dart 2.13 and up.
88

@@ -16,7 +16,7 @@ The state part comes into play when you make your view **reactive**. You can pas
1616

1717
## Creating a view
1818

19-
A single flutter-view generates a Dart function that usually returns a widget tree. You can either use Pug or HTML:
19+
A single flutter-view in pug generates a Dart function that usually returns a widget tree.
2020

2121
{% tabs %}
2222
{% tab title="Pug" %}
@@ -59,7 +59,7 @@ This generated function can be used like any other Dart code, and will return th
5959

6060
## Adding Styling
6161

62-
You can add Sass/CSS to styles to your view. Flutter-view supports [CSS style properties](reference/css-properties.md) that convert into code. For our example, you can easily add a text [**color**](reference/css-properties.md#color-color), [**background color**](reference/css-properties.md#box-shadow-2), some [**font properties**](reference/css-properties.md#box-shadow-8), and add [**padding**](reference/css-properties.md#padding):
62+
You can add Sass to style your view. These styles get mixed with your pug to generate styled Dart code. Flutter-view supports [CSS style properties](reference/css-properties.md) that convert into code. For our example, you can easily add a text [**color**](reference/css-properties.md#color-color), [**background color**](reference/css-properties.md#box-shadow-2), some [**font properties**](reference/css-properties.md#box-shadow-8), and add [**padding**](reference/css-properties.md#padding):
6363

6464
{% tabs %}
6565
{% tab title="Pug" %}

faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Flutter-view is a tool for creating Flutter Dart code, meant to make it easier t
88

99
Flutter-view itself is an [**npm**](https://www.npmjs.com) program that you run in a terminal window. It monitors your project's Pug, Sass, HTML and CSS files. When a file updates, it will create or update Dart files of the same name.
1010

11-
You use the Pug or HTML files to define flutter-views, which flutter-view will convert into Flutter Widget layout functions in Dart. You can them use these Dart functions in your normal Flutter code.
11+
You use the Pug files to define flutter-views, which flutter-view will convert into Flutter Widget layout functions in Dart. You can them use these Dart functions in your normal Flutter code.
1212

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

1515
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

get-started/vs-code-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ _Note: for this to work, the project link comments in flutter-view must be enabl
1717

1818
Normally when you change Flutter Dart code in VSCode, the Dart extension knows you are running a Flutter project and triggers a hot reload in your connected device or emulator.
1919

20-
When you change a Pug, Html, Sass or CSS file, flutter-view will update the Dart code in the background as you save. However the editor will not know that it needs to trigger a hot reload.
20+
When you change a Pug or Sass file, flutter-view will update the Dart code in the background as you save. However the editor will not know that it needs to trigger a hot reload.
2121

2222
To enable this, we need to do two things:
2323

guide/adding-content.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ In Flutter, widget trees are built by passing a child or children. Widget trees
66

77
Flutter-views are optimised for building widget trees. Pug in particular is well suited for creating tree structures and moving parts around.
88

9-
The following example generates a Dart method **FooPage\(\)**, which returns a Scaffold with an AppBar, and a centralized greeting message.
9+
The following example generates a Dart method **FooPage()**, which returns a Scaffold with an AppBar, and a centralized greeting message. 
1010

1111
The Pug creates the layout, and the main.dart file uses this layout to render the app. This separation between layout and logic is fundamental to using flutter-view.
1212

1313
{% tabs %}
1414
{% tab title="Pug" %}
1515
{% code title="foo-page.pug" %}
16-
```css
16+
```pug
1717
foo-page(flutter-view :greeting)
1818
scaffold
1919
app-bar(as='appBar')
@@ -76,7 +76,7 @@ To see how this works, compare the Pug and generated Dart code in this example:
7676

7777
{% tabs %}
7878
{% tab title="Pug" %}
79-
```css
79+
```pug
8080
container
8181
column
8282
row
@@ -122,7 +122,7 @@ Flutter-view knows which classes generally need children instead of single child
122122

123123
{% tabs %}
124124
{% tab title="Pug" %}
125-
```css
125+
```pug
126126
container
127127
row first row!
128128
row second row!
@@ -161,13 +161,13 @@ You can [override the default wrapper](configuring-flutter-view.md#autowrapchild
161161

162162
### Calling dart factory constructors
163163

164-
Some Flutter Dart classes may use factory constructors. For example, ButtonTheme has a [**ButtonTheme.bar\(\)**](https://docs.flutter.io/flutter/material/ButtonTheme/ButtonTheme.bar.html) constructor.
164+
Some Flutter Dart classes may use factory constructors. For example, ButtonTheme has a [**ButtonTheme.bar()**](https://docs.flutter.io/flutter/material/ButtonTheme/ButtonTheme.bar.html) constructor. 
165165

166166
To call the factory constructor instead of the default constructor, pass the constructor after the class name, separated with a colon.
167167

168168
{% tabs %}
169169
{% tab title="Pug" %}
170-
```css
170+
```pug
171171
button-theme:bar
172172
| some content here
173173
```
@@ -190,7 +190,7 @@ There may be cases where flutter-view does not recognise your tag needs a childr
190190

191191
{% tabs %}
192192
{% tab title="Pug" %}
193-
```css
193+
```pug
194194
column
195195
array(as='children')
196196
row first!
@@ -226,7 +226,7 @@ To see how this works, compare the Pug and generated Dart code in this example:
226226

227227
{% tabs %}
228228
{% tab title="Pug" %}
229-
```css
229+
```pug
230230
container
231231
column(const)
232232
row
@@ -263,7 +263,7 @@ For example:
263263

264264
{% tabs %}
265265
{% tab title="Pug" %}
266-
```css
266+
```pug
267267
banner(title='testing')
268268
| Hello world!
269269
```
@@ -290,7 +290,7 @@ For example:
290290

291291
{% tabs %}
292292
{% tab title="Pug" %}
293-
```css
293+
```pug
294294
flat-button(:color='highlighted ? Colors.red : Colors.grey')
295295
| Click me!
296296
```
@@ -314,7 +314,7 @@ Some widgets take an unnamed parameter in their constructor. You can pass this u
314314

315315
{% tabs %}
316316
{% tab title="Pug" %}
317-
```css
317+
```pug
318318
container
319319
icon(:value='Icons.add')
320320
text(value='Hello world')
@@ -339,7 +339,7 @@ return Container(
339339

340340
You may need to pass a parameter that has the name of a reserved keyword, such as value. You can bypass this problem by escaping your parameter with the ^ sign:
341341

342-
```text
342+
```
343343
:^value='foo'
344344
```
345345

@@ -349,7 +349,7 @@ Sometimes what you want to pass is not just a single value, but a value that is
349349

350350
{% tabs %}
351351
{% tab title="Pug" %}
352-
```css
352+
```pug
353353
scaffold
354354
app-bar(as='appBar')
355355
container(as='title') Test App
@@ -383,7 +383,7 @@ You can create functions that return children using the [**function shortcut**](
383383

384384
Passing a handler function or closure is no different than in Dart:
385385

386-
```css
386+
```pug
387387
my-button(flutter-view :on-click[Function])
388388
flat-button(:on-pressed='onClick') Click me!
389389
```
@@ -392,7 +392,7 @@ A common case is a closure without any parameters. In that case you can use the
392392

393393
{% tabs %}
394394
{% tab title="Pug" %}
395-
```css
395+
```pug
396396
my-button(flutter-view)
397397
flat-button(@on-pressed='print("Click!")') Click me!
398398
```
@@ -416,7 +416,7 @@ Sometimes you need to pass an array of specific items to a parameter. In that ca
416416

417417
{% tabs %}
418418
{% tab title="Pug" %}
419-
```css
419+
```pug
420420
custom-scroll-view
421421
array(as='slivers')
422422
sliver1
@@ -442,7 +442,7 @@ CustomScrollView(
442442

443443
A nice Pug feature is that classes and ids are automatically converted into DIV tags. In flutter-view, they are automatically converted into [Container](https://docs.flutter.io/flutter/widgets/Container-class.html) widgets:
444444

445-
```css
445+
```pug
446446
container hello world
447447
#greeting hello world
448448
.greeting hello world
@@ -459,4 +459,3 @@ Container(
459459
The classes and ids you use are forgotten after the conversion to Dart code. However, you do get automatic commenting, which will make it easier to read the generated code.
460460

461461
The biggest benefit is however that you can use them to style your widgets.
462-

guide/creating-a-new-view.md

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Creating a new view
22

3-
To create a new view, create either an HTML or Pug page. It is common to put this page in its own directory with the same name, to group the page, styling and optional models together. A single page can contain many flutter-views.
3+
To create a new view, create a Pug file. It is common to put this file in its own directory with the same name, to group the page, styling and optional models together. A single page can contain many flutter-views.
44

55
## Importing Dart dependencies
66

@@ -25,12 +25,6 @@ To import additional packages in a Pug or HTML file, use the import tag with the
2525
import(package='flutter_view_widgets/flutter_view_widgets.dart')
2626
```
2727
{% endtab %}
28-
29-
{% tab title="HTML" %}
30-
```markup
31-
<import package='flutter_view_widgets/flutter_view_widgets.dart'/>
32-
```
33-
{% endtab %}
3428
{% endtabs %}
3529

3630
To import files in a Pug or HTML file, use the import tag with the file parameter. The files are relative to the current file directory:
@@ -41,12 +35,6 @@ To import files in a Pug or HTML file, use the import tag with the file paramete
4135
import(file='../directory/test.dart')
4236
```
4337
{% endtab %}
44-
45-
{% tab title="HTML" %}
46-
```markup
47-
<import file='../directory/test.dart'/>
48-
```
49-
{% endtab %}
5038
{% endtabs %}
5139

5240
## Creating Flutter-views
@@ -55,19 +43,11 @@ A flutter-view is transformed into a Dart function. As such, you are just writin
5543

5644
### Method body
5745

58-
The format of a flutter view in HTML is as follows:
46+
The format of a flutter view in Pug is as follows:
5947

6048
{% tabs %}
61-
{% tab title="HTML" %}
62-
```markup
63-
<method-name flutter-view [optional parameters]>
64-
...method body...
65-
</method-name>
66-
```
67-
{% endtab %}
68-
6949
{% tab title="Pug" %}
70-
```css
50+
```pug
7151
method-name(flutter-view [optional parameters])
7252
...method body...
7353
```
@@ -92,24 +72,16 @@ Parameters are defined as follows:
9272

9373
`:parameter-name[type]?`
9474

95-
The **\[type\]** and **?** are optional:
75+
The **\[type]** and **?** are optional:
9676

9777
* The type becomes the type of the parameter in the Dart function. If omitted, it it is considered dynamic
9878
* By default, parameters you specify are required. Adding a **?** at the end indicates that they are optional.
9979

10080
Example:
10181

10282
{% tabs %}
103-
{% tab title="HTML" %}
104-
```markup
105-
<task-list-item flutter-view :model[TaskList] :task[Task] :done?>
106-
...widgets that show the task...
107-
</method-name>
108-
```
109-
{% endtab %}
110-
11183
{% tab title="Pug" %}
112-
```css
84+
```pug
11385
task-list-item(flutter-view :task-model[TaskList] :task[Task] :done?)
11486
...widgets that show the task...
11587
```
@@ -124,5 +96,3 @@ TaskListItem({ @required TaskList taskModel, @required Task task, done) {
12496
}
12597
```
12698

127-
128-

guide/flow-control.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This will only render the widget if the passed condition is true.
88

99
{% tabs %}
1010
{% tab title="Pug" %}
11-
```c
11+
```pug
1212
user-profile(flutter-view :user[User])
1313
.user
1414
.name ${user.name}
@@ -47,7 +47,7 @@ A slot is a placeholder for a value. It will take the value of the first valid c
4747

4848
{% tabs %}
4949
{% tab title="Pug" %}
50-
```c
50+
```pug
5151
wrapper(flutter-view :content[Widget])
5252
slot(:value='content').content
5353
.footer A footer
@@ -77,7 +77,7 @@ Slot can function as an if/else. In the next example you see either the .status
7777

7878
{% tabs %}
7979
{% tab title="Pug" %}
80-
```c
80+
```pug
8181
tasks-page(flutter-view :tasks[List])
8282
scaffold
8383
slot(as='body')
@@ -119,7 +119,7 @@ By adding multiple children with if to a slot, you can also create a switch/case
119119

120120
{% tabs %}
121121
{% tab title="Pug" %}
122-
```c
122+
```pug
123123
slot
124124
.apple(if='fruit=="Apple"')
125125
.pear(if='fruit=="Pear"')
@@ -136,7 +136,7 @@ Use **for** to repeat a widget for every value in a list. For every repetition,
136136

137137
{% tabs %}
138138
{% tab title="Pug" %}
139-
```c
139+
```pug
140140
tasks-page(flutter-view :tasks[List])
141141
scaffold
142142
slot(as='body')

0 commit comments

Comments
 (0)