Skip to content

Rotating a ListView around X causes it to dissapear #30819

@goderbauer

Description

@goderbauer
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    ScrollController c;
    return Transform(
      transform: Matrix4.identity()
        ..setEntry(3, 2, 0.001)
        ..rotateX(0.01 * 10), // <-- this causes the ListView to disappear
      child: Scaffold(
        body: Center(
          child: Container(
            width: 200,
            child: ListView.builder(
              controller: c = ScrollController()..addListener(() {
                print(c.offset);
              }),
              itemBuilder: (BuildContext context, int index) {
                return Container(
                  height: 100.0,
                  color: index % 2 == 0 ? Colors.blue : Colors.red,
                  child: Text('Tile $index'),
                );
              },
            ),
          ),
        ),
      ),
    );
  }
}

If the line with the comment that does the rotation is removed everything shows up as expected. The scroll view itself is still "there", if you scroll the area where it is supposed to be the new scroll position gets printed to the console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions