Unverified Commit a665dd1c authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate more doc samples (#72392)

parent 0dc80621
...@@ -11,8 +11,7 @@ import 'framework.dart'; ...@@ -11,8 +11,7 @@ import 'framework.dart';
import 'image.dart'; import 'image.dart';
// Examples can assume: // Examples can assume:
// // @dart = 2.9 // late BuildContext context;
// BuildContext context;
/// A widget that paints a [Decoration] either before or after its child paints. /// A widget that paints a [Decoration] either before or after its child paints.
/// ///
...@@ -219,7 +218,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { ...@@ -219,7 +218,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget {
/// ```dart /// ```dart
/// Container( /// Container(
/// constraints: BoxConstraints.expand( /// constraints: BoxConstraints.expand(
/// height: Theme.of(context).textTheme.headline4.fontSize * 1.1 + 200.0, /// height: Theme.of(context).textTheme.headline4!.fontSize! * 1.1 + 200.0,
/// ), /// ),
/// padding: const EdgeInsets.all(8.0), /// padding: const EdgeInsets.all(8.0),
/// color: Colors.blue[600], /// color: Colors.blue[600],
...@@ -227,7 +226,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { ...@@ -227,7 +226,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget {
/// child: Text('Hello World', /// child: Text('Hello World',
/// style: Theme.of(context) /// style: Theme.of(context)
/// .textTheme /// .textTheme
/// .headline4 /// .headline4!
/// .copyWith(color: Colors.white)), /// .copyWith(color: Colors.white)),
/// transform: Matrix4.rotationZ(0.1), /// transform: Matrix4.rotationZ(0.1),
/// ) /// )
......
...@@ -14,8 +14,7 @@ import 'implicit_animations.dart'; ...@@ -14,8 +14,7 @@ import 'implicit_animations.dart';
import 'transitions.dart'; import 'transitions.dart';
// Examples can assume: // Examples can assume:
// // @dart = 2.9 // late Uint8List bytes;
// Uint8List bytes;
/// An image that shows a [placeholder] image while the target [image] is /// An image that shows a [placeholder] image while the target [image] is
/// loading, then fades in the new image when it loads. /// loading, then fades in the new image when it loads.
......
...@@ -30,12 +30,11 @@ export 'package:flutter/foundation.dart' show Key, LocalKey, ValueKey; ...@@ -30,12 +30,11 @@ export 'package:flutter/foundation.dart' show Key, LocalKey, ValueKey;
export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugDumpRenderTree, debugDumpLayerTree; export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugDumpRenderTree, debugDumpLayerTree;
// Examples can assume: // Examples can assume:
// // @dart = 2.9 // late BuildContext context;
// BuildContext context;
// void setState(VoidCallback fn) { } // void setState(VoidCallback fn) { }
// abstract class RenderFrogJar extends RenderObject { } // abstract class RenderFrogJar extends RenderObject { }
// abstract class FrogJar extends RenderObjectWidget { } // abstract class FrogJar extends RenderObjectWidget { }
// abstract class FrogJarParentData extends ParentData { Size size; } // abstract class FrogJarParentData extends ParentData { late Size size; }
// KEYS // KEYS
...@@ -624,7 +623,7 @@ abstract class Widget extends DiagnosticableTree { ...@@ -624,7 +623,7 @@ abstract class Widget extends DiagnosticableTree {
/// ///
/// ```dart /// ```dart
/// class GreenFrog extends StatelessWidget { /// class GreenFrog extends StatelessWidget {
/// const GreenFrog({ Key key }) : super(key: key); /// const GreenFrog({ Key? key }) : super(key: key);
/// ///
/// @override /// @override
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
...@@ -642,13 +641,13 @@ abstract class Widget extends DiagnosticableTree { ...@@ -642,13 +641,13 @@ abstract class Widget extends DiagnosticableTree {
/// ```dart /// ```dart
/// class Frog extends StatelessWidget { /// class Frog extends StatelessWidget {
/// const Frog({ /// const Frog({
/// Key key, /// Key? key,
/// this.color = const Color(0xFF2DBD3A), /// this.color = const Color(0xFF2DBD3A),
/// this.child, /// this.child,
/// }) : super(key: key); /// }) : super(key: key);
/// ///
/// final Color color; /// final Color color;
/// final Widget child; /// final Widget? child;
/// ///
/// @override /// @override
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
...@@ -841,7 +840,7 @@ abstract class StatelessWidget extends Widget { ...@@ -841,7 +840,7 @@ abstract class StatelessWidget extends Widget {
/// ///
/// ```dart /// ```dart
/// class YellowBird extends StatefulWidget { /// class YellowBird extends StatefulWidget {
/// const YellowBird({ Key key }) : super(key: key); /// const YellowBird({ Key? key }) : super(key: key);
/// ///
/// @override /// @override
/// _YellowBirdState createState() => _YellowBirdState(); /// _YellowBirdState createState() => _YellowBirdState();
...@@ -864,13 +863,13 @@ abstract class StatelessWidget extends Widget { ...@@ -864,13 +863,13 @@ abstract class StatelessWidget extends Widget {
/// ```dart /// ```dart
/// class Bird extends StatefulWidget { /// class Bird extends StatefulWidget {
/// const Bird({ /// const Bird({
/// Key key, /// Key? key,
/// this.color = const Color(0xFFFFE306), /// this.color = const Color(0xFFFFE306),
/// this.child, /// this.child,
/// }) : super(key: key); /// }) : super(key: key);
/// ///
/// final Color color; /// final Color color;
/// final Widget child; /// final Widget? child;
/// ///
/// _BirdState createState() => _BirdState(); /// _BirdState createState() => _BirdState();
/// } /// }
...@@ -1531,21 +1530,19 @@ abstract class ProxyWidget extends Widget { ...@@ -1531,21 +1530,19 @@ abstract class ProxyWidget extends Widget {
/// ```dart /// ```dart
/// class FrogSize extends ParentDataWidget<FrogJarParentData> { /// class FrogSize extends ParentDataWidget<FrogJarParentData> {
/// FrogSize({ /// FrogSize({
/// Key key, /// Key? key,
/// @required this.size, /// required this.size,
/// @required Widget child, /// required Widget child,
/// }) : assert(child != null), /// }) : super(key: key, child: child);
/// assert(size != null),
/// super(key: key, child: child);
/// ///
/// final Size size; /// final Size size;
/// ///
/// @override /// @override
/// void applyParentData(RenderObject renderObject) { /// void applyParentData(RenderObject renderObject) {
/// final FrogJarParentData parentData = renderObject.parentData; /// final FrogJarParentData parentData = renderObject.parentData! as FrogJarParentData;
/// if (parentData.size != size) { /// if (parentData.size != size) {
/// parentData.size = size; /// parentData.size = size;
/// final RenderFrogJar targetParent = renderObject.parent; /// final RenderFrogJar targetParent = renderObject.parent! as RenderFrogJar;
/// targetParent.markNeedsLayout(); /// targetParent.markNeedsLayout();
/// } /// }
/// } /// }
...@@ -1684,17 +1681,17 @@ abstract class ParentDataWidget<T extends ParentData> extends ProxyWidget { ...@@ -1684,17 +1681,17 @@ abstract class ParentDataWidget<T extends ParentData> extends ProxyWidget {
/// ```dart /// ```dart
/// class FrogColor extends InheritedWidget { /// class FrogColor extends InheritedWidget {
/// const FrogColor({ /// const FrogColor({
/// Key key, /// Key? key,
/// @required this.color, /// required this.color,
/// @required Widget child, /// required Widget child,
/// }) : assert(color != null), /// }) : super(key: key, child: child);
/// assert(child != null),
/// super(key: key, child: child);
/// ///
/// final Color color; /// final Color color;
/// ///
/// static FrogColor of(BuildContext context) { /// static FrogColor of(BuildContext context) {
/// return context.dependOnInheritedWidgetOfExactType<FrogColor>(); /// final FrogColor? result = context.dependOnInheritedWidgetOfExactType<FrogColor>();
/// assert(result != null, 'No FrogColor found in context');
/// return result!;
/// } /// }
/// ///
/// @override /// @override
...@@ -2420,7 +2417,7 @@ abstract class BuildContext { ...@@ -2420,7 +2417,7 @@ abstract class BuildContext {
/// {@tool snippet} /// {@tool snippet}
/// ///
/// ```dart /// ```dart
/// ScrollableState scrollable = context.findAncestorStateOfType<ScrollableState>(); /// ScrollableState? scrollable = context.findAncestorStateOfType<ScrollableState>();
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
T? findAncestorStateOfType<T extends State>(); T? findAncestorStateOfType<T extends State>();
...@@ -4436,7 +4433,7 @@ typedef ErrorWidgetBuilder = Widget Function(FlutterErrorDetails details); ...@@ -4436,7 +4433,7 @@ typedef ErrorWidgetBuilder = Widget Function(FlutterErrorDetails details);
/// ///
/// It is possible to override this widget. /// It is possible to override this widget.
/// ///
/// {@tool sample --template=freeform_no_null_safety} /// {@tool sample --template=freeform}
/// ```dart /// ```dart
/// import 'package:flutter/material.dart'; /// import 'package:flutter/material.dart';
/// ///
......
...@@ -27,9 +27,6 @@ import 'sliver.dart'; ...@@ -27,9 +27,6 @@ import 'sliver.dart';
import 'sliver_fill.dart'; import 'sliver_fill.dart';
import 'viewport.dart'; import 'viewport.dart';
// Examples can assume:
// // @dart = 2.9
/// A controller for [PageView]. /// A controller for [PageView].
/// ///
/// A page controller lets you manipulate which page is visible in a [PageView]. /// A page controller lets you manipulate which page is visible in a [PageView].
...@@ -49,19 +46,13 @@ import 'viewport.dart'; ...@@ -49,19 +46,13 @@ import 'viewport.dart';
/// ///
/// ```dart /// ```dart
/// class MyPageView extends StatefulWidget { /// class MyPageView extends StatefulWidget {
/// MyPageView({Key key}) : super(key: key); /// MyPageView({Key? key}) : super(key: key);
/// ///
/// _MyPageViewState createState() => _MyPageViewState(); /// _MyPageViewState createState() => _MyPageViewState();
/// } /// }
/// ///
/// class _MyPageViewState extends State<MyPageView> { /// class _MyPageViewState extends State<MyPageView> {
/// PageController _pageController; /// PageController _pageController = PageController();
///
/// @override
/// void initState() {
/// super.initState();
/// _pageController = PageController();
/// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
...@@ -725,7 +716,7 @@ class PageView extends StatefulWidget { ...@@ -725,7 +716,7 @@ class PageView extends StatefulWidget {
/// }, /// },
/// childCount: items.length, /// childCount: items.length,
/// findChildIndexCallback: (Key key) { /// findChildIndexCallback: (Key key) {
/// final ValueKey valueKey = key; /// final ValueKey<String> valueKey = key as ValueKey<String>;
/// final String data = valueKey.value; /// final String data = valueKey.value;
/// return items.indexOf(data); /// return items.indexOf(data);
/// } /// }
...@@ -748,7 +739,7 @@ class PageView extends StatefulWidget { ...@@ -748,7 +739,7 @@ class PageView extends StatefulWidget {
/// } /// }
/// ///
/// class KeepAlive extends StatefulWidget { /// class KeepAlive extends StatefulWidget {
/// const KeepAlive({Key key, this.data}) : super(key: key); /// const KeepAlive({Key? key, required this.data}) : super(key: key);
/// ///
/// final String data; /// final String data;
/// ///
......
...@@ -17,12 +17,15 @@ import 'scroll_simulation.dart'; ...@@ -17,12 +17,15 @@ import 'scroll_simulation.dart';
export 'package:flutter/physics.dart' show Simulation, ScrollSpringSimulation, Tolerance; export 'package:flutter/physics.dart' show Simulation, ScrollSpringSimulation, Tolerance;
// Examples can assume: // Examples can assume:
// // @dart = 2.9
// class FooScrollPhysics extends ScrollPhysics { // class FooScrollPhysics extends ScrollPhysics {
// const FooScrollPhysics({ ScrollPhysics parent }): super(parent: parent); // const FooScrollPhysics({ ScrollPhysics? parent }): super(parent: parent);
// @override
// FooScrollPhysics applyTo(ScrollPhysics? ancestor) {
// return FooScrollPhysics(parent: buildParent(ancestor));
// }
// } // }
// class BarScrollPhysics extends ScrollPhysics { // class BarScrollPhysics extends ScrollPhysics {
// const BarScrollPhysics({ ScrollPhysics parent }): super(parent: parent); // const BarScrollPhysics({ ScrollPhysics? parent }): super(parent: parent);
// } // }
/// Determines the physics of a [Scrollable] widget. /// Determines the physics of a [Scrollable] widget.
......
...@@ -6,9 +6,6 @@ import 'package:flutter/foundation.dart'; ...@@ -6,9 +6,6 @@ import 'package:flutter/foundation.dart';
import 'framework.dart'; import 'framework.dart';
// Examples can assume:
// // @dart = 2.9
/// Builds a [Widget] when given a concrete value of a [ValueListenable<T>]. /// Builds a [Widget] when given a concrete value of a [ValueListenable<T>].
/// ///
/// If the `child` parameter provided to the [ValueListenableBuilder] is not /// If the `child` parameter provided to the [ValueListenableBuilder] is not
...@@ -50,7 +47,7 @@ typedef ValueWidgetBuilder<T> = Widget Function(BuildContext context, T value, W ...@@ -50,7 +47,7 @@ typedef ValueWidgetBuilder<T> = Widget Function(BuildContext context, T value, W
/// ///
/// ```dart /// ```dart
/// class MyHomePage extends StatefulWidget { /// class MyHomePage extends StatefulWidget {
/// MyHomePage({Key key, this.title}) : super(key: key); /// MyHomePage({Key? key, required this.title}) : super(key: key);
/// final String title; /// final String title;
/// ///
/// @override /// @override
...@@ -72,14 +69,14 @@ typedef ValueWidgetBuilder<T> = Widget Function(BuildContext context, T value, W ...@@ -72,14 +69,14 @@ typedef ValueWidgetBuilder<T> = Widget Function(BuildContext context, T value, W
/// children: <Widget>[ /// children: <Widget>[
/// Text('You have pushed the button this many times:'), /// Text('You have pushed the button this many times:'),
/// ValueListenableBuilder( /// ValueListenableBuilder(
/// builder: (BuildContext context, int value, Widget child) { /// builder: (BuildContext context, int value, Widget? child) {
/// // This builder will only get called when the _counter /// // This builder will only get called when the _counter
/// // is updated. /// // is updated.
/// return Row( /// return Row(
/// mainAxisAlignment: MainAxisAlignment.spaceEvenly, /// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
/// children: <Widget>[ /// children: <Widget>[
/// Text('$value'), /// Text('$value'),
/// child, /// child!,
/// ], /// ],
/// ); /// );
/// }, /// },
......
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