Your Second Flutter App

Nov 30 2021 · Dart 2.13, Flutter 2.2.3, Visual Studio Code

Part 1: Parse Network Data

05. Make a Network Call

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 04. Use a Model & Repository Next episode: 06. Parse the Network Response

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Most mobile apps make network calls to the Internet to send and retrieve data to a backend server or API.

https://pub.dev/packages/http
import 'package:http/http.dart' as http;
final uri = Uri.parse(url);
final response = await http.get(uri);
final apiResponse = json.decode(response.body) as Map<String, dynamic>;
print(apiResponse);
class CoursesController {
}
import '../../repository/repository.dart';
import '../../repository/course_repository.dart';
import '../../model/course.dart';
final Repository _repository = CourseRepository();
  Future<List<Course>> fetchCourses(int domainFilter) {
    return _repository.getCourses(domainFilter);
  }
final _controller = CoursesController();
    return FutureBuilder<List<Course>>(
        future: _controller.fetchCourses(Constants.allFilter),
);
builder: (context, snapshot) {
  final courses = snapshot.data;
  if (courses == null) {
    return const Center(child: CircularProgressIndicator());
  }
  return const Text('RWCourses');
}
import '../../model/course.dart';
import 'ui/courses/courses_page.dart';
@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text(Strings.appTitle),
    ),
    body: const CoursesPage(),
  );
}