Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/cupertino.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatefulWidget {
- @override
- _MyAppState createState() => _MyAppState();
- }
- class _MyAppState extends State<MyApp> {
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Main(),
- );
- }
- }
- class Main extends StatefulWidget {
- @override
- _MainState createState() => _MainState();
- }
- class Name{
- String firstName;
- String lastName;
- Name({this.firstName, this.lastName});
- }
- class _MainState extends State<Main> {
- List<Name> names = List<Name>();
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- names = [
- Name(firstName: "Lamar", lastName: "Marshall"),
- Name(firstName: "Roxy", lastName: "Hiroshima"),
- ];
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: SafeArea(child: Center(
- child: DataTable(
- columns: [
- DataColumn(
- label: Text("first name"),
- numeric: false,
- tooltip: "First name"
- ),
- DataColumn(
- label: Text("Last Name"),
- numeric: false,
- tooltip: "Last Name"
- )
- ],
- rows: names.map((f) => DataRow(cells: [
- DataCell(Text(f.firstName)),
- DataCell(Text(f.lastName))
- ])).toList()
- )
- ),
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement