letsar / flutter_staggered_grid_view

A Flutter staggered grid view
MIT License
3.12k stars 508 forks source link

What is the Tile widget in the example? #317

Open wyxcoder opened 1 year ago

wyxcoder commented 1 year ago

I cannot locate the widget Title?

alexrabin commented 11 months ago

@wyxcoder

https://github.com/letsar/flutter_staggered_grid_view/blob/0bfd05f285a6ecf390a8927e6ad4e67f7a39979b/examples/lib/common.dart#L31C1-L75C2


class Tile extends StatelessWidget {
  const Tile({
    Key? key,
    required this.index,
    this.extent,
    this.backgroundColor,
    this.bottomSpace,
  }) : super(key: key);

  final int index;
  final double? extent;
  final double? bottomSpace;
  final Color? backgroundColor;

  @override
  Widget build(BuildContext context) {
    final child = Container(
      color: backgroundColor,
      height: extent,
      child: Center(
        child: CircleAvatar(
          minRadius: 20,
          maxRadius: 20,
          backgroundColor: Colors.white,
          foregroundColor: Colors.black,
          child: Text('$index', style: const TextStyle(fontSize: 20)),
        ),
      ),
    );

    if (bottomSpace == null) {
      return child;
    }

    return Column(
      children: [
        Expanded(child: child),
        Container(
          height: bottomSpace,
          color: Colors.green,
        )
      ],
    );
  }
}