Skip to content

Commit

Permalink
更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
duwen committed Nov 13, 2018
1 parent 0441e5b commit 50a4e9e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
18 changes: 11 additions & 7 deletions animations/staggered-animations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ permalink: /animations/staggered-animations/

<b> <a id="whats-the-point" class="anchor" href="#whats-the-point" aria-hidden="true"><span class="octicon octicon-link"></span></a>你将学到什么:</b>

* A staggered animation consists of sequential or overlapping
animations.
* To create a staggered animation, use multiple Animation objects.
* One AnimationController controls all of the Animations.
* Each Animation object specifies the animation during an Interval.
* For each property being animated, create a Tween.

* 交错动画由一个动画序列或重叠的动画组成。
* 要创建交错动画,需要使用多个动画对象。
* 一个AnimationController控制所有动画。
* 每个动画对象在间隔(Interval)期间指定动画。
* 对于要执行动画的每个属性都要创建一个Tween。

</div>

<aside class="alert alert-info" markdown="1">
**Terminology:**
If the concept of tweens or tweening is new to you, see the
[Animations in Flutter tutorial.](/tutorials/animation/)
如果您还不清楚“补间”的概念,请参考
[Flutter动画教程](/tutorials/animation/)
</aside>

Staggered animations are a straightforward concept: visual changes
Expand All @@ -28,6 +30,8 @@ The animation might be purely sequential, with one change occuring after
the next, or it might partially or completely overlap. It might also
have gaps, where no changes occur.

所谓交错动画,直接来说就是:视觉变化发生在一系列操作中,而不是一次性发生。 动画可能是纯粹顺序的,在下一个动画之后会发生一次更改,或者可能部分或完全重叠。 它也可能有间隙,没有发生变化。

This guide shows how to build a staggered animation in Flutter.

<aside class="alert alert-info" markdown="1">
Expand Down
Binary file modified images/json/ide_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 11 additions & 26 deletions json.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ String json = JSON.encode(user);
```yaml
dependencies:
# Your other regular dependencies here
json_annotation: ^0.2.2
json_annotation: ^2.0.0

dev_dependencies:
# Your other dev_dependencies here
build_runner: ^0.7.6
json_serializable: ^0.3.2
build_runner: ^1.0.0
json_serializable: ^2.0.0
```
在您的项目根文件夹中运行 `flutter packages get` (或者在编辑器中点击 "Packages
Expand All @@ -193,38 +193,23 @@ Get") 以在项目中使用这些新的依赖项.
{% prettify dart %}
import 'package:json_annotation/json_annotation.dart';

/// This allows our `User` class to access private members in
/// the generated file. The value for this is *.g.dart, where
/// the star denotes the source file name.
part '[[highlight]]user[[/highlight]].g.dart';
// user.g.dart 将在我们运行生成命令后自动生成
part 'user.g.dart';

/// An annotation for the code generator to know that this class needs the
/// JSON serialization logic to be generated.
[[highlight]]@JsonSerializable()[[/highlight]]
///这个标注是告诉生成器,这个类是需要生成Model类的
@JsonSerializable()

/// Every json_serializable class must have the serializer mixin.
/// It makes the generated toJson() method to be usable for the class.
/// The mixin's name follows the source class, in this case, User.
class User extends Object with _$[[highlight]]User[[/highlight]]SerializerMixin {
class User{
User(this.name, this.email);

String name;
String email;

/// A necessary factory constructor for creating a new User instance
/// from a map. We pass the map to the generated _$UserFromJson constructor.
/// The constructor is named after the source class, in this case User.
factory User.fromJson(Map<String, dynamic> json) => _$[[highlight]]User[[/highlight]]FromJson(json);
//不同的类使用不同的mixin即可
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
Map<String, dynamic> toJson() => _$UserToJson(this);
}
{% endprettify %}

With this setup, the source code generator will generate code for serializing
the `name` and `email` fields from JSON and back.

If needed, it is also easy to customize the naming strategy. For example, if the
API we are working with returns objects with _snake\_case_, and we want to use
_lowerCamelCase_ in our models, we can use the `@JsonKey` annotation with a name
parameter:

有了这个设置,源码生成器将生成用于序列化`name`和`email`字段的JSON代码。

Expand Down

0 comments on commit 50a4e9e

Please sign in to comment.