-
-
Save Eshpelin/5528777b5f8192f62fa41bef20556a06 to your computer and use it in GitHub Desktop.
JSON Serialization Issue: The argument type 'Tracks' can't be assigned to the parameter type 'Map<String, dynamic>'
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'; | |
import 'package:flutter_gmail_redesign/titles.dart'; | |
//import 'package:flutter_gmail_redesign/widget/header.dart'; | |
//import 'package:flutter_gmail_redesign/widget/mails.dart'; | |
void main() { | |
runApp(MaterialApp( | |
theme: ThemeData.dark(), | |
debugShowCheckedModeBanner: false, | |
home: TrackList(), | |
)); | |
} |
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 PrimaryMail extends StatelessWidget { | |
final IconData iconData; | |
final String title; | |
// final String msg; | |
final String count; | |
final Color colors; | |
PrimaryMail( | |
{@required this.iconData, | |
@required this.title, | |
// @required this.msg, | |
@required this.count, | |
@required this.colors}); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
margin: EdgeInsets.fromLTRB(30, 16, 16, 16), | |
child: Row( | |
mainAxisSize: MainAxisSize.max, | |
children: <Widget>[ | |
Icon( | |
this.iconData, | |
color: this.colors, | |
), | |
Expanded( | |
child: Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 20), | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Text( | |
this.title, | |
style: TextStyle( | |
color: Colors.black, | |
fontSize: 17, | |
fontFamily: 'GoogleMedium'), | |
), | |
// Text( | |
// this.msg, | |
// style: TextStyle( | |
// color: Colors.black87, | |
// fontSize: 15, | |
// fontFamily: 'GoogleRegular'), | |
// ), | |
], | |
), | |
), | |
), | |
Container( | |
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 5), | |
child: Text( | |
this.count, | |
textAlign: TextAlign.center, | |
style: TextStyle(fontSize: 12, fontFamily: 'GoogleMedium'), | |
), | |
decoration: BoxDecoration( | |
color: this.colors, | |
shape: BoxShape.rectangle, | |
borderRadius: BorderRadius.circular(20)), | |
) | |
], | |
), | |
); | |
} | |
} |
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 'dart:async'; | |
import 'dart:convert'; | |
import 'package:flutter/material.dart'; | |
import 'package:community_material_icon/community_material_icon.dart'; | |
import 'package:flutter/services.dart'; | |
import 'package:flutter_gmail_redesign/Tracks.dart'; | |
//import 'package:flutter_gmail_redesign/widget/header.dart'; | |
//import 'package:flutter_gmail_redesign/widget/mails.dart'; | |
import 'package:flutter_gmail_redesign/widget/primary_mail.dart'; | |
import 'package:outline_material_icons/outline_material_icons.dart'; | |
import 'dart:math'; | |
class TrackList extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() => _TrackListState(); | |
} | |
class _TrackListState extends State<TrackList> { | |
var tracks = const []; | |
Future loadTrackList() async { | |
String content = await rootBundle.loadString('data/titles.json'); | |
List<Tracks> collection = json.decode(content); | |
List<Tracks> _tracks = collection.map((json) => Tracks.fromJson(json)).toList(); | |
setState(() { | |
tracks = _tracks; | |
}); | |
} | |
void initState() { | |
loadTrackList(); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) => Scaffold( | |
backgroundColor: Colors.white, | |
floatingActionButton: FloatingActionButton( | |
backgroundColor: Colors.white, | |
onPressed: () {}, | |
child: Icon( | |
CommunityMaterialIcons.plus, | |
color: Colors.black, | |
), | |
), | |
body: ListView.builder( | |
itemCount: tracks.length, | |
itemBuilder: (BuildContext context, int index) { | |
var rnd = new Random(); | |
var totalUsers = rnd.nextInt(600); | |
Tracks trackTitles = tracks[index]; | |
return PrimaryMail( | |
iconData: OMIcons.supervisorAccount, | |
title: trackTitles.title, | |
// msg: 'Subtitle Went Here, originally msg on PrimaryMail.dart', | |
count: "$totalUsers active", | |
colors: Colors.lightBlueAccent, | |
); | |
}, | |
), | |
); | |
} |
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
[{ | |
"title": "BCS Examination", | |
"subtitle": "Something" | |
}, | |
{ | |
"title": "Dhaka University Admission" | |
}, | |
{ | |
"title": "Khulna University Admission" | |
}, | |
{ | |
"title": "Chottogram University Admission" | |
}, | |
{ | |
"title": "Potato Job Exam" | |
}, | |
{ | |
"title": "Private Job Exam" | |
} | |
] |
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
class Tracks{ | |
final String title; | |
final String subtitle; | |
Tracks(this.title, this.subtitle); | |
Tracks.fromJson(Map<String, dynamic> json) : | |
title = json['title'], | |
subtitle = json['subtitle']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment