main.dart
import 'package:flutter/material.dart';
void main() => runApp(const FlutterExample());
class FlutterExample extends StatelessWidget {
const FlutterExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Example',
theme: ThemeData(primarySwatch: Colors.amber),
home: const StateExample()
);
}
}
class StateExample extends StatefulWidget {
const StateExample({Key? key}) : super(key: key);
@override
_StateExampleState createState() => _StateExampleState();
}
class _StateExampleState extends State<StateExample>{
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFFEFEFA),
appBar: AppBar(
title: const Text("Flutter - ListView Horizontal Height")
),
body: bodyContent(),
);
}
bodyContent() {
return Container(
height: 100,
margin: const EdgeInsets.symmetric(vertical: 20),
child: ListView.builder(
itemCount: 100,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Container(
child: Text(
"${index + 1}",
style: const TextStyle(
fontSize: 30,
),
),
color: const Color(0xFFDA1884),
margin: const EdgeInsets.symmetric(horizontal: 2.0),
alignment: Alignment.center,
width: 100,
);
},
)
);
}
}
More flutter tutorials
- flutter – How to use TextField
- flutter – Button padding
- flutter – TextField border
- flutter – TextField border size
- flutter – TextField border shadow
- flutter – SnackBar example
- flutter – SnackBar duration
- flutter – SnackBar behavior
- flutter – SnackBar shape
- flutter – Image network
- flutter – ListView example
- flutter – ListView card
- flutter – ListView icon
- flutter – ListView item click listener
- flutter – ListView IconButton