Skip to content

Instantly share code, notes, and snippets.

@ysknsn
Created December 22, 2019 07:12
Show Gist options
  • Save ysknsn/d4d3305f86ac5a234d699d75fc47e5d9 to your computer and use it in GitHub Desktop.
Save ysknsn/d4d3305f86ac5a234d699d75fc47e5d9 to your computer and use it in GitHub Desktop.
MapEntry Demo
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