Showing
2 changed files
with
20 additions
and
0 deletions
| @@ -647,3 +647,22 @@ class SizedBox extends StatelessWidget { | @@ -647,3 +647,22 @@ class SizedBox extends StatelessWidget { | ||
| 647 | constraints: BoxConstraints.tightFor(width: width, height: height)); | 647 | constraints: BoxConstraints.tightFor(width: width, height: height)); |
| 648 | } | 648 | } |
| 649 | } | 649 | } |
| 650 | + | ||
| 651 | +typedef WidgetBuilder = Widget Function(Context context); | ||
| 652 | + | ||
| 653 | +/// A platonic widget that calls a closure to obtain its child widget. | ||
| 654 | +class Builder extends StatelessWidget { | ||
| 655 | + /// Creates a widget that delegates its build to a callback. | ||
| 656 | + /// | ||
| 657 | + /// The [builder] argument must not be null. | ||
| 658 | + Builder({ | ||
| 659 | + @required this.builder, | ||
| 660 | + }) : assert(builder != null), | ||
| 661 | + super(); | ||
| 662 | + | ||
| 663 | + /// Called to obtain the child widget. | ||
| 664 | + final WidgetBuilder builder; | ||
| 665 | + | ||
| 666 | + @override | ||
| 667 | + Widget build(Context context) => builder(context); | ||
| 668 | +} |
-
Please register or login to post a comment