Skip to content

Instantly share code, notes, and snippets.

@DanielRomanMartinez
Created September 23, 2021 11:07
Show Gist options
  • Save DanielRomanMartinez/9c83f86c79bc0a53d7814235562835f0 to your computer and use it in GitHub Desktop.
Save DanielRomanMartinez/9c83f86c79bc0a53d7814235562835f0 to your computer and use it in GitHub Desktop.
Horitzontal List View
import 'package:flutter/material.dart';
class MyRestaurants extends StatelessWidget {
final List<String> list = [
'Todos',
'Restaurantes',
'Cafeterias',
'Cervezerias',
'Bares',
'Bibliotecas',
'Pescaderias',
'Gasolineras'
];
MyRestaurants({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SafeArea(
child: Container(
height: 50,
child: ListView.builder(
controller: ScrollController(),
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.all(5),
itemCount: list.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: RaisedButton(
color: Colors.red,
onPressed: () => print(list[index]),
child: Text(list[index]),
shape: const StadiumBorder(),
),
);
},
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment