diff --git a/src/_includes/docs/run-profile.md b/src/_includes/docs/run-profile.md index 45e493182d..f91fd17c09 100644 --- a/src/_includes/docs/run-profile.md +++ b/src/_includes/docs/run-profile.md @@ -6,9 +6,9 @@ Do _not_ test the performance of your app with debug and hot reload enabled. - + **请勿** 在调试模式和热重载功能开启的情况下做性能测试。 - + {{site.alert.end}} So far you've been running your app in *debug* mode. Debug @@ -27,12 +27,12 @@ build modes. For more details, see [Flutter's build modes][]. [Flutter 的构建模式选择]({{site.url}}/testing/build-modes)。 {{site.alert.important}} - + If you're concerned about the package size of your app, see [Measuring your app's size][]. - + 如果你关心应用大小,请参考 [这篇文档][Measuring your app's size]。 - + {{site.alert.end}} [Flutter's build modes]: {{site.url}}/testing/build-modes diff --git a/src/add-to-app/android/add-flutter-screen.md b/src/add-to-app/android/add-flutter-screen.md index 61e6e656a7..17128b5b7a 100644 --- a/src/add-to-app/android/add-flutter-screen.md +++ b/src/add-to-app/android/add-flutter-screen.md @@ -282,7 +282,7 @@ is discussed next. 那么你的 Flutter 应用会像是运行在一个大小为零的窗口中, 直至 `FlutterEngine` 附属到一个 `FlutterActivity`,`FlutterFragment` 或 `FlutterView`。 请确保你的应用在开始预热到你展示 Flutter 内容中间的这段时间里表现正常。 - + {{site.alert.end}} With a pre-warmed, cached `FlutterEngine`, you now need diff --git a/src/add-to-app/ios/add-flutter-screen.md b/src/add-to-app/ios/add-flutter-screen.md index 26066511c1..e3a74e5c2a 100644 --- a/src/add-to-app/ios/add-flutter-screen.md +++ b/src/add-to-app/ios/add-flutter-screen.md @@ -33,6 +33,7 @@ To launch a Flutter screen from an existing iOS, you start a `FlutterEngine` 充当 Dart VM 和 Flutter 运行时的主机; `FlutterViewController` 依附于 `FlutterEngine`, 给 Flutter 传递 UIKit 的输入事件,并展示被 `FlutterEngine` 渲染的每一帧画面。 + {{site.alert.end}} The `FlutterEngine` might have the same lifespan as your @@ -59,6 +60,7 @@ The `FlutterEngine` might have the same lifespan as your logic before showing the UI. 在展示 UI 前,你的应用和 plugins 可以与 Flutter 和 Dart 逻辑交互。 + {{site.alert.end}} See [Loading sequence and performance][] @@ -339,6 +341,7 @@ Now, you have a Flutter screen embedded in your iOS app. 在上一个例子中,你的默认 Dart 库的默认入口函数 `main()`, 将会在 `AppDelegate` 创建 `FlutterEngine` 并调用 `run` 方法时调用。 + {{site.alert.end}} ### _Alternatively_ - Create a FlutterViewController with an implicit FlutterEngine @@ -792,6 +795,7 @@ a different Dart function. @pragma('vm:entry-point') void myOtherEntrypoint() { ... }; ``` + {{site.alert.end}} ### Dart library @@ -884,10 +888,11 @@ FlutterViewController* flutterViewController = 如果在 `FlutterEngine` 启动后,迫切得需要在平台侧改变你当前的 Flutter 路由, 可以使用 `FlutterViewController` 里的 [`pushRoute()`][] 或者 [`popRoute()`][]。 -To pop the iOS route from the Flutter side, + To pop the iOS route from the Flutter side, call [`SystemNavigator.pop()`][]. - -在 Flutter 侧推出 iOS 路由,调用 [`SystemNavigator.pop()`][]。 + + 在 Flutter 侧推出 iOS 路由,调用 [`SystemNavigator.pop()`][]。 + {{site.alert.end}} See [Navigation and routing][] for more about Flutter's routes. diff --git a/src/androidx-migration.md b/src/androidx-migration.md index 326db3a68e..e21787b02f 100644 --- a/src/androidx-migration.md +++ b/src/androidx-migration.md @@ -13,6 +13,7 @@ keywords: AndoridX, Android Studio, Flutter 里使用 AndroidX doesn't use AndroidX. 如果 Flutter 监测到你的项目中未使用到 AndroidX,那么你会跳转到此页面。 + {{site.alert.end}} [AndroidX]({{site.android-dev}}/jetpack/androidx) is a major improvement diff --git a/src/codelabs/layout-basics-old.md b/src/codelabs/layout-basics-old.md index 9586e71db7..aa636c381b 100644 --- a/src/codelabs/layout-basics-old.md +++ b/src/codelabs/layout-basics-old.md @@ -28,10 +28,11 @@ toc: false work in some browsers and not others. If you encounter any, please [create a DartPad issue](https://goo.gle/flutter_web_issue), labeling the issue with `platform-web`. - + 目前 codelab 是基于 Chrome 开发测试的。可能会有一些功能(短期内)在某些浏览器上可用,而在另一些浏览器上不可用。 - 如果您遇到任何问题,请 [create a DartPad issue](https://goo.gle/flutter_web_issue) ,并为这个 issue 加上 - `platform-web` 标签。 + 如果您遇到任何问题,请 [create a DartPad issue](https://goo.gle/flutter_web_issue) + 并为这个 issue 加上 `platform-web` 标签。 + {{site.alert.end}} `Row` and `Column` are two very important widgets in the Flutter universe. diff --git a/src/codelabs/layout-basics.md b/src/codelabs/layout-basics.md index a2e910c8d2..c0ed33430b 100644 --- a/src/codelabs/layout-basics.md +++ b/src/codelabs/layout-basics.md @@ -69,6 +69,7 @@ and `Column` lays out its widgets vertically. {{site.alert.secondary}} {:.no_toc} + The following example displays the differences between a `Row` and `Column`. @@ -1167,7 +1168,7 @@ wrap a widget and force the widget to fill extra space. 与 `Flexible` 非常相似。 {{site.alert.tip}} - + **What's the difference between Flexible and Expanded?** Use `Flexible` to resize widgets in a `Row` or `Column`. That way, you can adjust a child widget's spacing @@ -1193,7 +1194,7 @@ wrap a widget and force the widget to fill extra space. The following example demonstrates how the `Expanded` widget forces its child widget to fill extra space. - + 下面的例子演示了 `Expanded` widget 是如何 强制其子 widget 填满空间的。 @@ -1214,6 +1215,7 @@ wrap a widget and force the widget to fill extra space. and run again. 选择 **Format** 按钮格式化代码,然后再次运行。 + {{site.alert.end}} ```run-dartpad:theme-dark:mode-flutter:width-100%:height-400px:split-60 @@ -1674,6 +1676,7 @@ can create space between widgets. Use `Spacer` when you want to create space using a `flex` property. Use `SizedBox` when you want to create space using a specific number of logical pixels. + **SizedBox 和 Spacer 有何不同?** 如果你想用 `flex` 属性创建一段空间,请使用 `Spacer`。 如果你想创建一个拥有特定逻辑像素值的空间,请使用 `SizedBox`。 @@ -1840,7 +1843,7 @@ for different fonts, sizes, and colors. {:.no_toc} {{site.alert.secondary}} - + The following example displays "Hey!" three times, but at different font sizes and in different colors. `Row` specifies the `crossAxisAlignment` @@ -2528,6 +2531,7 @@ Future main() async { ], ); ``` + {{site.alert.end}} ```run-dartpad:theme-dark:mode-flutter:width-100%:height-400px:split-60 diff --git a/src/community/tutorials/memory-leak-monitoring-on-flutter.md b/src/community/tutorials/memory-leak-monitoring-on-flutter.md index a195e92086..4d7d398e3c 100644 --- a/src/community/tutorials/memory-leak-monitoring-on-flutter.md +++ b/src/community/tutorials/memory-leak-monitoring-on-flutter.md @@ -187,11 +187,12 @@ Flutter 中的 Dart 是不支持反射的(为了优化打包体积,关闭了 {{site.alert.note}} -简单说明下 Library 是什么东西, -Dart 中的分包管理是根据 Library 来的, -同一个 Library 内的类名不能重复, -一般情况下一个 `.dart` 文件就是一个 Library, -当然也有例外,比如:part of 和 export。 + 简单说明下 Library 是什么东西, + Dart 中的分包管理是根据 Library 来的, + 同一个 Library 内的类名不能重复, + 一般情况下一个 `.dart` 文件就是一个 Library, + 当然也有例外,比如:part of 和 export。 + {{site.alert.end}} `vm_service` 有个 [invoke(isolateId, targetId, selector, argumentIds)](https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#invoke) API, @@ -344,7 +345,8 @@ Dev Tools 是调用了 `vm_service` 的 {{site.alert.note}} -通过 dev_tools dump 出来的对象来看,的确泄漏了! + 通过 dev_tools dump 出来的对象来看,的确泄漏了! + {{site.alert.end}} 也就是 1.9.1 Framework 里面存在着泄漏, @@ -441,7 +443,8 @@ Flutter 的 widget tree 的层次是非常深的。 {{site.alert.note}} -好消息是以上泄漏都在 1.12 版本之后修复了。 + 好消息是以上泄漏都在 1.12 版本之后修复了。 + {{site.alert.end}} 修复完上述两个泄漏之后, diff --git a/src/cookbook/animation/page-route-animation.md b/src/cookbook/animation/page-route-animation.md index 683a387c75..1c67f8ba4b 100644 --- a/src/cookbook/animation/page-route-animation.md +++ b/src/cookbook/animation/page-route-animation.md @@ -67,17 +67,17 @@ To start, use a [`PageRouteBuilder`][] to create a [`Route`][]. 另一个则是创建一个路由的转换器(`transitionsBuilder`)。 {{site.alert.note}} - + The `child` parameter in transitionsBuilder is the widget returned from pageBuilder. The `pageBuilder` function is only called the first time the route is built. The framework can avoid extra work because `child` stays the same throughout the transition. - + transitionsBuilder 的 `child` 参数是通过 `pageBuilder` 方法 来返回一个 transitionsBuilder widget,这个 `pageBuilder` 方法仅会在 第一次构建路由的时候被调用。框架能够自动避免做额外的工作,因为 整个过渡期间 `child` 保存了同一个实例。 - + {{site.alert.end}} The following example creates two routes: a home route with a "Go!" button, and diff --git a/src/cookbook/animation/physics-simulation.md b/src/cookbook/animation/physics-simulation.md index 6831ed9d43..cbfd8f788b 100644 --- a/src/cookbook/animation/physics-simulation.md +++ b/src/cookbook/animation/physics-simulation.md @@ -126,7 +126,7 @@ Then construct an [AnimationController][] in 继承的 `SingleTickerProviderStateMixin` 让 state 对象为 `AnimationController` 提供了 `TickerProvider` 的能力。要获得更多信息,请查看 [TickerProvider][] 文档。 - + {{site.alert.end}} @@ -414,7 +414,7 @@ onPanEnd: (details) { is no longer required. 既然动画控制器使用了模拟,就不再需要指定 `duration` 参数。 - + {{site.alert.end}} ## Interactive Example diff --git a/src/cookbook/design/package-fonts.md b/src/cookbook/design/package-fonts.md index 73523d6580..4dfbd32b8e 100644 --- a/src/cookbook/design/package-fonts.md +++ b/src/cookbook/design/package-fonts.md @@ -41,7 +41,7 @@ This recipe uses the following steps: to almost 1000 open-sourced font families. 查看 [google_fonts][] 库,你将可以直接访问近 1000 个开源字体族。 - + {{site.alert.end}} ## 1. Add a font to a package diff --git a/src/cookbook/design/snackbars.md b/src/cookbook/design/snackbars.md index 8a97a45210..444540c5ac 100644 --- a/src/cookbook/design/snackbars.md +++ b/src/cookbook/design/snackbars.md @@ -151,7 +151,7 @@ final snackBar = SnackBar( 注意: 这个例子是当用户点击一个按钮的时候显示一个 SnackBar。 更多有关处理用户输入的信息,请查阅实用教程 (Cookbook) 的 [Gestures][] 部分。 - + {{site.alert.end}} diff --git a/src/cookbook/design/tabs.md b/src/cookbook/design/tabs.md index f670dc61a2..0bd9ad44e8 100644 --- a/src/cookbook/design/tabs.md +++ b/src/cookbook/design/tabs.md @@ -29,7 +29,7 @@ Flutter 自带的 [Material 库][material library] 创建一个使用 tabs 布局、Cupertino 风格的 iOS 应用, 请参见这个 codelab: [使用 Flutter 构建 iOS 风格的应用][Building a Cupertino app with Flutter]。 - + {{site.alert.end}} This recipe creates a tabbed example using the following steps; diff --git a/src/cookbook/forms/retrieve-input.md b/src/cookbook/forms/retrieve-input.md index c624c06a47..05a94b4d25 100644 --- a/src/cookbook/forms/retrieve-input.md +++ b/src/cookbook/forms/retrieve-input.md @@ -53,7 +53,7 @@ we can use it to retrieve the text a user has typed into that text field. **记住:**当不再使用 `TextEditingController` 时, 请销毁它以确保相关的资源得到释放。 - + {{site.alert.end}} diff --git a/src/cookbook/lists/floating-app-bar.md b/src/cookbook/lists/floating-app-bar.md index b51ac74ee8..3db0fd6780 100644 --- a/src/cookbook/lists/floating-app-bar.md +++ b/src/cookbook/lists/floating-app-bar.md @@ -178,6 +178,7 @@ CustomScrollView( 试试 [`SliverAppBar` 支持的各种属性][various properties you can pass to the `SliverAppBar` widget], 并使用热重载来查看结果。例如,你可以给 `flexibleSpace` 提供一个 `Image` widget 来创建一个背景图像,当它在屏幕外滚动时会缩小尺寸。 + {{site.alert.end}} diff --git a/src/cookbook/navigation/hero-animations.md b/src/cookbook/navigation/hero-animations.md index c6b7edbd47..a86fb9d2ba 100644 --- a/src/cookbook/navigation/hero-animations.md +++ b/src/cookbook/navigation/hero-animations.md @@ -63,7 +63,7 @@ handle animations in the next steps. 这个示例建立在 [导航到一个新页面和返回][Navigate to a new screen and back] 和 [处理点击事件][Handle taps] 这两个章节的基础上。 - + {{site.alert.end}} @@ -191,7 +191,7 @@ Hero( 这份代码和第一个页面中的代码是相同的。 实际上,可以创建一个可复用的组件来代替这些重复的代码。 但是在这个示例中,重复的代码会更易于讲解和演示。 - + {{site.alert.end}} ## Interactive example diff --git a/src/cookbook/navigation/named-routes.md b/src/cookbook/navigation/named-routes.md index 5d92491f3e..4f58ff6fab 100644 --- a/src/cookbook/navigation/named-routes.md +++ b/src/cookbook/navigation/named-routes.md @@ -174,6 +174,7 @@ MaterialApp( When using `initialRoute`, **don't** define a `home` property. 当使用 `initialRoute` 时,需要确保你没有同时定义 `home` 属性。 + {{site.alert.end}} ## 3. Navigate to the second screen diff --git a/src/cookbook/navigation/navigation-basics.md b/src/cookbook/navigation/navigation-basics.md index a93731cffa..877545b964 100644 --- a/src/cookbook/navigation/navigation-basics.md +++ b/src/cookbook/navigation/navigation-basics.md @@ -29,7 +29,7 @@ details about the product. **术语**: 在 Flutter 中,**屏 (screen)** 和 **页面 (page)** 都叫做 **路由 (route)**, 在下文中统称为“路由 (route)”。 - + {{site.alert.end}} In Android, a route is equivalent to an Activity. diff --git a/src/cookbook/networking/background-parsing.md b/src/cookbook/networking/background-parsing.md index d0139cc7a3..692187b369 100644 --- a/src/cookbook/networking/background-parsing.md +++ b/src/cookbook/networking/background-parsing.md @@ -104,7 +104,8 @@ Future fetchPhotos(http.Client client) async { This makes the function easier to test and use in different environments. 在这个例子中你需要给方法添加了一个 `http.Client` 参数。 - 这将使得该方法测试起来更容易同时也可以在不同环境中使用。 + 这将使得该方法测试起来更容易,同时也可以在不同环境中使用。 + {{site.alert.end}} ## 3. Parse and convert the JSON into a list of photos diff --git a/src/cookbook/persistence/sqlite.md b/src/cookbook/persistence/sqlite.md index 8b0ed83b51..f1da213529 100644 --- a/src/cookbook/persistence/sqlite.md +++ b/src/cookbook/persistence/sqlite.md @@ -445,7 +445,7 @@ print(await dogs()); // Prints Fido with age 42. Do not use string interpolation, such as `where: "id = ${dog.id}"`! 这里不要使用字符串模板,比如: `where: "id = ${dog.id}"`! - + {{site.alert.end}} diff --git a/src/cookbook/plugins/picture-using-camera.md b/src/cookbook/plugins/picture-using-camera.md index 7865b5faa5..b1d5e20ab1 100644 --- a/src/cookbook/plugins/picture-using-camera.md +++ b/src/cookbook/plugins/picture-using-camera.md @@ -245,7 +245,7 @@ display a preview of the camera's feed. **请记住**: 在使用相机前,请确保控制器已经完成初始化。 因此,你一定要等待前一个步骤创建 `_initializeControllerFuture()` 执行完毕才去展示 `CameraPreview`。 - + {{site.alert.end}} Use a [`FutureBuilder`][] for exactly this purpose. diff --git a/src/cookbook/testing/widget/introduction.md b/src/cookbook/testing/widget/introduction.md index 43a424ba0d..600e5cd85f 100644 --- a/src/cookbook/testing/widget/introduction.md +++ b/src/cookbook/testing/widget/introduction.md @@ -242,7 +242,7 @@ Use one of the following methods to ask Flutter to rebuild the widget. 要开始播放动画,则需要调用一次 `pump()`(不指定 duration)以启动 ticker。 如果没有这一步骤,动画将不会执行。 - + {{site.alert.end}} [`tester.pumpAndSettle()`][] diff --git a/src/data-and-backend/google-apis.md b/src/data-and-backend/google-apis.md index a20d70073f..6c71d6d432 100644 --- a/src/data-and-backend/google-apis.md +++ b/src/data-and-backend/google-apis.md @@ -43,7 +43,7 @@ Examples of user-data APIs include **不应该** 直接使用到 Flutter 应用中。 直接使用需要将服务证书作为应用程序的一部分,这是不安全的。 我们推荐创建一个中间服务,来使用这些 API。 - + {{site.alert.end}} To add authentication to Firebase explicitly, check out the diff --git a/src/deployment/android.md b/src/deployment/android.md index f8fae52131..5b4a3ca1eb 100644 --- a/src/deployment/android.md +++ b/src/deployment/android.md @@ -407,6 +407,7 @@ Release builds of your app will now be signed automatically. 现在我们 app 的发布版本就会被自动签名了。 {{site.alert.note}} + You might need to run `flutter clean` after changing the gradle file. This prevents cached builds from affecting the signing process. @@ -660,6 +661,7 @@ the Play Store. Google Play 更推荐使用 app bundle 格式的应用, 更多信息可以参考 [Android App Bundle][bundle]。 + {{site.alert.end}} ### Build an app bundle diff --git a/src/deployment/macos.md b/src/deployment/macos.md index d7afadc81d..5356939819 100644 --- a/src/deployment/macos.md +++ b/src/deployment/macos.md @@ -557,6 +557,7 @@ keychain initialize ``` {{site.alert.secondary}} + **Restore Login Keychain!** After running `keychain initialize` you **must** run the following:
diff --git a/src/deployment/windows.md b/src/deployment/windows.md index c419f64e11..e9bc47084c 100644 --- a/src/deployment/windows.md +++ b/src/deployment/windows.md @@ -30,7 +30,7 @@ of packaging and deploying a Flutter app in this way. 亦或是你不想处理认证过程。 微软提供的文档包括了关于使用 [Windows Installer][msidocs] 进行传统安装的更多内容。 - + {{site.alert.end}} diff --git a/src/get-started/codelab-web.md b/src/get-started/codelab-web.md index 6fc0eb6775..a5c91b1300 100644 --- a/src/get-started/codelab-web.md +++ b/src/get-started/codelab-web.md @@ -29,6 +29,7 @@ js: 当然你可能更想去尝试 [编写你的第一个 Flutter 应用][first_flutter_codelab]。 需要注意的是,在一切工具顺利安装的基础上, 本页面上的 codelab 将可以在移动端和桌面端的网页浏览器里运行。 + {{site.alert.end}} The web app that you'll be building diff --git a/src/get-started/install/macos.md b/src/get-started/install/macos.md index cebcf452d3..3970644b51 100644 --- a/src/get-started/install/macos.md +++ b/src/get-started/install/macos.md @@ -47,9 +47,11 @@ your development environment must meet these minimum requirements: 如果你要在 [Apple 芯片的 Mac 电脑][] 上使用,你还需要安装 Rosetta 2 环境因为 [一些辅助工具][some ancillary tools] 仍然需要, 你可以通过手动运行下面的命令来安装: + ```terminal $ sudo softwareupdate --install-rosetta --agree-to-license ``` + {{site.alert.end}} {% include_relative _get-sdk-mac.md %} diff --git a/src/get-started/test-drive/_web-app.md b/src/get-started/test-drive/_web-app.md index 5a250e5820..2d2554c092 100644 --- a/src/get-started/test-drive/_web-app.md +++ b/src/get-started/test-drive/_web-app.md @@ -8,7 +8,7 @@ **你是否也希望在 Web 平台运行 Flutter 应用呢?** Flutter 最新的 beta 频道已开启 web 支持。想要尝试,请查看 [编写你的第一个 Flutter 网页应用][Write your first Flutter app for the web] codelab。 - + {{site.alert.end}} [Write your first Flutter app for the web]: {{site.url}}/get-started/web diff --git a/src/perf/app-size.md b/src/perf/app-size.md index ff70d15a50..7de97fd70d 100644 --- a/src/perf/app-size.md +++ b/src/perf/app-size.md @@ -210,7 +210,7 @@ of the release build of their application. 正如 [检查总大小](#checking-the-total-size) 一节所述, 上传包的大小并不代表用户最终的下载大小。请注意,拆分工具中显示的冗余的原生库结构和资源密度, 都可以通过 Play 商店和 App Store 过滤。 - + {{site.alert.end}} The size analysis tool is invoked by passing the `--analyze-size` flag when @@ -258,6 +258,7 @@ native library is further broken down by package for quick analysis. 编译后的 Dart 原生库会按包进一步拆分,以便快速分析。 {{site.alert.warning}} + This tool on iOS creates a .app rather than an IPA. Use this tool to evaluate the relative size of the .app's content. To get a closer estimate of the download size, reference the @@ -266,7 +267,7 @@ native library is further broken down by package for quick analysis. 在 iOS 上,该工具会创建一个 .app 文件,而不是一个 IPA 包文件。 使用该工具可以评估 .app 内容的相对大小。为了获取更准确的下载大小的估算值, 请参考上面的 [估算总大小](#estimating-total-size) 一节。 - + {{site.alert.end}} ### Deeper analysis in DevTools diff --git a/src/perf/deferred-components.md b/src/perf/deferred-components.md index f34cf7497c..1a4a7d90d2 100644 --- a/src/perf/deferred-components.md +++ b/src/perf/deferred-components.md @@ -45,7 +45,7 @@ which can be compiled into split AOT shared libraries. Also, note that this is an advanced feature. 另外,请注意这是一个高级功能。 - + {{site.alert.end}} Though modules can be defer loaded, @@ -409,7 +409,7 @@ any issues and guides you through suggested changes to fix them. 这个标志会让 `pubspec.yaml` 中定义的所有延迟组件,被视为定义在 assets 部分的普通组件。 所有 Dart 代码会被编译到一个共享库中,`loadLibrary()` 调用会在下一个事件循环中完成(异步时尽快完成)。 此标志也等效于移除 `pubspec.yaml` 中的 `deferred-components:`。 - + {{site.alert.end}}
    @@ -448,7 +448,7 @@ of loading units. 你可以通过 `--no-validate-deferred-components` 标志,来让工具尝试在不执行验证程序下构建应用。 这可能导致由意外和错误的指令而引起的故障。 此标志应当仅在不需要依赖验证程序检查的默认 Play-store-based 的自定义实现时使用。 - + {{site.alert.end}} The validator detects any new, changed, or removed diff --git a/src/perf/ui-performance.md b/src/perf/ui-performance.md index 8279ad8838..be39b3c92c 100644 --- a/src/perf/ui-performance.md +++ b/src/perf/ui-performance.md @@ -33,7 +33,7 @@ keywords: 性能分析,性能调试工具,开发者工具,60fps,120fps,profile m 当 UI 渲染不流畅的时候,卡顿就随之产生了。 举例来说,如果一帧花了 10 倍的时间来渲染,这帧就会被丢弃,动画看起来就会卡。 - + {{site.alert.end}} It's been said that "a _fast_ app is great, @@ -48,6 +48,7 @@ steps to take, and tools that can help. 从哪里着手呢?本文展示了应该从哪里着手,步骤以及可以提供帮助的工具。 {{site.alert.note}} + * An app's performance is determined by more than one measure. Performance sometimes refers to raw speed, but also to the UI's smoothness and lack of stutter. Other examples of performance @@ -609,7 +610,7 @@ other potentially expensive operations, such as clipping or shadows. 透明度、裁剪以及阴影它们本身并不是个糟糕的主意。 然而对 widget 树顶层 widget 的操作可能导致额外对 `saveLayer` 的调用以及无用的处理。 - + {{site.alert.end}} When you encounter calls to `saveLayer`, diff --git a/src/platform-integration/android/splash-screen.md b/src/platform-integration/android/splash-screen.md index e68f5123ce..1e6260709f 100644 --- a/src/platform-integration/android/splash-screen.md +++ b/src/platform-integration/android/splash-screen.md @@ -76,6 +76,7 @@ initializes. {{site.alert.end}} {{site.alert.note}} + For apps that embed one or more Flutter screens within an existing Android app, consider [pre-warming a `FlutterEngine`][] and reusing the diff --git a/src/platform-integration/ios/ios-app-clip.md b/src/platform-integration/ios/ios-app-clip.md index 42d6175368..3d21c17def 100644 --- a/src/platform-integration/ios/ios-app-clip.md +++ b/src/platform-integration/ios/ios-app-clip.md @@ -13,7 +13,7 @@ description: 如何为您的 Flutter 工程加入 iOS 14 的 App Clip。 目前该实验测试版本会突破 10MB 的未压缩 IPA 有效负载的大小限制, 请勿在生产环境中使用([#71098][])。 - + {{site.alert.end}} This guide describes how to manually add another @@ -460,7 +460,7 @@ into the App Clip bundle. to run Flutter apps with plugins. 运行带有插件的 Flutter 应用程序需要 CocoaPods 1.10.0.beta.1 或更高版本。 - + {{site.alert.end}} **8.1** diff --git a/src/platform-integration/platform-adaptations.md b/src/platform-integration/platform-adaptations.md index 3ca8d0f2e1..689df071be 100644 --- a/src/platform-integration/platform-adaptations.md +++ b/src/platform-integration/platform-adaptations.md @@ -77,8 +77,6 @@ You can request additional guides by commenting on [issue #8427][]. {{site.alert.end}} -{{site.alert.end}} - ## Page navigation ## 页面导航 diff --git a/src/platform-integration/platform-channels.md b/src/platform-integration/platform-channels.md index c70b64b4a6..d2d16f448b 100644 --- a/src/platform-integration/platform-channels.md +++ b/src/platform-integration/platform-channels.md @@ -102,7 +102,7 @@ Flutter 内置的平台特定 API 支持不依赖于任何生成代码,而是 在不同的平台上执行对应的代码。 [不同平台操作体验的差异和适配][Platform adaptations] 文档中列举了部分 Flutter 框架自动为你处理的平台适配行为。 - + {{site.alert.end}} [`defaultTargetPlatform`]: {{site.api}}/flutter/foundation/defaultTargetPlatform.html @@ -135,7 +135,7 @@ to ensure the user interface remains responsive. Flutter 是通过 Dart 异步发送消息的。 即便如此,当你调用一个平台方法时,也需要在主线程上做调用。 在 [这里][section on threading] 查看更多。 - + {{site.alert.end}} On the client side, [`MethodChannel`][] enables sending diff --git a/src/platform-integration/web/renderers.md b/src/platform-integration/web/renderers.md index 8bbe7f66e7..42a2bec765 100644 --- a/src/platform-integration/web/renderers.md +++ b/src/platform-integration/web/renderers.md @@ -132,7 +132,7 @@ Flutter engine 启动之后无法再在 `main.dart.js` 更换 web 渲染器。 从 **Flutter 3.7.0** 开始,设置 `window.flutterWebRenderer`(以前版本中使用的一种方法) 会在 JS 控制台中显示 **弃用通知**。 有关详细信息,请查看 [自定义 Web 应用程序初始化][web-app-init]。 - + {{site.alert.end}} ## Choosing which option to use diff --git a/src/release/breaking-changes/plugin-api-migration.md b/src/release/breaking-changes/plugin-api-migration.md index cc99afe5a2..74c2e3c7f7 100644 --- a/src/release/breaking-changes/plugin-api-migration.md +++ b/src/release/breaking-changes/plugin-api-migration.md @@ -16,6 +16,7 @@ keywords: 迁移,Android平台,开发,新特性 如果我们检测到您的应用项目中使用的插件正在使用旧的 Android APIs , 会提示您前往本页面。 + {{site.alert.end}} _If you don't write or maintain an Android Flutter plugin, diff --git a/src/testing/build-modes.md b/src/testing/build-modes.md index 3f15b16969..2e98a0bd77 100644 --- a/src/testing/build-modes.md +++ b/src/testing/build-modes.md @@ -267,6 +267,7 @@ The command `flutter run --profile` compiles to profile mode. Use the [DevTools][] suite to profile your app's performance. 可以使用 [开发者工具][DevTools] 来测试应用性能。 + {{site.alert.end}} For more information on the build modes, see diff --git a/src/testing/integration-tests/index.md b/src/testing/integration-tests/index.md index f63e6d1335..243b806c86 100644 --- a/src/testing/integration-tests/index.md +++ b/src/testing/integration-tests/index.md @@ -396,6 +396,7 @@ Where `_test.dart` is the file created in the ```bash ./gradlew project:task -Pdart-defines="{base64(key=value)},[...]" ``` + {{site.alert.end}} Drag the "debug" APK from diff --git a/src/tools/android-studio.md b/src/tools/android-studio.md index e23bca96ae..b022fbabe1 100644 --- a/src/tools/android-studio.md +++ b/src/tools/android-studio.md @@ -247,7 +247,7 @@ Dart 插件的代码分析,可以做到: 下面的介绍文章适用于 Android Studio 和 IntelliJ,更多关于开发者工具的信息, 请参看文档:[在 Android Studio 上安装和运行开发者工具][Running DevTools from Android Studio]。 - + {{site.alert.end}} Running and debugging are controlled from the main toolbar: diff --git a/src/tools/devtools/debugger.md b/src/tools/devtools/debugger.md index f9b8e858dc..b6ed1d93e5 100644 --- a/src/tools/devtools/debugger.md +++ b/src/tools/devtools/debugger.md @@ -14,6 +14,7 @@ keywords: 调试,debug,设置断点,单步调试 如果应用是从 VS Code 启动的,开发工具会隐藏调试器标签页, 因为 VS Code 有内置的调试器。 + {{site.alert.end}} ## Getting started @@ -35,6 +36,7 @@ breakpoints, stepping, and variable inspection. 调试器可以用于所有的 Flutter 和 Dart 应用。 如果你想要使用 GDB 远程调试运行在 Android 应用进程中的 Flutter 引擎, 请查看 [`flutter_gdb`][]。 + {{site.alert.end}} [`flutter_gdb`]: https://github.com/flutter/engine/blob/main/sky/tools/flutter_gdb diff --git a/src/tools/devtools/inspector.md b/src/tools/devtools/inspector.md index 887f7e36f1..b66f4c9f1c 100644 --- a/src/tools/devtools/inspector.md +++ b/src/tools/devtools/inspector.md @@ -14,7 +14,7 @@ keywords: Flutter inspector,widget 树 The inspector works with all Flutter applications. Flutter inspector 适用于所有 Flutter 应用。 - + {{site.alert.end}} ## What is it? @@ -64,7 +64,7 @@ tab on the DevTools toolbar. 你可以直接在 Android Studio/IntelliJ 中使用 Flutter inspector, 但是你可能会更喜欢使用 DevTools 在浏览器中打开 Flutter inspector,这样你能得到更宽敞的视图。 - + {{site.alert.end}} ### Debugging layout issues visually diff --git a/src/tools/devtools/logging.md b/src/tools/devtools/logging.md index b42d1aa3e5..722f3ede57 100644 --- a/src/tools/devtools/logging.md +++ b/src/tools/devtools/logging.md @@ -12,7 +12,7 @@ keywords: 开发者工具,日志视图,Dart The logging view works with all Flutter and Dart applications. 日志视图可用于所有 Flutter 和 Dart 应用。 - + {{site.alert.end}} ## What is it? diff --git a/src/tools/vs-code.md b/src/tools/vs-code.md index ccf7a3df0e..41e7a90bb1 100644 --- a/src/tools/vs-code.md +++ b/src/tools/vs-code.md @@ -211,7 +211,7 @@ Flutter 扩展执行代码分析,它提供: 以下说明描述了 VS Code 可用的功能。更多使用 DevTools 的详细信息请参考 [DevTools][] 中的 [Running DevTools from VS Code][] 文档。 - + {{site.alert.end}} Start debugging by clicking **Run > Start Debugging** diff --git a/src/ui/accessibility-and-internationalization/internationalization.md b/src/ui/accessibility-and-internationalization/internationalization.md index 90b845b4de..0c84118b90 100644 --- a/src/ui/accessibility-and-internationalization/internationalization.md +++ b/src/ui/accessibility-and-internationalization/internationalization.md @@ -30,7 +30,7 @@ keywords: 国际化 * How to define the locales an app supports. 如何去定义 app 支持的语言环境。 - + {{site.alert.end}} If your app might be deployed to users who speak another diff --git a/src/ui/animations/hero-animations.md b/src/ui/animations/hero-animations.md index c14243ffcc..67599671c8 100644 --- a/src/ui/animations/hero-animations.md +++ b/src/ui/animations/hero-animations.md @@ -36,7 +36,7 @@ keywords: 共享元素过渡,补间动画 _shared element animations._ Flutter 中的 Hero widget 实现的动画类型也称为 **共享元素过渡** 或 **共享元素动画**。 - + {{site.alert.end}} You've probably seen hero animations many times. For example, a screen displays @@ -472,7 +472,7 @@ implement hero animations: image in a layout widget. These examples use `Container`. 通过在布局 widget 中放置目标图像来改变图像位置。这些示例中使用 `Container`。 - + {{site.alert.end}} @@ -750,7 +750,7 @@ Key information: * Build the destination route using `PageRouteBuilder`. 使用 PageRouteBuilder 创建目标页。 - + {{site.alert.end}} Flying a hero from one route to another as it transforms diff --git a/src/ui/animations/staggered-animations.md b/src/ui/animations/staggered-animations.md index 2037ae051b..154b0c9a1d 100644 --- a/src/ui/animations/staggered-animations.md +++ b/src/ui/animations/staggered-animations.md @@ -10,6 +10,7 @@ keywords: 交织动画 --- {{site.alert.secondary}} +

    What you'll learn

    * A staggered animation consists of sequential or overlapping @@ -32,7 +33,7 @@ keywords: 交织动画 * For each property being animated, create a `Tween`. 为每一个要执行动画的属性创建一个 Tween - + {{site.alert.end}} {{site.alert.secondary}} @@ -44,6 +45,7 @@ keywords: 交织动画 **术语:** 如果 tweens 或 tweening 的概念对你来说比较新,请看 [Flutter 指南中的 Animation][Animations in Flutter tutorial]。 + {{site.alert.end}} Staggered animations are a straightforward concept: visual changes @@ -107,6 +109,7 @@ This guide shows how to build a staggered animation in Flutter. 然后,选择一个最小的图像,最大的图像会展开同时对勾消失。 在最大的图像结束展开前,最小的图像会收缩并显示对勾。 这个交织行为比较类似于你在 Google Photos 中看到的效果。 + {{site.alert.end}} The following video demonstrates the animation performed by @@ -162,7 +165,7 @@ After running forward, the animation runs in reverse. **刚接触Flutter?** 本文假定你已经知道如何使用 Flutter 的 widgets 创建一个布局。 更多信息请看 [Flutter 中的布局][Building Layouts in Flutter]. - + {{site.alert.end}} ## Basic structure of a staggered animation @@ -170,6 +173,7 @@ After running forward, the animation runs in reverse. ## 一个交织动画的基础结构 {{site.alert.secondary}} +

    What's the point?

    重点是什么?

    diff --git a/src/ui/animations/tutorial.md b/src/ui/animations/tutorial.md index 36282014f4..034ae405d4 100644 --- a/src/ui/animations/tutorial.md +++ b/src/ui/animations/tutorial.md @@ -29,7 +29,7 @@ diff2html: true * When to use `AnimatedWidget` vs. `AnimatedBuilder`. `AnimatedWidget` 和 `AnimatedBuilder` 的应用区别。 - + {{site.alert.end}} This tutorial shows you how to build explicit animations in Flutter. @@ -305,6 +305,7 @@ To use your custom State object as the `vsync`, include the 根据所选曲线的不同,`CurvedAnimation` 的输出范围可能会超过输入。 举个例子,弹性曲线(比如Curves.elasticIn) 会明显超出或低于默认范围。 + {{site.alert.end}} ### Tween @@ -388,6 +389,7 @@ Animation alpha = IntTween(begin: 0, end: 255).animate(controller); not an [`Animatable`][]. `animate()` 方法会返回一个 [`Animation`][],而不是 [`Animatable`][]。 + {{site.alert.end}} The following example shows a controller, a curve, and a `Tween`: @@ -445,6 +447,7 @@ Each section provides a link to the source code for that example. ### 渲染动画 {{site.alert.secondary}} +

    What's the point?

    要点

    @@ -472,7 +475,7 @@ Each section provides a link to the source code for that example. * To make a class private, start its name with an underscore (`_`). 如需使类私有,在名字前面添加下划线(`_`)。 - + {{site.alert.end}} So far you've learned how to generate a sequence of numbers over time. @@ -650,6 +653,7 @@ you've created your first animation in Flutter! 要了解更多级联操作符的内容,请参考 [Dart 文档网站][Dart language documentation] 里的文档 [Cascade notation][]。 + {{site.alert.end}} ### Simplifying with Animated­Widget @@ -657,6 +661,7 @@ you've created your first animation in Flutter! ### 使用 Animated­Widget 进行简化 {{site.alert.secondary}} +

    What's the point?

    要点

    @@ -688,6 +693,7 @@ you've created your first animation in Flutter! Flutter API 中的 `AnimatedWidget`:`AnimatedBuilder`, `RotationTransition`, `ScaleTransition`, `SizeTransition`, `SlideTransition`。 + {{site.alert.end}} The `AnimatedWidget` base class allows you to separate out @@ -1181,6 +1187,7 @@ in the bullet points above. ### 同步动画 {{site.alert.secondary}} +

    What's the point?

    重点提醒

    @@ -1190,7 +1197,7 @@ in the bullet points above. use with a [`CurvedAnimation`][]. [`Curves`][] 类定义了一列常用的曲线,您可以配合 [`CurvedAnimation`][] 来使用。 - + {{site.alert.end}} In this section, you'll build on the example from @@ -1217,7 +1224,7 @@ opacity animates from transparent to opaque. 每个补间动画控制一个动画的不同效果。 仅用于说明目的。如果您需要在代码中加入渐变不透明度和尺寸效果, 可能需要用 [`FadeTransition`][] 和 [`SizeTransition`][] 来代替。 - + {{site.alert.end}} Each tween manages an aspect of the animation. For example: diff --git a/src/ui/layout/index.md b/src/ui/layout/index.md index 81b2c1c74a..f2e3e0a8b3 100644 --- a/src/ui/layout/index.md +++ b/src/ui/layout/index.md @@ -1254,11 +1254,12 @@ it automatically scrolls. {% endcomment %} {{site.alert.note}} + When displaying a two-dimensional list where it's important which row and column a cell occupies (for example, it's the entry in the "calorie" column for the "avocado" row), use [`Table`][] or [`DataTable`][]. - + 当展示二维列表中的单元格所在的行和列的位置很重要的 (例如,它是 “calorie” 行和 “avocado” 列的条目)的时候, 使用 [`Table`][] 或者 [`DataTable`][].。 diff --git a/src/ui/layout/tutorial.md b/src/ui/layout/tutorial.md index 32257d7422..1e315f84c6 100644 --- a/src/ui/layout/tutorial.md +++ b/src/ui/layout/tutorial.md @@ -18,6 +18,7 @@ diff2html: true {{site.alert.secondary}} +

    What you'll learn

    你将会学习到

    @@ -279,6 +280,7 @@ Add the title section to the app body like this: ``` {{site.alert.tip}} + * When pasting code into your app, indentation can become skewed. You can fix this in your Flutter editor using the [automatic reformatting support][]. @@ -502,7 +504,7 @@ leaving only the image. Add the image file to the example: 注意 `wget` 不能保存二进制文件。 原始的图片虽然可以在 Creative Commons 许可下 [在线获取][available online], 但是文件较大,下载缓慢。 - + {{site.alert.end}} * Update the `pubspec.yaml` file to include an `assets` tag. @@ -523,6 +525,7 @@ leaving only the image. Add the image file to the example: + - images/lake.jpg ``` {{site.alert.tip}} + * Note that `pubspec.yaml` is case sensitive, so write `assets:` and the image URL as shown above.