Last active
August 1, 2021 23:58
-
-
Save monkeyswarm/7654454e52e48b51240c5aac09d84c82 to your computer and use it in GitHub Desktop.
Track containers 4: nested list views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check that hitting the start/end of a child listview passes the scroll to the parent listview. | |
// Works as intended on laptop/dartpad with two-finger scroll on trackpad, but not with point and drag | |
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
Widget _buildContainer(Color color, Color borderColor) => Container( | |
height: 300.0, | |
decoration: BoxDecoration( | |
color: color, border: Border.all(color: borderColor, width: 8)), | |
child: ListView( | |
children: List.generate( | |
25, (i) => Container(height: 30.0, child: Text('foo $i'))))); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Fun with nested list view'), | |
), | |
body: Column(children: [ | |
Container( | |
color: Color(0x88888888), | |
height: 600, | |
child: ListView(children: [ | |
_buildContainer(Color(0x88FF0000), Color(0xFFFF0000)), | |
_buildContainer(Color(0x8800FF00), Color(0xFF00FF00)), | |
_buildContainer(Color(0x880000FF), Color(0xFF0000FF)), | |
])) | |
])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment