transitions.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:flutter/widgets.dart';
  2. import 'package:flutter/foundation.dart';
  3. import '../rendering/transitions.dart';
  4. class SizeTransitionWithIntrinsicSize extends SingleChildRenderObjectWidget {
  5. /// Creates a size transition with its intrinsic width/height taking [sizeFactor] into account.
  6. ///
  7. /// The [axis], [sizeFactor], and [axisAlignment] arguments must not be null.
  8. /// The [axis] argument defaults to [Axis.vertical]. The [axisAlignment]
  9. /// defaults to 0.0, which centers the child along the main axis during the
  10. /// transition.
  11. SizeTransitionWithIntrinsicSize({
  12. this.axis = Axis.vertical,
  13. required this.sizeFactor,
  14. double axisAlignment = 0.0,
  15. Widget? child,
  16. Key? key,
  17. }) : super(
  18. key: key,
  19. child: SizeTransition(
  20. axis: axis,
  21. sizeFactor: sizeFactor,
  22. axisAlignment: axisAlignment,
  23. child: child,
  24. ));
  25. final Axis axis;
  26. final Animation<double> sizeFactor;
  27. @override
  28. RenderSizeTransitionWithIntrinsicSize createRenderObject(
  29. BuildContext context) {
  30. return RenderSizeTransitionWithIntrinsicSize(
  31. axis: axis,
  32. sizeFactor: sizeFactor,
  33. );
  34. }
  35. @override
  36. void updateRenderObject(BuildContext context,
  37. RenderSizeTransitionWithIntrinsicSize renderObject) {
  38. renderObject
  39. ..axis = axis
  40. ..sizeFactor = sizeFactor;
  41. }
  42. @override
  43. void debugFillProperties(DiagnosticPropertiesBuilder properties) {
  44. super.debugFillProperties(properties);
  45. properties.add(DiagnosticsProperty<Axis>('axis', axis));
  46. properties
  47. .add(DiagnosticsProperty<Animation<double>>('sizeFactor', sizeFactor));
  48. }
  49. }