Last active
December 16, 2021 20:05
-
-
Save Jahidul007/688047457a1dd8c0c44e4c42c48a8a24 to your computer and use it in GitHub Desktop.
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'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatefulWidget { | |
@override | |
State<MyApp> createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
List<String> dataToShow = ['title', 'open', 'high', 'low', 'last', 'volume']; | |
List<DataModel> data = []; | |
@override | |
void initState() { | |
super.initState(); | |
for (var item in dataToShow) { | |
data.add(DataModel(item)); | |
} | |
} | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: darkBlue, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: ListView.builder( | |
shrinkWrap: true, | |
itemCount: data.length, | |
itemBuilder: (ctx, index) { | |
return GridTile( | |
child: Text(data[index].getPropertyValue(dataToShow[0]))); | |
}, | |
), | |
), | |
); | |
} | |
} | |
class DataModel { | |
String title; | |
DataModel(this.title); | |
String getPropertyValue(String propertyName) { | |
return propertyName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment