"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/dev/benchmarks/macrobenchmarks/lib/src/heavy_grid_view.dart" (13 Nov 2020, 897 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 import 'package:flutter/material.dart';
    6 
    7 class HeavyGridViewPage extends StatelessWidget {
    8   @override
    9   Widget build(BuildContext context) {
   10     return GridView.builder(
   11       itemCount: 1000,
   12       gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
   13       itemBuilder: (BuildContext context, int index) => HeavyWidget(index),
   14     ).build(context);
   15   }
   16 }
   17 
   18 class HeavyWidget extends StatelessWidget {
   19   HeavyWidget(this.index) : super(key: ValueKey<int>(index));
   20 
   21   final int index;
   22   final List<int> _weight = List<int>(1000000);
   23 
   24   @override
   25   Widget build(BuildContext context) {
   26     return SizedBox(
   27       width: 200,
   28       height: 200,
   29       child: Text('$index: ${_weight.length}'),
   30     );
   31   }
   32 }