Unverified Commit b21e08c8 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

[NNBD] Migrate sample code pt 4 (#72842)

parent 691d05da
...@@ -795,7 +795,7 @@ class _ActionsMarker extends InheritedWidget { ...@@ -795,7 +795,7 @@ class _ActionsMarker extends InheritedWidget {
/// widget, and the new control should be enabled for keyboard traversal and /// widget, and the new control should be enabled for keyboard traversal and
/// activation. /// activation.
/// ///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety} /// {@tool dartpad --template=stateful_widget_material}
/// This example shows how keyboard interaction can be added to a custom control /// This example shows how keyboard interaction can be added to a custom control
/// that changes color when hovered and focused, and can toggle a light when /// that changes color when hovered and focused, and can toggle a light when
/// activated, either by touch or by hitting the `X` key on the keyboard when /// activated, either by touch or by hitting the `X` key on the keyboard when
...@@ -813,7 +813,11 @@ class _ActionsMarker extends InheritedWidget { ...@@ -813,7 +813,11 @@ class _ActionsMarker extends InheritedWidget {
/// ///
/// ```dart preamble /// ```dart preamble
/// class FadButton extends StatefulWidget { /// class FadButton extends StatefulWidget {
/// const FadButton({Key key, this.onPressed, this.child}) : super(key: key); /// const FadButton({
/// Key? key,
/// required this.onPressed,
/// required this.child,
/// }) : super(key: key);
/// ///
/// final VoidCallback onPressed; /// final VoidCallback onPressed;
/// final Widget child; /// final Widget child;
...@@ -826,8 +830,8 @@ class _ActionsMarker extends InheritedWidget { ...@@ -826,8 +830,8 @@ class _ActionsMarker extends InheritedWidget {
/// bool _focused = false; /// bool _focused = false;
/// bool _hovering = false; /// bool _hovering = false;
/// bool _on = false; /// bool _on = false;
/// Map<Type, Action<Intent>> _actionMap; /// late Map<Type, Action<Intent>> _actionMap;
/// Map<LogicalKeySet, Intent> _shortcutMap; /// late Map<LogicalKeySet, Intent> _shortcutMap;
/// ///
/// @override /// @override
/// void initState() { /// void initState() {
......
...@@ -12,11 +12,6 @@ import 'package:flutter/foundation.dart'; ...@@ -12,11 +12,6 @@ import 'package:flutter/foundation.dart';
import 'framework.dart'; import 'framework.dart';
// Examples can assume:
// // @dart = 2.9
// dynamic _lot;
// Future<String> _calculation;
/// Base class for widgets that build themselves based on interaction with /// Base class for widgets that build themselves based on interaction with
/// a specified [Stream]. /// a specified [Stream].
/// ///
...@@ -371,7 +366,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps ...@@ -371,7 +366,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// as the builder will always be called before the stream listener has a chance /// as the builder will always be called before the stream listener has a chance
/// to be processed. /// to be processed.
/// ///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety} /// {@tool dartpad --template=stateful_widget_material}
/// ///
/// This sample shows a [StreamBuilder] that listens to a Stream that emits bids /// This sample shows a [StreamBuilder] that listens to a Stream that emits bids
/// for an auction. Every time the StreamBuilder receives a bid from the Stream, /// for an auction. Every time the StreamBuilder receives a bid from the Stream,
...@@ -388,7 +383,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps ...@@ -388,7 +383,7 @@ typedef AsyncWidgetBuilder<T> = Widget Function(BuildContext context, AsyncSnaps
/// ///
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.headline2, /// style: Theme.of(context).textTheme.headline2!,
/// textAlign: TextAlign.center, /// textAlign: TextAlign.center,
/// child: Container( /// child: Container(
/// alignment: FractionalOffset.center, /// alignment: FractionalOffset.center,
...@@ -614,7 +609,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> { ...@@ -614,7 +609,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// `future?.asStream()`, except that snapshots with `ConnectionState.active` /// `future?.asStream()`, except that snapshots with `ConnectionState.active`
/// may appear for the latter, depending on how the stream is implemented. /// may appear for the latter, depending on how the stream is implemented.
/// ///
/// {@tool dartpad --template=stateful_widget_material_no_null_safety} /// {@tool dartpad --template=stateful_widget_material}
/// ///
/// This sample shows a [FutureBuilder] that displays a loading spinner while it /// This sample shows a [FutureBuilder] that displays a loading spinner while it
/// loads data. It displays a success icon and text if the [Future] completes /// loads data. It displays a success icon and text if the [Future] completes
...@@ -630,7 +625,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> { ...@@ -630,7 +625,7 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// ///
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.headline2, /// style: Theme.of(context).textTheme.headline2!,
/// textAlign: TextAlign.center, /// textAlign: TextAlign.center,
/// child: FutureBuilder<String>( /// child: FutureBuilder<String>(
/// future: _calculation, // a previously-obtained Future<String> or null /// future: _calculation, // a previously-obtained Future<String> or null
......
...@@ -16,7 +16,7 @@ import 'will_pop_scope.dart'; ...@@ -16,7 +16,7 @@ import 'will_pop_scope.dart';
/// with a context whose ancestor is the [Form], or pass a [GlobalKey] to the /// with a context whose ancestor is the [Form], or pass a [GlobalKey] to the
/// [Form] constructor and call [GlobalKey.currentState]. /// [Form] constructor and call [GlobalKey.currentState].
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety} /// {@tool dartpad --template=stateful_widget_scaffold}
/// This example shows a [Form] with one [TextFormField] to enter an email /// This example shows a [Form] with one [TextFormField] to enter an email
/// address and an [ElevatedButton] to submit the form. A [GlobalKey] is used here /// address and an [ElevatedButton] to submit the form. A [GlobalKey] is used here
/// to identify the [Form] and validate input. /// to identify the [Form] and validate input.
...@@ -38,7 +38,7 @@ import 'will_pop_scope.dart'; ...@@ -38,7 +38,7 @@ import 'will_pop_scope.dart';
/// hintText: 'Enter your email', /// hintText: 'Enter your email',
/// ), /// ),
/// validator: (value) { /// validator: (value) {
/// if (value.isEmpty) { /// if (value!.isEmpty) {
/// return 'Please enter some text'; /// return 'Please enter some text';
/// } /// }
/// return null; /// return null;
...@@ -50,7 +50,7 @@ import 'will_pop_scope.dart'; ...@@ -50,7 +50,7 @@ import 'will_pop_scope.dart';
/// onPressed: () { /// onPressed: () {
/// // Validate will return true if the form is valid, or false if /// // Validate will return true if the form is valid, or false if
/// // the form is invalid. /// // the form is invalid.
/// if (_formKey.currentState.validate()) { /// if (_formKey.currentState!.validate()) {
/// // Process data. /// // Process data.
/// } /// }
/// }, /// },
......
...@@ -136,7 +136,7 @@ class PageStorageBucket { ...@@ -136,7 +136,7 @@ class PageStorageBucket {
/// you should give each of them unique [PageStorageKey]s, or set some of their /// you should give each of them unique [PageStorageKey]s, or set some of their
/// `keepScrollOffset` false to prevent saving. /// `keepScrollOffset` false to prevent saving.
/// ///
/// {@tool dartpad --template=freeform_no_null_safety} /// {@tool dartpad --template=freeform}
/// ///
/// This sample shows how to explicitly use a [PageStorage] to /// This sample shows how to explicitly use a [PageStorage] to
/// store the states of its children pages. Each page includes a scrollable /// store the states of its children pages. Each page includes a scrollable
...@@ -212,7 +212,7 @@ class PageStorageBucket { ...@@ -212,7 +212,7 @@ class PageStorageBucket {
/// ///
/// class ColorBoxPage extends StatelessWidget { /// class ColorBoxPage extends StatelessWidget {
/// ColorBoxPage({ /// ColorBoxPage({
/// Key key, /// Key? key,
/// }) : super(key: key); /// }) : super(key: key);
/// ///
/// @override /// @override
......
...@@ -80,7 +80,7 @@ import 'scrollable.dart'; ...@@ -80,7 +80,7 @@ import 'scrollable.dart';
/// with some remaining space to allocate as specified by its /// with some remaining space to allocate as specified by its
/// [Column.mainAxisAlignment] argument. /// [Column.mainAxisAlignment] argument.
/// ///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety} /// {@tool dartpad --template=stateless_widget_material}
/// In this example, the children are spaced out equally, unless there's no more /// In this example, the children are spaced out equally, unless there's no more
/// room, in which case they stack vertically and scroll. /// room, in which case they stack vertically and scroll.
/// ///
...@@ -91,7 +91,7 @@ import 'scrollable.dart'; ...@@ -91,7 +91,7 @@ import 'scrollable.dart';
/// ```dart /// ```dart
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.bodyText2, /// style: Theme.of(context).textTheme.bodyText2!,
/// child: LayoutBuilder( /// child: LayoutBuilder(
/// builder: (BuildContext context, BoxConstraints viewportConstraints) { /// builder: (BuildContext context, BoxConstraints viewportConstraints) {
/// return SingleChildScrollView( /// return SingleChildScrollView(
...@@ -154,14 +154,14 @@ import 'scrollable.dart'; ...@@ -154,14 +154,14 @@ import 'scrollable.dart';
/// so that the intrinsic sizing algorithm can short-circuit the computation when it /// so that the intrinsic sizing algorithm can short-circuit the computation when it
/// reaches those parts of the subtree. /// reaches those parts of the subtree.
/// ///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety} /// {@tool dartpad --template=stateless_widget_material}
/// In this example, the column becomes either as big as viewport, or as big as /// In this example, the column becomes either as big as viewport, or as big as
/// the contents, whichever is biggest. /// the contents, whichever is biggest.
/// ///
/// ```dart /// ```dart
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return DefaultTextStyle( /// return DefaultTextStyle(
/// style: Theme.of(context).textTheme.bodyText2, /// style: Theme.of(context).textTheme.bodyText2!,
/// child: LayoutBuilder( /// child: LayoutBuilder(
/// builder: (BuildContext context, BoxConstraints viewportConstraints) { /// builder: (BuildContext context, BoxConstraints viewportConstraints) {
/// return SingleChildScrollView( /// return SingleChildScrollView(
......
...@@ -25,7 +25,7 @@ export 'package:flutter/rendering.dart' show RelativeRect; ...@@ -25,7 +25,7 @@ export 'package:flutter/rendering.dart' show RelativeRect;
/// [AnimatedWidget] is most useful for widgets that are otherwise stateless. To /// [AnimatedWidget] is most useful for widgets that are otherwise stateless. To
/// use [AnimatedWidget], simply subclass it and implement the build function. /// use [AnimatedWidget], simply subclass it and implement the build function.
/// ///
///{@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// This code defines a widget called `Spinner` that spins a green square /// This code defines a widget called `Spinner` that spins a green square
/// continually. It is built with an [AnimatedWidget]. /// continually. It is built with an [AnimatedWidget].
...@@ -36,10 +36,12 @@ export 'package:flutter/rendering.dart' show RelativeRect; ...@@ -36,10 +36,12 @@ export 'package:flutter/rendering.dart' show RelativeRect;
/// ///
/// ```dart preamble /// ```dart preamble
/// class SpinningContainer extends AnimatedWidget { /// class SpinningContainer extends AnimatedWidget {
/// const SpinningContainer({Key key, AnimationController controller}) /// const SpinningContainer({
/// : super(key: key, listenable: controller); /// Key? key,
/// required AnimationController controller,
/// }) : super(key: key, listenable: controller);
/// ///
/// Animation<double> get _progress => listenable; /// Animation<double> get _progress => listenable as Animation<double>;
/// ///
/// @override /// @override
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
...@@ -52,16 +54,10 @@ export 'package:flutter/rendering.dart' show RelativeRect; ...@@ -52,16 +54,10 @@ export 'package:flutter/rendering.dart' show RelativeRect;
/// ``` /// ```
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// /// duration: const Duration(seconds: 10),
/// @override /// vsync: this,
/// void initState() { /// )..repeat();
/// super.initState();
/// _controller = AnimationController(
/// duration: const Duration(seconds: 10),
/// vsync: this,
/// )..repeat();
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -195,30 +191,23 @@ class _AnimatedState extends State<AnimatedWidget> { ...@@ -195,30 +191,23 @@ class _AnimatedState extends State<AnimatedWidget> {
/// animated by a [CurvedAnimation] set to [Curves.elasticIn]: /// animated by a [CurvedAnimation] set to [Curves.elasticIn]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/slide_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/slide_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold_center_freeform_state_no_null_safety} /// {@tool dartpad --template=stateful_widget_scaffold_center_freeform_state}
/// The following code implements the [SlideTransition] as seen in the video /// The following code implements the [SlideTransition] as seen in the video
/// above: /// above:
/// ///
/// ```dart /// ```dart
/// class _MyStatefulWidgetState extends State<MyStatefulWidget> with SingleTickerProviderStateMixin { /// class _MyStatefulWidgetState extends State<MyStatefulWidget> with SingleTickerProviderStateMixin {
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// Animation<Offset> _offsetAnimation; /// duration: const Duration(seconds: 2),
/// /// vsync: this,
/// @override /// )..repeat(reverse: true);
/// void initState() { /// late Animation<Offset> _offsetAnimation = Tween<Offset>(
/// super.initState(); /// begin: Offset.zero,
/// _controller = AnimationController( /// end: const Offset(1.5, 0.0),
/// duration: const Duration(seconds: 2), /// ).animate(CurvedAnimation(
/// vsync: this, /// parent: _controller,
/// )..repeat(reverse: true); /// curve: Curves.elasticIn,
/// _offsetAnimation = Tween<Offset>( /// ));
/// begin: Offset.zero,
/// end: const Offset(1.5, 0.0),
/// ).animate(CurvedAnimation(
/// parent: _controller,
/// curve: Curves.elasticIn,
/// ));
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -313,27 +302,20 @@ class SlideTransition extends AnimatedWidget { ...@@ -313,27 +302,20 @@ class SlideTransition extends AnimatedWidget {
/// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]: /// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/scale_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/scale_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// The following code implements the [ScaleTransition] as seen in the video /// The following code implements the [ScaleTransition] as seen in the video
/// above: /// above:
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// Animation<double> _animation; /// duration: const Duration(seconds: 2),
/// /// vsync: this,
/// @override /// )..repeat(reverse: true);
/// void initState() { /// late Animation<double> _animation = CurvedAnimation(
/// super.initState(); /// parent: _controller,
/// _controller = AnimationController( /// curve: Curves.fastOutSlowIn,
/// duration: const Duration(seconds: 2), /// );
/// vsync: this,
/// )..repeat(reverse: true);
/// _animation = CurvedAnimation(
/// parent: _controller,
/// curve: Curves.fastOutSlowIn,
/// );
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -416,27 +398,20 @@ class ScaleTransition extends AnimatedWidget { ...@@ -416,27 +398,20 @@ class ScaleTransition extends AnimatedWidget {
/// animated by a [CurvedAnimation] set to [Curves.elasticOut]: /// animated by a [CurvedAnimation] set to [Curves.elasticOut]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/rotation_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/rotation_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// The following code implements the [RotationTransition] as seen in the video /// The following code implements the [RotationTransition] as seen in the video
/// above: /// above:
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// Animation<double> _animation; /// duration: const Duration(seconds: 2),
/// /// vsync: this,
/// @override /// )..repeat(reverse: true);
/// void initState() { /// late Animation<double> _animation = CurvedAnimation(
/// super.initState(); /// parent: _controller,
/// _controller = AnimationController( /// curve: Curves.elasticOut,
/// duration: const Duration(seconds: 2), /// );
/// vsync: this,
/// )..repeat(reverse: true);
/// _animation = CurvedAnimation(
/// parent: _controller,
/// curve: Curves.elasticOut,
/// );
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -525,28 +500,21 @@ class RotationTransition extends AnimatedWidget { ...@@ -525,28 +500,21 @@ class RotationTransition extends AnimatedWidget {
/// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]: /// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/size_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/size_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// This code defines a widget that uses [SizeTransition] to change the size /// This code defines a widget that uses [SizeTransition] to change the size
/// of [FlutterLogo] continually. It is built with a [Scaffold] /// of [FlutterLogo] continually. It is built with a [Scaffold]
/// where the internal widget has space to change its size. /// where the internal widget has space to change its size.
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// Animation<double> _animation; /// duration: const Duration(seconds: 3),
/// /// vsync: this,
/// @override /// )..repeat();
/// void initState() { /// late Animation<double> _animation = CurvedAnimation(
/// super.initState(); /// parent: _controller,
/// _controller = AnimationController( /// curve: Curves.fastOutSlowIn,
/// duration: const Duration(seconds: 3), /// );
/// vsync: this,
/// )..repeat();
/// _animation = CurvedAnimation(
/// parent: _controller,
/// curve: Curves.fastOutSlowIn,
/// );
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -658,27 +626,20 @@ class SizeTransition extends AnimatedWidget { ...@@ -658,27 +626,20 @@ class SizeTransition extends AnimatedWidget {
/// Here's an illustration of the [FadeTransition] widget, with it's [opacity] /// Here's an illustration of the [FadeTransition] widget, with it's [opacity]
/// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]: /// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]:
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// The following code implements the [FadeTransition] using /// The following code implements the [FadeTransition] using
/// the Flutter logo: /// the Flutter logo:
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// Animation<double> _animation; /// duration: const Duration(seconds: 2),
/// /// vsync: this,
/// @override /// )..repeat(reverse: true);
/// void initState() { /// late Animation<double> _animation = CurvedAnimation(
/// super.initState(); /// parent: _controller,
/// _controller = AnimationController( /// curve: Curves.easeIn,
/// duration: const Duration(seconds: 2), /// );
/// vsync: this,
/// )..repeat(reverse: true);
/// _animation = CurvedAnimation(
/// parent: _controller,
/// curve: Curves.easeIn,
/// );
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -762,21 +723,23 @@ class FadeTransition extends SingleChildRenderObjectWidget { ...@@ -762,21 +723,23 @@ class FadeTransition extends SingleChildRenderObjectWidget {
/// Animates the opacity of a sliver widget. /// Animates the opacity of a sliver widget.
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold_center_freeform_state_no_null_safety} /// {@tool dartpad --template=stateful_widget_scaffold_center_freeform_state}
/// Creates a [CustomScrollView] with a [SliverFixedExtentList] that uses a /// Creates a [CustomScrollView] with a [SliverFixedExtentList] that uses a
/// [SliverFadeTransition] to fade the list in and out. /// [SliverFadeTransition] to fade the list in and out.
/// ///
/// ```dart /// ```dart
/// class _MyStatefulWidgetState extends State<MyStatefulWidget> with SingleTickerProviderStateMixin { /// class _MyStatefulWidgetState extends State<MyStatefulWidget> with SingleTickerProviderStateMixin {
/// AnimationController controller; /// late AnimationController controller = AnimationController(
/// Animation<double> animation; /// duration: const Duration(milliseconds: 1000),
/// vsync: this,
/// );
/// late Animation<double> animation = CurvedAnimation(
/// parent: controller,
/// curve: Curves.easeIn,
/// );
/// ///
/// initState() { /// initState() {
/// super.initState(); /// super.initState();
/// controller = AnimationController(
/// duration: const Duration(milliseconds: 1000), vsync: this);
/// animation = CurvedAnimation(parent: controller, curve: Curves.easeIn);
///
/// animation.addStatusListener((status) { /// animation.addStatusListener((status) {
/// if (status == AnimationStatus.completed) { /// if (status == AnimationStatus.completed) {
/// controller.reverse(); /// controller.reverse();
...@@ -904,22 +867,16 @@ class RelativeRectTween extends Tween<RelativeRect> { ...@@ -904,22 +867,16 @@ class RelativeRectTween extends Tween<RelativeRect> {
/// animated by a [CurvedAnimation] set to [Curves.elasticInOut]: /// animated by a [CurvedAnimation] set to [Curves.elasticInOut]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/positioned_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/positioned_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// The following code implements the [PositionedTransition] as seen in the video /// The following code implements the [PositionedTransition] as seen in the video
/// above: /// above:
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// /// duration: const Duration(seconds: 2),
/// @override /// vsync: this,
/// void initState() { /// )..repeat(reverse: true);
/// super.initState();
/// _controller = AnimationController(
/// duration: const Duration(seconds: 2),
/// vsync: this,
/// )..repeat(reverse: true);
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -1010,22 +967,16 @@ class PositionedTransition extends AnimatedWidget { ...@@ -1010,22 +967,16 @@ class PositionedTransition extends AnimatedWidget {
/// animated by a [CurvedAnimation] set to [Curves.elasticInOut]: /// animated by a [CurvedAnimation] set to [Curves.elasticInOut]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/relative_positioned_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/relative_positioned_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// The following code implements the [RelativePositionedTransition] as seen in the video /// The following code implements the [RelativePositionedTransition] as seen in the video
/// above: /// above:
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// /// duration: const Duration(seconds: 2),
/// @override /// vsync: this,
/// void initState() { /// )..repeat(reverse: true);
/// super.initState();
/// _controller = AnimationController(
/// duration: const Duration(seconds: 2),
/// vsync: this,
/// )..repeat(reverse: true);
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -1051,7 +1002,7 @@ class PositionedTransition extends AnimatedWidget { ...@@ -1051,7 +1002,7 @@ class PositionedTransition extends AnimatedWidget {
/// ).animate(CurvedAnimation( /// ).animate(CurvedAnimation(
/// parent: _controller, /// parent: _controller,
/// curve: Curves.elasticInOut, /// curve: Curves.elasticInOut,
/// )), /// )) as Animation<Rect>,
/// child: Padding( /// child: Padding(
/// padding: const EdgeInsets.all(8), /// padding: const EdgeInsets.all(8),
/// child: FlutterLogo() /// child: FlutterLogo()
...@@ -1130,7 +1081,7 @@ class RelativePositionedTransition extends AnimatedWidget { ...@@ -1130,7 +1081,7 @@ class RelativePositionedTransition extends AnimatedWidget {
/// [decoration] animated by a [CurvedAnimation] set to [Curves.decelerate]: /// [decoration] animated by a [CurvedAnimation] set to [Curves.decelerate]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/decorated_box_transition.mp4} /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/decorated_box_transition.mp4}
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// The following code implements the [DecoratedBoxTransition] as seen in the video /// The following code implements the [DecoratedBoxTransition] as seen in the video
/// above: /// above:
/// ///
...@@ -1160,16 +1111,10 @@ class RelativePositionedTransition extends AnimatedWidget { ...@@ -1160,16 +1111,10 @@ class RelativePositionedTransition extends AnimatedWidget {
/// ), /// ),
/// ); /// );
/// ///
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// /// vsync: this,
/// @override /// duration: const Duration(seconds: 3),
/// void initState() { /// )..repeat(reverse: true);
/// _controller = AnimationController(
/// vsync: this,
/// duration: const Duration(seconds: 3),
/// )..repeat(reverse: true);
/// super.initState();
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -1310,15 +1255,15 @@ class AlignTransition extends AnimatedWidget { ...@@ -1310,15 +1255,15 @@ class AlignTransition extends AnimatedWidget {
/// Animated version of a [DefaultTextStyle] that animates the different properties /// Animated version of a [DefaultTextStyle] that animates the different properties
/// of its [TextStyle]. /// of its [TextStyle].
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// The following code implements the [DefaultTextStyleTransition] that shows /// The following code implements the [DefaultTextStyleTransition] that shows
/// a transition between thick blue font and thin red font. /// a transition between thick blue font and thin red font.
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller;
/// TextStyleTween _styleTween; /// late TextStyleTween _styleTween;
/// CurvedAnimation _curvedAnimation; /// late CurvedAnimation _curvedAnimation;
/// ///
/// @override /// @override
/// void initState() { /// void initState() {
...@@ -1438,7 +1383,7 @@ class DefaultTextStyleTransition extends AnimatedWidget { ...@@ -1438,7 +1383,7 @@ class DefaultTextStyleTransition extends AnimatedWidget {
/// Using this pre-built child is entirely optional, but can improve /// Using this pre-built child is entirely optional, but can improve
/// performance significantly in some cases and is therefore a good practice. /// performance significantly in some cases and is therefore a good practice.
/// ///
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety} /// {@tool dartpad --template=stateful_widget_material_ticker}
/// ///
/// This code defines a widget that spins a green square continually. It is /// This code defines a widget that spins a green square continually. It is
/// built with an [AnimatedBuilder] and makes use of the [child] feature to /// built with an [AnimatedBuilder] and makes use of the [child] feature to
...@@ -1449,16 +1394,10 @@ class DefaultTextStyleTransition extends AnimatedWidget { ...@@ -1449,16 +1394,10 @@ class DefaultTextStyleTransition extends AnimatedWidget {
/// ``` /// ```
/// ///
/// ```dart /// ```dart
/// AnimationController _controller; /// late AnimationController _controller = AnimationController(
/// /// duration: const Duration(seconds: 10),
/// @override /// vsync: this,
/// void initState() { /// )..repeat();
/// super.initState();
/// _controller = AnimationController(
/// duration: const Duration(seconds: 10),
/// vsync: this,
/// )..repeat();
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -1478,7 +1417,7 @@ class DefaultTextStyleTransition extends AnimatedWidget { ...@@ -1478,7 +1417,7 @@ class DefaultTextStyleTransition extends AnimatedWidget {
/// child: Text('Whee!'), /// child: Text('Whee!'),
/// ), /// ),
/// ), /// ),
/// builder: (BuildContext context, Widget child) { /// builder: (BuildContext context, Widget? child) {
/// return Transform.rotate( /// return Transform.rotate(
/// angle: _controller.value * 2.0 * math.pi, /// angle: _controller.value * 2.0 * math.pi,
/// child: child, /// child: child,
......
...@@ -61,7 +61,7 @@ import 'value_listenable_builder.dart'; ...@@ -61,7 +61,7 @@ import 'value_listenable_builder.dart';
/// ///
/// ## Example Code /// ## Example Code
/// ///
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety} /// {@tool dartpad --template=stateful_widget_scaffold_center}
/// This example shows an [IconButton] that "zooms" in when the widget first /// This example shows an [IconButton] that "zooms" in when the widget first
/// builds (its size smoothly increases from 0 to 24) and whenever the button /// builds (its size smoothly increases from 0 to 24) and whenever the button
/// is pressed, it smoothly changes its size to the new target value of either /// is pressed, it smoothly changes its size to the new target value of either
...@@ -75,11 +75,11 @@ import 'value_listenable_builder.dart'; ...@@ -75,11 +75,11 @@ import 'value_listenable_builder.dart';
/// return TweenAnimationBuilder( /// return TweenAnimationBuilder(
/// tween: Tween<double>(begin: 0, end: targetValue), /// tween: Tween<double>(begin: 0, end: targetValue),
/// duration: Duration(seconds: 1), /// duration: Duration(seconds: 1),
/// builder: (BuildContext context, double size, Widget child) { /// builder: (BuildContext context, double size, Widget? child) {
/// return IconButton( /// return IconButton(
/// iconSize: size, /// iconSize: size,
/// color: Colors.blue, /// color: Colors.blue,
/// icon: child, /// icon: child!,
/// onPressed: () { /// onPressed: () {
/// setState(() { /// setState(() {
/// targetValue = targetValue == 24.0 ? 48.0 : 24.0; /// targetValue = targetValue == 24.0 ? 48.0 : 24.0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment