Reputation: 73
I'm trying to write basic Listview example, however not able to scroll down, screen is fixed not able to view all items.
Tried with working example from flutter official documentation (displaying Listview till items29) https://api.flutter.dev/flutter/widgets/ListView-class.html
Not able to figure out Whether it is settings issue or other.
import 'package:flutter/material.dart';
class mySquare extends StatelessWidget {
String child;
mySquare({required this.child});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(height: 200, color: Colors.amber, child: Text(child)),
);
}
}
class HomePage extends StatelessWidget {
List posts = ['post1', 'post2', 'post3', 'post4', 'post5', 'post6'];
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
itemCount: posts.length,
itemBuilder: ((BuildContext context, index) {
return mySquare(
child: posts[index],
);
}),
),
);
}
}
Upvotes: 0
Views: 46
Reputation: 1583
I launched your code on Android emulator and it works as expected.
If the device is big enough for all items ListView
wouldn't scroll
Upvotes: 1