Skip to content

Instantly share code, notes, and snippets.

@joramkimata
Created January 25, 2020 21:49
Show Gist options
  • Save joramkimata/35446799122eab1472d812f2af863cc7 to your computer and use it in GitHub Desktop.
Save joramkimata/35446799122eab1472d812f2af863cc7 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:infinite_listview/infinite_listview.dart';
main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MyApp();
}
}
class _MyApp extends State<MyApp> {
// 1 Step: InfiniteScollController
final InfiniteScrollController _infiniteController = InfiniteScrollController(
initialScrollOffset: 0.0,
);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("InfiniteApp"),
),
body: Container(
child: InfiniteListView.separated(
controller: _infiniteController,
itemBuilder: (BuildContext context, int index) {
return Material(
child: InkWell(
onTap: () {},
child: ListTile(
title: Text('Item #$index'),
subtitle: Text('Subtitle $index'),
trailing: const Icon(Icons.chevron_right),
),
),
);
},
separatorBuilder: (BuildContext context, int index) =>
const Divider(height: 2.0),
anchor: 0.5,
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment