title: How do we pass the size to CustomPaint?
body: <p>Column's child's CustomPainter's size become (0, 0).</p>
  
  <p>1) When we just used CustomPaint and CustomPainter, the size we expected was passed to CustomPainter, which is rendered as expected.</p>
  
  <p>2) When we used CustomPaint and CustomPainter as Stack's children, the size we expected was not passed to CustomPainter.</p>
  
  <p>3) But when we used it as SizedBox.expand's children, the size we expected was passed to CustomPainter and it was rendered.</p>
  
  <p>4) When we used CustomPaint and CustomPainter as Column's children, the size we expected was not passed to CustomPainter. We are investigating ways to solve it.</p>
  
  <p>5) However, it is either 0.0 or infinite in height. We want it to just expand to a good size.</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class TestWidget extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
      // 1) OK Size(360.0, 640.0)
      // return CustomPaint(
      //   painter: TestPainter(),
      // );
  
      // 2) NG Size(0.0, 0.0)
      // return Stack(
      //   children: &lt;Widget&gt;[
      //     CustomPaint(
      //       painter: TestPainter(),
      //     ),
      //   ],
      // );
  
      // 3) OK Size(360.0, 640.0)
      // return Stack(
      //   children: &lt;Widget&gt;[
      //     SizedBox.expand(
      //       child: CustomPaint(
      //         painter: TestPainter(),
      //       ),
      //     ),
      //   ],
      // );
  
      // 4)5) NG BoxConstraints forces an infinite height.
      // return Column(
      //   children: &lt;Widget&gt;[
      //     SizedBox.expand(
      //       child: CustomPaint(
      //         painter: TestPainter(),
      //       ),
      //     ),
      //     Text('test'),
      //   ],
      // );
  
      // 4)5) NG Size(0.0, 0.0)
      // return Column(
      //   children: &lt;Widget&gt;[
      //     SizedBox(
      //       child: CustomPaint(
      //         painter: TestPainter(),
      //       ),
      //     ),
      //     Text('test'),
      //   ],
      // );
  
      // 4)5) Size(360.0, 0.0)
      // return Column(
      //   children: &lt;Widget&gt;[
      //     SizedBox(
      //       width: double.infinity,
      //       child: CustomPaint(
      //         painter: TestPainter(),
      //       ),
      //     ),
      //     Text('test'),
      //   ],
      // );
      }
  }
  
  class TestPainter extends CustomPainter {
      @override
      void paint(Canvas canvas, Size size) {
      print(size);
      Paint p = Paint();
      p.color = Color.fromARGB(0xff, 0xff, 0x00, 0x00);
      Rect rect = Rect.fromLTWH(0, 0, size.width, size.height);
      canvas.drawRect(rect, p);
      }
  
      @override
      bool shouldRepaint(CustomPainter oldDelegate) {
      return true;
      }
  }
  </code></pre>
  
  <p>We expect CustomPaint and CustomPainter to be expanded to the appropriate size and that size will be passed to CustomPainter.</p>