Unverified Commit 21c6dda1 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

assert(elevation >= 0.0) and doc clarifications (#25345)

parent 89fa4cc5
...@@ -131,7 +131,8 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { ...@@ -131,7 +131,8 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
/// Creates a material design app bar. /// Creates a material design app bar.
/// ///
/// The arguments [elevation], [primary], [toolbarOpacity], [bottomOpacity] /// The arguments [elevation], [primary], [toolbarOpacity], [bottomOpacity]
/// and [automaticallyImplyLeading] must not be null. /// and [automaticallyImplyLeading] must not be null. Additionally,
/// [elevation] must be non-negative.
/// ///
/// Typically used in the [Scaffold.appBar] property. /// Typically used in the [Scaffold.appBar] property.
AppBar({ AppBar({
...@@ -153,7 +154,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { ...@@ -153,7 +154,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
this.toolbarOpacity = 1.0, this.toolbarOpacity = 1.0,
this.bottomOpacity = 1.0, this.bottomOpacity = 1.0,
}) : assert(automaticallyImplyLeading != null), }) : assert(automaticallyImplyLeading != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(primary != null), assert(primary != null),
assert(titleSpacing != null), assert(titleSpacing != null),
assert(toolbarOpacity != null), assert(toolbarOpacity != null),
...@@ -264,10 +265,13 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { ...@@ -264,10 +265,13 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
/// * [PreferredSize], which can be used to give an arbitrary widget a preferred size. /// * [PreferredSize], which can be used to give an arbitrary widget a preferred size.
final PreferredSizeWidget bottom; final PreferredSizeWidget bottom;
/// The z-coordinate at which to place this app bar. This controls the size of /// The z-coordinate at which to place this app bar relative to its parent.
/// the shadow below the app bar. ///
/// This controls the size of the shadow below the app bar.
/// ///
/// Defaults to 4, the appropriate elevation for app bars. /// Defaults to 4, the appropriate elevation for app bars.
///
/// The value is non-negative.
final double elevation; final double elevation;
/// The color to use for the app bar's material. Typically this should be set /// The color to use for the app bar's material. Typically this should be set
......
...@@ -42,6 +42,7 @@ class BottomAppBar extends StatefulWidget { ...@@ -42,6 +42,7 @@ class BottomAppBar extends StatefulWidget {
/// Creates a bottom application bar. /// Creates a bottom application bar.
/// ///
/// The [color], [elevation], and [clipBehavior] arguments must not be null. /// The [color], [elevation], and [clipBehavior] arguments must not be null.
/// Additionally, [elevation] must be non-negative.
const BottomAppBar({ const BottomAppBar({
Key key, Key key,
this.color, this.color,
...@@ -68,8 +69,11 @@ class BottomAppBar extends StatefulWidget { ...@@ -68,8 +69,11 @@ class BottomAppBar extends StatefulWidget {
/// When null defaults to [ThemeData.bottomAppBarColor]. /// When null defaults to [ThemeData.bottomAppBarColor].
final Color color; final Color color;
/// The z-coordinate at which to place this bottom app bar. This controls the /// The z-coordinate at which to place this bottom app bar relative to its
/// size of the shadow below the bottom app bar. /// parent.
///
/// This controls the size of the shadow below the bottom app bar. The
/// value is non-negative.
/// ///
/// Defaults to 8, the appropriate elevation for bottom app bars. /// Defaults to 8, the appropriate elevation for bottom app bars.
final double elevation; final double elevation;
......
...@@ -59,7 +59,7 @@ class BottomSheet extends StatefulWidget { ...@@ -59,7 +59,7 @@ class BottomSheet extends StatefulWidget {
}) : assert(enableDrag != null), }) : assert(enableDrag != null),
assert(onClosing != null), assert(onClosing != null),
assert(builder != null), assert(builder != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
super(key: key); super(key: key);
/// The animation that controls the bottom sheet's position. /// The animation that controls the bottom sheet's position.
...@@ -87,10 +87,11 @@ class BottomSheet extends StatefulWidget { ...@@ -87,10 +87,11 @@ class BottomSheet extends StatefulWidget {
/// Default is true. /// Default is true.
final bool enableDrag; final bool enableDrag;
/// The z-coordinate at which to place this material. This controls the size /// The z-coordinate at which to place this material relative to its parent.
/// of the shadow below the material.
/// ///
/// Defaults to 0. /// This controls the size of the shadow below the material.
///
/// Defaults to 0. The value is non-negative.
final double elevation; final double elevation;
@override @override
......
...@@ -28,8 +28,10 @@ import 'theme_data.dart'; ...@@ -28,8 +28,10 @@ import 'theme_data.dart';
class RawMaterialButton extends StatefulWidget { class RawMaterialButton extends StatefulWidget {
/// Create a button based on [Semantics], [Material], and [InkWell] widgets. /// Create a button based on [Semantics], [Material], and [InkWell] widgets.
/// ///
/// The [shape], [elevation], [padding], [constraints], and [clipBehavior] /// The [shape], [elevation], [highlightElevation], [disabledElevation],
/// arguments must not be null. /// [padding], [constraints], and [clipBehavior] arguments must not be null.
/// Additionally, [elevation], [highlightElevation], and [disabledElevation]
/// must be non-negative.
const RawMaterialButton({ const RawMaterialButton({
Key key, Key key,
@required this.onPressed, @required this.onPressed,
...@@ -50,9 +52,9 @@ class RawMaterialButton extends StatefulWidget { ...@@ -50,9 +52,9 @@ class RawMaterialButton extends StatefulWidget {
this.child, this.child,
}) : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded, }) : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded,
assert(shape != null), assert(shape != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(highlightElevation != null), assert(highlightElevation != null && highlightElevation >= 0.0),
assert(disabledElevation != null), assert(disabledElevation != null && disabledElevation >= 0.0),
assert(padding != null), assert(padding != null),
assert(constraints != null), assert(constraints != null),
assert(animationDuration != null), assert(animationDuration != null),
...@@ -84,7 +86,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -84,7 +86,7 @@ class RawMaterialButton extends StatefulWidget {
/// The elevation for the button's [Material] when the button /// The elevation for the button's [Material] when the button
/// is [enabled] but not pressed. /// is [enabled] but not pressed.
/// ///
/// Defaults to 2.0. /// Defaults to 2.0. The value is always non-negative.
/// ///
/// See also: /// See also:
/// ///
...@@ -95,7 +97,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -95,7 +97,7 @@ class RawMaterialButton extends StatefulWidget {
/// The elevation for the button's [Material] when the button /// The elevation for the button's [Material] when the button
/// is [enabled] and pressed. /// is [enabled] and pressed.
/// ///
/// Defaults to 8.0. /// Defaults to 8.0. The value is always non-negative.
/// ///
/// See also: /// See also:
/// ///
...@@ -106,7 +108,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -106,7 +108,7 @@ class RawMaterialButton extends StatefulWidget {
/// The elevation for the button's [Material] when the button /// The elevation for the button's [Material] when the button
/// is not [enabled]. /// is not [enabled].
/// ///
/// Defaults to 0.0. /// Defaults to 0.0. The value is always non-negative.
/// ///
/// * [elevation], the default elevation. /// * [elevation], the default elevation.
/// * [highlightElevation], the elevation when the button is pressed. /// * [highlightElevation], the elevation when the button is pressed.
......
...@@ -65,17 +65,19 @@ import 'theme.dart'; ...@@ -65,17 +65,19 @@ import 'theme.dart';
class Card extends StatelessWidget { class Card extends StatelessWidget {
/// Creates a material design card. /// Creates a material design card.
/// ///
/// The [clipBehavior] argument must not be null. /// The [clipBehavior] and [elevation] arguments must not be null.
/// Additionally, the [elevation] must be non-negative.
const Card({ const Card({
Key key, Key key,
this.color, this.color,
this.elevation, this.elevation = 1.0,
this.shape, this.shape,
this.margin = const EdgeInsets.all(4.0), this.margin = const EdgeInsets.all(4.0),
this.clipBehavior = Clip.none, this.clipBehavior = Clip.none,
this.child, this.child,
this.semanticContainer = true, this.semanticContainer = true,
}) : super(key: key); }) : assert(elevation != null && elevation >= 0.0),
super(key: key);
/// The card's background color. /// The card's background color.
/// ///
...@@ -89,7 +91,7 @@ class Card extends StatelessWidget { ...@@ -89,7 +91,7 @@ class Card extends StatelessWidget {
/// ///
/// Defines the card's [Material.elevation]. /// Defines the card's [Material.elevation].
/// ///
/// The default elevation is 1.0. /// The default elevation is 1.0. The value is always non-negative.
final double elevation; final double elevation;
/// The shape of the card's [Material]. /// The shape of the card's [Material].
...@@ -139,7 +141,7 @@ class Card extends StatelessWidget { ...@@ -139,7 +141,7 @@ class Card extends StatelessWidget {
child: Material( child: Material(
type: MaterialType.card, type: MaterialType.card,
color: color ?? Theme.of(context).cardColor, color: color ?? Theme.of(context).cardColor,
elevation: elevation ?? 1.0, elevation: elevation,
shape: shape ?? const RoundedRectangleBorder( shape: shape ?? const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0)), borderRadius: BorderRadius.all(Radius.circular(4.0)),
), ),
......
...@@ -287,10 +287,12 @@ abstract class SelectableChipAttributes { ...@@ -287,10 +287,12 @@ abstract class SelectableChipAttributes {
/// {@end-tool} /// {@end-tool}
ValueChanged<bool> get onSelected; ValueChanged<bool> get onSelected;
/// Elevation to be applied on the chip during the press motion. /// Elevation to be applied on the chip relative to its parent during the
/// press motion.
///
/// This controls the size of the shadow below the chip. /// This controls the size of the shadow below the chip.
/// ///
/// Defaults to 8. /// Defaults to 8. The value is always non-negative.
double get pressElevation; double get pressElevation;
/// Color to be used for the chip's background, indicating that it is /// Color to be used for the chip's background, indicating that it is
...@@ -397,10 +399,12 @@ abstract class TappableChipAttributes { ...@@ -397,10 +399,12 @@ abstract class TappableChipAttributes {
/// {@end-tool} /// {@end-tool}
VoidCallback get onPressed; VoidCallback get onPressed;
/// Elevation to be applied on the chip during the press motion. /// Elevation to be applied on the chip relative to its parent during the
/// press motion.
///
/// This controls the size of the shadow below the chip. /// This controls the size of the shadow below the chip.
/// ///
/// Defaults to 8. /// Defaults to 8. The value is always non-negative.
double get pressElevation; double get pressElevation;
/// Tooltip string to be used for the body area (where the label and avatar /// Tooltip string to be used for the body area (where the label and avatar
...@@ -1159,7 +1163,8 @@ class RawChip extends StatefulWidget ...@@ -1159,7 +1163,8 @@ class RawChip extends StatefulWidget
/// The [onPressed] and [onSelected] callbacks must not both be specified at /// The [onPressed] and [onSelected] callbacks must not both be specified at
/// the same time. /// the same time.
/// ///
/// The [label], [isEnabled], and [clipBehavior] arguments must not be null. /// The [label], [pressElevation], [isEnabled], and [clipBehavior] arguments
/// must not be null. Additionally, [pressElevation] must be non-negative.
const RawChip({ const RawChip({
Key key, Key key,
this.avatar, this.avatar,
...@@ -1188,6 +1193,7 @@ class RawChip extends StatefulWidget ...@@ -1188,6 +1193,7 @@ class RawChip extends StatefulWidget
}) : assert(label != null), }) : assert(label != null),
assert(isEnabled != null), assert(isEnabled != null),
assert(clipBehavior != null), assert(clipBehavior != null),
assert(pressElevation != null && pressElevation >= 0.0),
deleteIcon = deleteIcon ?? _kDefaultDeleteIcon, deleteIcon = deleteIcon ?? _kDefaultDeleteIcon,
super(key: key); super(key: key);
......
...@@ -85,17 +85,22 @@ class Drawer extends StatelessWidget { ...@@ -85,17 +85,22 @@ class Drawer extends StatelessWidget {
/// Creates a material design drawer. /// Creates a material design drawer.
/// ///
/// Typically used in the [Scaffold.drawer] property. /// Typically used in the [Scaffold.drawer] property.
///
/// The [elevation] must be non-negative.
const Drawer({ const Drawer({
Key key, Key key,
this.elevation = 16.0, this.elevation = 16.0,
this.child, this.child,
this.semanticLabel, this.semanticLabel,
}) : super(key: key); }) : assert(elevation != null && elevation >= 0.0),
super(key: key);
/// The z-coordinate at which to place this drawer. This controls the size of /// The z-coordinate at which to place this drawer relative to its parent.
/// the shadow below the drawer. ///
/// This controls the size of the shadow below the drawer.
/// ///
/// Defaults to 16, the appropriate elevation for drawers. /// Defaults to 16, the appropriate elevation for drawers. The value is
/// always non-negative.
final double elevation; final double elevation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
......
...@@ -58,7 +58,8 @@ class FloatingActionButton extends StatefulWidget { ...@@ -58,7 +58,8 @@ class FloatingActionButton extends StatefulWidget {
/// Creates a circular floating action button. /// Creates a circular floating action button.
/// ///
/// The [elevation], [highlightElevation], [mini], [shape], and [clipBehavior] /// The [elevation], [highlightElevation], [mini], [shape], and [clipBehavior]
/// arguments must not be null. /// arguments must not be null. Additionally, [elevation] and
/// [highlightElevation] must be non-negative.
const FloatingActionButton({ const FloatingActionButton({
Key key, Key key,
this.child, this.child,
...@@ -74,8 +75,8 @@ class FloatingActionButton extends StatefulWidget { ...@@ -74,8 +75,8 @@ class FloatingActionButton extends StatefulWidget {
this.clipBehavior = Clip.none, this.clipBehavior = Clip.none,
this.materialTapTargetSize, this.materialTapTargetSize,
this.isExtended = false, this.isExtended = false,
}) : assert(elevation != null), }) : assert(elevation != null && elevation >= 0.0),
assert(highlightElevation != null), assert(highlightElevation != null && highlightElevation >= 0.0),
assert(mini != null), assert(mini != null),
assert(shape != null), assert(shape != null),
assert(isExtended != null), assert(isExtended != null),
...@@ -86,7 +87,8 @@ class FloatingActionButton extends StatefulWidget { ...@@ -86,7 +87,8 @@ class FloatingActionButton extends StatefulWidget {
/// an [icon] and a [label]. /// an [icon] and a [label].
/// ///
/// The [label], [icon], [elevation], [highlightElevation], [clipBehavior] /// The [label], [icon], [elevation], [highlightElevation], [clipBehavior]
/// and [shape] arguments must not be null. /// and [shape] arguments must not be null. Additionally, [elevation] and
// [highlightElevation] must be non-negative.
FloatingActionButton.extended({ FloatingActionButton.extended({
Key key, Key key,
this.tooltip, this.tooltip,
...@@ -102,8 +104,8 @@ class FloatingActionButton extends StatefulWidget { ...@@ -102,8 +104,8 @@ class FloatingActionButton extends StatefulWidget {
this.clipBehavior = Clip.none, this.clipBehavior = Clip.none,
@required Widget icon, @required Widget icon,
@required Widget label, @required Widget label,
}) : assert(elevation != null), }) : assert(elevation != null && elevation >= 0.0),
assert(highlightElevation != null), assert(highlightElevation != null && highlightElevation >= 0.0),
assert(shape != null), assert(shape != null),
assert(isExtended != null), assert(isExtended != null),
assert(clipBehavior != null), assert(clipBehavior != null),
...@@ -163,18 +165,22 @@ class FloatingActionButton extends StatefulWidget { ...@@ -163,18 +165,22 @@ class FloatingActionButton extends StatefulWidget {
/// If this is set to null, the button will be disabled. /// If this is set to null, the button will be disabled.
final VoidCallback onPressed; final VoidCallback onPressed;
/// The z-coordinate at which to place this button. This controls the size of /// The z-coordinate at which to place this button releative to its parent.
/// the shadow below the floating action button.
/// ///
/// Defaults to 6, the appropriate elevation for floating action buttons. ///
/// This controls the size of the shadow below the floating action button.
///
/// Defaults to 6, the appropriate elevation for floating action buttons. The
/// value is always non-negative.
final double elevation; final double elevation;
/// The z-coordinate at which to place this button when the user is touching /// The z-coordinate at which to place this button relative to its parent when
/// the button. This controls the size of the shadow below the floating action /// the user is touching the button.
/// button. ///
/// This controls the size of the shadow below the floating action button.
/// ///
/// Defaults to 12, the appropriate elevation for floating action buttons /// Defaults to 12, the appropriate elevation for floating action buttons
/// while they are being touched. /// while they are being touched. The value is always non-negative.
/// ///
/// See also: /// See also:
/// ///
......
...@@ -156,7 +156,7 @@ class Material extends StatefulWidget { ...@@ -156,7 +156,7 @@ class Material extends StatefulWidget {
/// Creates a piece of material. /// Creates a piece of material.
/// ///
/// The [type], [elevation], [shadowColor], and [animationDuration] arguments /// The [type], [elevation], [shadowColor], and [animationDuration] arguments
/// must not be null. /// must not be null. Additionally, [elevation] must be non-negative.
/// ///
/// If a [shape] is specified, then the [borderRadius] property must be /// If a [shape] is specified, then the [borderRadius] property must be
/// null and the [type] property must not be [MaterialType.circle]. If the /// null and the [type] property must not be [MaterialType.circle]. If the
...@@ -176,7 +176,7 @@ class Material extends StatefulWidget { ...@@ -176,7 +176,7 @@ class Material extends StatefulWidget {
this.animationDuration = kThemeChangeDuration, this.animationDuration = kThemeChangeDuration,
this.child, this.child,
}) : assert(type != null), }) : assert(type != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(shadowColor != null), assert(shadowColor != null),
assert(!(shape != null && borderRadius != null)), assert(!(shape != null && borderRadius != null)),
assert(animationDuration != null), assert(animationDuration != null),
...@@ -195,14 +195,17 @@ class Material extends StatefulWidget { ...@@ -195,14 +195,17 @@ class Material extends StatefulWidget {
final MaterialType type; final MaterialType type;
/// {@template flutter.material.material.elevation} /// {@template flutter.material.material.elevation}
/// The z-coordinate at which to place this material. This controls the size /// The z-coordinate at which to place this material relative to its parent.
/// of the shadow below the material. ///
/// This controls the size of the shadow below the material.
/// ///
/// If this is non-zero, the contents of the material are clipped, because the /// If this is non-zero, the contents of the material are clipped, because the
/// widget conceptually defines an independent printed piece of material. /// widget conceptually defines an independent printed piece of material.
/// ///
/// Defaults to 0. Changing this value will cause the shadow to animate over /// Defaults to 0. Changing this value will cause the shadow to animate over
/// [animationDuration]. /// [animationDuration].
///
/// The value is non-negative.
/// {@endtemplate} /// {@endtemplate}
final double elevation; final double elevation;
...@@ -609,7 +612,7 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget { ...@@ -609,7 +612,7 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget {
}) : assert(child != null), }) : assert(child != null),
assert(shape != null), assert(shape != null),
assert(clipBehavior != null), assert(clipBehavior != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
super(key: key, curve: curve, duration: duration); super(key: key, curve: curve, duration: duration);
...@@ -628,7 +631,10 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget { ...@@ -628,7 +631,10 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget {
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
final Clip clipBehavior; final Clip clipBehavior;
/// The target z-coordinate at which to place this physical object. /// The target z-coordinate at which to place this physical object relative
/// to its parent.
///
/// The value is non-negative.
final double elevation; final double elevation;
/// The target background color. /// The target background color.
......
...@@ -41,8 +41,6 @@ class MaterialButton extends StatelessWidget { ...@@ -41,8 +41,6 @@ class MaterialButton extends StatelessWidget {
/// Rather than creating a material button directly, consider using /// Rather than creating a material button directly, consider using
/// [FlatButton] or [RaisedButton]. To create a custom Material button /// [FlatButton] or [RaisedButton]. To create a custom Material button
/// consider using [RawMaterialButton]. /// consider using [RawMaterialButton].
///
/// The [clipBehavior] argument must not be null.
const MaterialButton({ const MaterialButton({
Key key, Key key,
@required this.onPressed, @required this.onPressed,
...@@ -150,10 +148,12 @@ class MaterialButton extends StatelessWidget { ...@@ -150,10 +148,12 @@ class MaterialButton extends StatelessWidget {
/// the current theme's highlight color, [ThemeData.highlightColor]. /// the current theme's highlight color, [ThemeData.highlightColor].
final Color highlightColor; final Color highlightColor;
/// The z-coordinate at which to place this button. This controls the size of /// The z-coordinate at which to place this button relative to its parent.
/// the shadow below the raised button. ///
/// This controls the size of the shadow below the raised button.
/// ///
/// Defaults to 2, the appropriate elevation for raised buttons. /// Defaults to 2, the appropriate elevation for raised buttons. The value
/// is always non-negative.
/// ///
/// See also: /// See also:
/// ///
...@@ -162,14 +162,14 @@ class MaterialButton extends StatelessWidget { ...@@ -162,14 +162,14 @@ class MaterialButton extends StatelessWidget {
/// * [highlightElevation], the elevation when the button is pressed. /// * [highlightElevation], the elevation when the button is pressed.
final double elevation; final double elevation;
/// The elevation for the button's [Material] when the button /// The elevation for the button's [Material] relative to its parent when the
/// is [enabled] and pressed. /// button is [enabled] and pressed.
/// ///
/// This controls the size of the shadow below the button. When a tap /// This controls the size of the shadow below the button. When a tap
/// down gesture occurs within the button, its [InkWell] displays a /// down gesture occurs within the button, its [InkWell] displays a
/// [highlightColor] "highlight". /// [highlightColor] "highlight".
/// ///
/// Defaults to 8.0. /// Defaults to 8.0. The value is always non-negative.
/// ///
/// See also: /// See also:
/// ///
...@@ -177,10 +177,10 @@ class MaterialButton extends StatelessWidget { ...@@ -177,10 +177,10 @@ class MaterialButton extends StatelessWidget {
/// * [disabledElevation], the elevation when the button is disabled. /// * [disabledElevation], the elevation when the button is disabled.
final double highlightElevation; final double highlightElevation;
/// The elevation for the button's [Material] when the button /// The elevation for the button's [Material] relative to its parent when the
/// is not [enabled]. /// button is not [enabled].
/// ///
/// Defaults to 0.0. /// Defaults to 0.0. The value is always non-negative.
/// ///
/// See also: /// See also:
/// ///
......
...@@ -44,7 +44,8 @@ class RaisedButton extends MaterialButton { ...@@ -44,7 +44,8 @@ class RaisedButton extends MaterialButton {
/// Create a filled button. /// Create a filled button.
/// ///
/// The [elevation], [highlightElevation], [disabledElevation], and /// The [elevation], [highlightElevation], [disabledElevation], and
/// [clipBehavior] arguments must not be null. /// [clipBehavior] arguments must not be null. Additionally, [elevation],
/// [highlightElevation], and [disabledElevation] must be non-negative.
const RaisedButton({ const RaisedButton({
Key key, Key key,
@required VoidCallback onPressed, @required VoidCallback onPressed,
......
...@@ -1504,6 +1504,7 @@ class RenderClipPath extends _RenderCustomClip<Path> { ...@@ -1504,6 +1504,7 @@ class RenderClipPath extends _RenderCustomClip<Path> {
/// determine the actual shape of the physical model. /// determine the actual shape of the physical model.
abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> { abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> {
/// The [shape], [elevation], [color], and [shadowColor] must not be null. /// The [shape], [elevation], [color], and [shadowColor] must not be null.
/// Additionally, the [elevation] must be non-negative.
_RenderPhysicalModelBase({ _RenderPhysicalModelBase({
@required RenderBox child, @required RenderBox child,
@required double elevation, @required double elevation,
...@@ -1511,7 +1512,7 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> { ...@@ -1511,7 +1512,7 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> {
@required Color shadowColor, @required Color shadowColor,
Clip clipBehavior = Clip.none, Clip clipBehavior = Clip.none,
CustomClipper<T> clipper, CustomClipper<T> clipper,
}) : assert(elevation != null), }) : assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
assert(clipBehavior != null), assert(clipBehavior != null),
...@@ -1520,14 +1521,16 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> { ...@@ -1520,14 +1521,16 @@ abstract class _RenderPhysicalModelBase<T> extends _RenderCustomClip<T> {
_shadowColor = shadowColor, _shadowColor = shadowColor,
super(child: child, clipBehavior: clipBehavior, clipper: clipper); super(child: child, clipBehavior: clipBehavior, clipper: clipper);
/// The z-coordinate at which to place this material. /// The z-coordinate relative to the parent at which to place this material.
///
/// The value is non-negative.
/// ///
/// If [debugDisableShadows] is set, this value is ignored and no shadow is /// If [debugDisableShadows] is set, this value is ignored and no shadow is
/// drawn (an outline is rendered instead). /// drawn (an outline is rendered instead).
double get elevation => _elevation; double get elevation => _elevation;
double _elevation; double _elevation;
set elevation(double value) { set elevation(double value) {
assert(value != null); assert(value != null && value >= 0.0);
if (elevation == value) if (elevation == value)
return; return;
final bool didNeedCompositing = alwaysNeedsCompositing; final bool didNeedCompositing = alwaysNeedsCompositing;
...@@ -1585,6 +1588,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> { ...@@ -1585,6 +1588,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> {
/// The [color] is required. /// The [color] is required.
/// ///
/// The [shape], [elevation], [color], and [shadowColor] must not be null. /// The [shape], [elevation], [color], and [shadowColor] must not be null.
/// Additionally, the [elevation] must be non-negative.
RenderPhysicalModel({ RenderPhysicalModel({
RenderBox child, RenderBox child,
BoxShape shape = BoxShape.rectangle, BoxShape shape = BoxShape.rectangle,
...@@ -1595,7 +1599,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> { ...@@ -1595,7 +1599,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase<RRect> {
Color shadowColor = const Color(0xFF000000), Color shadowColor = const Color(0xFF000000),
}) : assert(shape != null), }) : assert(shape != null),
assert(clipBehavior != null), assert(clipBehavior != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
_shape = shape, _shape = shape,
...@@ -1742,8 +1746,8 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> { ...@@ -1742,8 +1746,8 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> {
/// ///
/// The [color] and [shape] parameters are required. /// The [color] and [shape] parameters are required.
/// ///
/// The [clipper], [elevation], [color] and [shadowColor] must /// The [clipper], [elevation], [color] and [shadowColor] must not be null.
/// not be null. /// Additionally, the [elevation] must be non-negative.
RenderPhysicalShape({ RenderPhysicalShape({
RenderBox child, RenderBox child,
@required CustomClipper<Path> clipper, @required CustomClipper<Path> clipper,
...@@ -1752,7 +1756,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> { ...@@ -1752,7 +1756,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase<Path> {
@required Color color, @required Color color,
Color shadowColor = const Color(0xFF000000), Color shadowColor = const Color(0xFF000000),
}) : assert(clipper != null), }) : assert(clipper != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
super( super(
......
...@@ -748,6 +748,7 @@ class PhysicalModel extends SingleChildRenderObjectWidget { ...@@ -748,6 +748,7 @@ class PhysicalModel extends SingleChildRenderObjectWidget {
/// The [color] is required; physical things have a color. /// The [color] is required; physical things have a color.
/// ///
/// The [shape], [elevation], [color], and [shadowColor] must not be null. /// The [shape], [elevation], [color], and [shadowColor] must not be null.
/// Additionally, the [elevation] must be non-negative.
const PhysicalModel({ const PhysicalModel({
Key key, Key key,
this.shape = BoxShape.rectangle, this.shape = BoxShape.rectangle,
...@@ -758,7 +759,7 @@ class PhysicalModel extends SingleChildRenderObjectWidget { ...@@ -758,7 +759,7 @@ class PhysicalModel extends SingleChildRenderObjectWidget {
this.shadowColor = const Color(0xFF000000), this.shadowColor = const Color(0xFF000000),
Widget child, Widget child,
}) : assert(shape != null), }) : assert(shape != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
super(key: key, child: child); super(key: key, child: child);
...@@ -777,7 +778,10 @@ class PhysicalModel extends SingleChildRenderObjectWidget { ...@@ -777,7 +778,10 @@ class PhysicalModel extends SingleChildRenderObjectWidget {
/// This is ignored if the [shape] is not [BoxShape.rectangle]. /// This is ignored if the [shape] is not [BoxShape.rectangle].
final BorderRadius borderRadius; final BorderRadius borderRadius;
/// The z-coordinate at which to place this physical object. /// The z-coordinate relative to the parent at which to place this physical
/// object.
///
/// The value is non-negative.
final double elevation; final double elevation;
/// The background color. /// The background color.
...@@ -836,6 +840,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget { ...@@ -836,6 +840,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget {
/// The [color] is required; physical things have a color. /// The [color] is required; physical things have a color.
/// ///
/// The [clipper], [elevation], [color], and [shadowColor] must not be null. /// The [clipper], [elevation], [color], and [shadowColor] must not be null.
/// Additionally, the [elevation] must be non-negative.
const PhysicalShape({ const PhysicalShape({
Key key, Key key,
@required this.clipper, @required this.clipper,
...@@ -846,7 +851,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget { ...@@ -846,7 +851,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget {
Widget child, Widget child,
}) : assert(clipper != null), }) : assert(clipper != null),
assert(clipBehavior != null), assert(clipBehavior != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
super(key: key, child: child); super(key: key, child: child);
...@@ -861,7 +866,10 @@ class PhysicalShape extends SingleChildRenderObjectWidget { ...@@ -861,7 +866,10 @@ class PhysicalShape extends SingleChildRenderObjectWidget {
/// {@macro flutter.widgets.Clip} /// {@macro flutter.widgets.Clip}
final Clip clipBehavior; final Clip clipBehavior;
/// The z-coordinate at which to place this physical object. /// The z-coordinate relative to the parent at which to place this physical
/// object.
///
/// The value is non-negative.
final double elevation; final double elevation;
/// The background color. /// The background color.
......
...@@ -1240,7 +1240,8 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget { ...@@ -1240,7 +1240,8 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget {
/// Creates a widget that animates the properties of a [PhysicalModel]. /// Creates a widget that animates the properties of a [PhysicalModel].
/// ///
/// The [child], [shape], [borderRadius], [elevation], [color], [shadowColor], [curve], and /// The [child], [shape], [borderRadius], [elevation], [color], [shadowColor], [curve], and
/// [duration] arguments must not be null. /// [duration] arguments must not be null. Additionally, [elevation] must be
/// non-negative.
/// ///
/// Animating [color] is optional and is controlled by the [animateColor] flag. /// Animating [color] is optional and is controlled by the [animateColor] flag.
/// ///
...@@ -1262,7 +1263,7 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget { ...@@ -1262,7 +1263,7 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget {
assert(shape != null), assert(shape != null),
assert(clipBehavior != null), assert(clipBehavior != null),
assert(borderRadius != null), assert(borderRadius != null),
assert(elevation != null), assert(elevation != null && elevation >= 0.0),
assert(color != null), assert(color != null),
assert(shadowColor != null), assert(shadowColor != null),
assert(animateColor != null), assert(animateColor != null),
...@@ -1285,7 +1286,10 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget { ...@@ -1285,7 +1286,10 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget {
/// The target border radius of the rounded corners for a rectangle shape. /// The target border radius of the rounded corners for a rectangle shape.
final BorderRadius borderRadius; final BorderRadius borderRadius;
/// The target z-coordinate at which to place this physical object. /// The target z-coordinate relative to the parent at which to place this
/// physical object.
///
/// The value will always be non-negative.
final double elevation; final double elevation;
/// The target background color. /// The target background color.
......
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