Skip to content

List/Grids that can't actually scroll should warn that repaint boundaries are being added, or just avoid adding them. #103068

@dnfield

Description

@dnfield

Internal: b/292548368

The app at the bottom of this issue adds repaint boundaries by default for the grid view, even though it is not scrollable by itself and is shrink wrapped. This means that some of the entries will be chosen as raster cache entries, but in reality the whole thing could/should be raster cached.

The default behavior of adding repatint boundaries makes sense for grid views that actually scroll. It does not make sense when the grid view is just being used as a static layout mechanism (effectively a set of rows and columns). We should warn developers about this case and encourage them to turn off repaint boundaries for this case.

/cc @flar @jonahwilliams @goderbauer

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SizedBox(
          width: 350,
          child: ListView(
            children: <Widget>[
              Container(
                color: Colors.red,
                height: 45,
                width: 350,
                child: const Text('Header!'),
              ),
              const Divider(),
              Container(
                color: Colors.blue,
                height: 240,
                width: 350,
                child: const Text('Foo!'),
              ),
              const Divider(),
              GridView.count(
                crossAxisCount: 4,
                crossAxisSpacing: 20,
                mainAxisSpacing: 20,
                shrinkWrap: true,
                children: const <Widget>[
                  CircleAvatar(child: Text('AB')),
                  CircleAvatar(child: Text('CD')),
                  CircleAvatar(child: Text('EF')),
                  CircleAvatar(child: Text('GH')),
                  CircleAvatar(child: Text('BA')),
                  CircleAvatar(child: Text('DC')),
                  CircleAvatar(child: Text('FE')),
                  CircleAvatar(child: Text('HG')),
                ],
              ),
              const Divider(),
              Container(
                color: Colors.yellow,
                height: 140,
                width: 350,
                child: const Text('Bar!'),
              ),
              Container(
                color: Colors.green,
                height: 45,
                width: 350,
                child: const Text('Footer!'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listcustomer: money (g3)f: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions