3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/ XXXXXXXXXX/5 Lab 9 Due Tuesday by 11:59pm Points 10 Submitting a file upload File Types dart Available Mar 31 at 12am - Apr...

1 answer below »
This is Dart programming language


3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/464001 1/5 Lab 9 Due Tuesday by 11:59pm Points 10 Submitting a file upload File Types dart Available Mar 31 at 12am - Apr 9 at 11:59pm 10 days Start Assignment Lab: Fetching Data from the Internet Introduc�on In this lab we will practice fetching data (fake for now) from the internet & use it to populate tables. It's also a good practice in OOP. Grading: You will submit the main.dart file only. You must use the provided index.html/styles.css files with no modifications. Part A: User Class & Data (2 marks) Create a new Dart project. Download the Lab09_web.zip (https://mycanvas.mohawkcollege.ca/courses/56088/files/9944528/download?download_frd=1) file. Use the index.html and styles.css in the archive to overwrite the default files in your project. You MUST not modify them. This is what the static page looks like: In the first step, we want to select a user through their id (from the dropdown list of 1 to 10). When  https://mycanvas.mohawkcollege.ca/courses/56088/files/9944528?wrap=1 https://mycanvas.mohawkcollege.ca/courses/56088/files/9944528/download?download_frd=1 3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/464001 2/5 selected, we display the user's name and email as follows: To achieve that, we need a User class together with a getUser asynchronous method as explained in class. You will also need an event listener for the drop down menu: Part B: User Posts (5 marks) Follow the standard steps of fetching an object or array of objects from the internet: Define a Post class with these properties: id, title & body. It should also have the basic constructor and fromJson factory method Define a getUserPosts asynchronous method that takes a userId and returns a Future list of Posts Use the fetched posts to populate the posts table for the selected user as shown in image  3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/464001 3/5 Part C: Post Word Count (3 marks) Add a method to class Post called wordCount. This method returns the number of words in the post. Use this method to populate the 3rd column of the table as follows:  3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/464001 4/5 Part D: Post Comments (Bonus) (3 marks) As you populate the posts table, determine the longest post (the one with the most words), then display the comments to that post in the comments table as shown: Define any necessary classes and methods needed to achieve this. Part E: Submi�ng your work Upload the main.dart file ONLY to the dropbox by the deadline for full marks or by the dropbox close date with deductions (25% per day or part thereof) Rubric Task Marks Display user name/email 2  3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/464001 5/5 Total Points: 10 Lab 9 Criteria Ratings Pts 2 pts 5 pts 3 pts Display user name/email 2 Fetch & display user posts 5 Display words count for each post 3 Fetch and display comments for longest post +3 User class & data 2 pts Full Marks 0 pts No Marks Fetch & display user posts 5 pts Full Marks 0 pts No Marks Display post's word count 3 pts Full Marks 0 pts No Marks 
Answered 8 days AfterMar 31, 2021

Answer To: 3/31/2021 Lab 9 https://mycanvas.mohawkcollege.ca/courses/56088/assignments/ XXXXXXXXXX/5 Lab 9 Due...

Valupadasu answered on Apr 02 2021
146 Votes
main.dart
import 'dart:convert' as convert;
import 'package:http/http.dart' as http;
import 'dart
:html';
class User {
int id;
String name;
String email;
Future getUser(String userId) async {
final response = await http
.get(Uri.https('jsonplaceholder.typicode.com', 'users/' + userId));
if (response.statusCode == 200) {
var jsonResponse = convert.jsonDecode(response.body);
name = jsonResponse['name'];
email = jsonResponse['email'];
}
return this;
}
}
class Post {
final String body;
final int id;
final String title;
Post({this.body, this.id, this.title});
factory Post.fromJson(Map json) {
return Post(
body: json['body'],
id: json['id'],
title: json['title'],
);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here