Skip to content

Instantly share code, notes, and snippets.

@solsticedhiver
Created April 1, 2023 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solsticedhiver/80ea3b8eb29df7340f48efb3933d51c4 to your computer and use it in GitHub Desktop.
Save solsticedhiver/80ea3b8eb29df7340f48efb3933d51c4 to your computer and use it in GitHub Desktop.
fascinating-cliff-5126

fascinating-cliff-5126

Created with <3 with dartpad.dev.

import 'package:flutter/material.dart';
/*
* Tap/click the floating action button to scroll the horizontal ListView, and hover the first ListTile.
* It is hilghlighted, but the highlighted portion is shown hover/under the left vertical ListView.
*/
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Bug'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<int> theIntegers = List.generate(30, (index) => index);
List<int> theShuffled = [];
final ScrollController _controller = ScrollController();
@override
void initState() {
super.initState();
theShuffled.addAll(theIntegers);
theShuffled.shuffle();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Row(mainAxisSize: MainAxisSize.min, children: [
Container(
width: 150,
child: ListView.builder(
itemCount: theIntegers.length,
itemBuilder: (context, index) {
return ListTile(title: Text(theIntegers[index].toString()));
})),
Container(
height: MediaQuery.of(context).size.height / 2,
width: MediaQuery.of(context).size.width - 160,
child: ListView.builder(
controller: _controller,
scrollDirection: Axis.horizontal,
itemCount: theShuffled.length,
itemBuilder: (context, index) {
return Container(
height: 150,
width: 300,
child: InkWell(
onTap: () {},
child: Card(
child: Center(
child: ListTile(
title: Text(theShuffled[index].toString()),
)))));
})),
])),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.arrow_right),
onPressed: () {
_controller.animateTo(
150,
duration: const Duration(milliseconds: 500),
curve: Curves.bounceIn,
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment