Repository: flutter
Issue: Flutter can not render calendar widgets in a single frame at 60fps
Labels: platform-android,framework,c: performance,f: date/time picker,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,team-android,triaged-android

## Details

I was trying to build a calendar app and I found that flutter can not build calendars in appropriate time (under 16ms) and using multiple calendar widgets in one page causing jank. The widget that I'm trying to build is a page that shows a complete year view. It's a common design in calendar apps such as Samsung calendar:

![Screenshot_20190817-134811_Calendar](https://user-images.githubusercontent.com/10382216/63209643-cae5f000-c0f8-11e9-9bf3-2e21c38bb4dc.jpg)

Here is a simple code and also I didn't include the logic. Every calendar widget is a simple combination of `Column`s and `Row`s.

```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: TestScreen(),
    );
  }
}

class TestScreen extends StatelessWidget {
  TestScreen() : controller = PageController(initialPage: 1000);

  final PageController controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Demo'),
      ),
      body: PageView.builder(
        controller: controller,
        itemBuilder: (context, index) => YearWidget(),
      )
    );
  }
  
}

class YearWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GridView.builder(
      itemCount: 12,
      addAutomaticKeepAlives: true,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
      ),
      itemBuilder: (BuildContext context, int index) => CalendarWidget()
    );
  }

}

class CalendarWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<Widget> rows = <Widget>[];
    for (var i = 0; i < 5; i++) {
      rows.add(
        Row(
          children: List<Widget>.generate(7, 
            (int j) => Expanded(
              child: Text((i * 7 + j + 1).toString(),
              textAlign: TextAlign.center,),)),
        )
      );
    }
    return Container(
      padding: EdgeInsets.all(10),
      child: Column(
        children: rows,
      ),
    );
  }

}
```

As you can see the code is not very complicated and the performance overlay is like this. Some of frames takes over 100ms to build: 

![Screenshot_20190817-134744](https://user-images.githubusercontent.com/10382216/63209658-f23cbd00-c0f8-11e9-9010-e7f93de0ceaa.jpg)

Also it's interesting that also flutter date picker has a similar issue and can not render frames under 16ms: 

![Screenshot_20190817-140635](https://user-images.githubusercontent.com/10382216/63209680-53fd2700-c0f9-11e9-8bed-ae0b27517307.jpg)


## Logs

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing flutter_performance_issue...
No issues found! (ran in 20.8s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here, with your device plugged in. -->

```
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Microsoft Windows [Version
    10.0.18362.10013], locale en-US)
    • Flutter version 1.7.8+hotfix.4 at C:\tools\flutter-sdk
    • Framework revision 20e59316b8 (4 weeks ago), 2019-07-18 20:04:33 -0700    
    • Engine revision fee001c93f
    • Dart version 2.4.0

 
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)    • Android SDK at C:\dev\Android\SDK\android-sdk-essential
    • Android NDK location not configured (optional; useful for native profiling      support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = C:\dev\Android\SDK\android-sdk-essential
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java      
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.4)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 35.3.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build
      1.8.0_152-release-1343-b01)

[!] IntelliJ IDEA Ultimate Edition (version 2018.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.5
    X Flutter plugin not installed; this adds Flutter specific functionality.   
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[√] VS Code (version 1.37.1)
    • VS Code at C:\Users\mahdi\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 2.22.3

[√] VS Code, 64-bit edition (version 1.34.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.22.3

[√] Connected device (1 available)
    • SM G950F • 988a1b315143304a34 • android-arm64 • Android 9 (API 28)        

! Doctor found issues in 1 category.
```