Created
December 22, 2019 07:12
-
-
Save ysknsn/d4d3305f86ac5a234d699d75fc47e5d9 to your computer and use it in GitHub Desktop.
MapEntry Demo
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'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
final List<MapEntry> colors = [ | |
MapEntry("yellow", Colors.yellow), | |
MapEntry("blue", Colors.blue), | |
MapEntry("red", Colors.red), | |
MapEntry("green", Colors.green), | |
MapEntry("purple", Colors.purple), | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: ListView( | |
children: <Widget>[ | |
Padding( | |
padding: EdgeInsets.all(20.0), | |
child: Text("Colors"), | |
), | |
Column( | |
children: colors.map((color) { | |
return Container( | |
color: color.value, | |
child: ListTile( | |
contentPadding: EdgeInsets.all(20), | |
title: Text(color.key), | |
), | |
); | |
}).toList(), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment