Repository: flutter
Issue: [Docs] CustomPainter returns Size(0,0), but `MediaQuery.of(context).size` returns correct value
Labels: framework,d: api docs,a: quality,c: proposal,P2,team-framework,triaged-framework

Code
```dart
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData.dark(),
      home: Scaffold(
        body: Builder(builder: (context) {
          return CustomPaint(
            painter: GradientImageBackgroundPainter(
                actualSize: MediaQuery.of(context).size),
          );
        }),
      ),
    ),
  );
}

class GradientImageBackgroundPainter extends CustomPainter {
  const GradientImageBackgroundPainter({
    required this.actualSize,
  });

  final Size actualSize;

  @override
  void paint(Canvas canvas, Size size) {
    print(size);
    print(actualSize);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}
```

Log
```
flutter: Size(739.2, 684.8)
flutter: Size(0.0, 0.0)
flutter: Size(722.8, 684.8)
flutter: Size(0.0, 0.0)
flutter: Size(712.4, 684.8)
flutter: Size(0.0, 0.0)
flutter: Size(710.0, 684.8)
flutter: Size(0.0, 0.0)
flutter: Size(707.2, 684.8)
flutter: Size(0.0, 0.0)
flutter: Size(704.8, 684.8)
flutter: Size(0.0, 0.0)
flutter: Size(704.4, 684.8)
```

Doctor
```
[✓] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.22000.282], locale en-US)
    • Flutter version 2.5.3 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (2 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Agone\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.5)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.31729.503
    • Windows 10 SDK version 10.0.19041.0

[✓] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.2
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.61.2)
    • VS Code at C:\Users\Agone\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.27.0

[✓] VS Code (version 1.62.0-insider)
    • VS Code at C:\Users\Agone\AppData\Local\Programs\Microsoft VS Code Insiders
    • Flutter extension version 3.27.0

[✓] Connected device (1 available)
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.282]

• No issues found!
```