Chapter 5

  1. Is this code correct?
String data = http.get(url);

If not, why?

The code is not correct, as the get() method of http is asynchronous, and therefore returns a Future and not a String.

  1. What are the JSON and XML formats used for?
    JSON and XML are text formats that represent data. They can be returned by web services and then used in client apps. 

  2. What is a thread?
    A thread is a single line of execution.

  3. Can you name a few common asynchronous scenarios?
    Some scenarios where you need to use asynchronous programming include http requests, database writes, and in general all long-running tasks.

  4. When should you use the async/await keywords?
    Asynchronous operations return Future objects (futures), which is something to be completed at a later time. To suspend execution until a Future completes, we use await in an async function.

  5. What's the difference between ListView and ListTile?
    A ListTile is a material widget that can contain one to three lines of text with optional icons at the beginning and end. A ListView is a scrolling widget that displays its children one after another either horizontally or vertically. You can include ListTile widgets into a ListView. 

  6. How can you use the map method to parse data and create a list?
    The map() method transforms each element in a list and returns the result of the transformation in a new list. For example, you can transform some JSON data into an object, as shown in the following code block:

final moviesMap = jsonResponse['results'];
List movies = moviesMap.map((i) => Movie.fromJson(i)).toList();
  1. How do you pass data from one screen to another?
    You need to pass the data in the builder when you create the new route as shown in the following example:

MaterialPageRoute route = MaterialPageRoute(builder: (_) => YourScreen(yourData));
Navigator.push(context, route);
  1. When should you use the json.decode() method over the body of a Response object?
    You use the json.decode() method to convert the Response into a list of data that is usable in your app, like custom objects or Strings.

  2. What is a CircleAvatar?

    CircleAvatar is a widget that draws a circle that can contain an image or some text.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.188.238