Skip to content

Instantly share code, notes, and snippets.

@bastaware
Last active October 8, 2020 20:37
Show Gist options
  • Save bastaware/ac436b786ae48383c107a64bb3db8070 to your computer and use it in GitHub Desktop.
Save bastaware/ac436b786ae48383c107a64bb3db8070 to your computer and use it in GitHub Desktop.
ListView as main widget
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: 20,
itemBuilder: (context, index) {
var text = 'Card $index';
print('Building card $text');
return Card(
child: Container(
height: 130,
child: Center(
child: Text(text),
)));
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment