Created
September 23, 2021 11:07
-
-
Save DanielRomanMartinez/9c83f86c79bc0a53d7814235562835f0 to your computer and use it in GitHub Desktop.
Horitzontal List View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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