This file contains hidden or 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 MyHomePage extends StatefulWidget { | |
| @override | |
| _MyHomePageState createState() => _MyHomePageState(); | |
| } | |
| class _MyHomePageState extends State<MyHomePage> { | |
| @override | |
| void initState() { | |
| context.bloc<MovieBloc>().add(LoadMovies()); | |
| super.initState(); |
This file contains hidden or 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:dio/dio.dart'; | |
| import 'package:network_handling/model/movie_response.dart'; | |
| import 'package:network_handling/services/api_result.dart'; | |
| import 'package:network_handling/services/dio_client.dart'; | |
| import 'package:network_handling/services/network_exceptions.dart'; | |
| class APIRepository { | |
| DioClient dioClient; | |
| final String _apiKey = "78b9f63937763a206bff26c070b94158"; | |
| String _baseUrl = "http://api.themoviedb.org/3/"; |
This file contains hidden or 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 MovieResponse { | |
| int page; | |
| int totalResults; | |
| int totalPages; | |
| List<Movie> results; | |
| MovieResponse({this.page, this.totalResults, this.totalPages, this.results}); | |
| MovieResponse.fromJson(Map<String, dynamic> json) { | |
| page = json['page']; |
This file contains hidden or 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/foundation.dart'; | |
| import 'package:freezed_annotation/freezed_annotation.dart'; | |
| import 'network_exceptions.dart'; | |
| part 'api_result.freezed.dart'; | |
| @freezed | |
| abstract class ApiResult<T> with _$ApiResult<T> { |
This file contains hidden or 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:io'; | |
| import 'package:dio/dio.dart'; | |
| import 'package:freezed_annotation/freezed_annotation.dart'; | |
| part 'network_exceptions.freezed.dart'; | |
| @freezed | |
| abstract class NetworkExceptions with _$NetworkExceptions { | |
| const factory NetworkExceptions.requestCancelled() = RequestCancelled; |
This file contains hidden or 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:io'; | |
| import 'package:dio/dio.dart'; | |
| import 'package:flutter/foundation.dart'; | |
| const _defaultConnectTimeout = Duration.millisecondsPerMinute; | |
| const _defaultReceiveTimeout = Duration.millisecondsPerMinute; | |
| class DioClient { | |
| final String baseUrl; |
This file contains hidden or 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
| StreamBuilder<Result<List<Prediction>>>( | |
| stream: placePredictionSearchBloc.streamController.stream, | |
| initialData: Result.idle(), | |
| builder: (BuildContext context, | |
| AsyncSnapshot<Result<List<Prediction>>> snapshot) { | |
| return snapshot.data.when(idle: () { | |
| return Container(); | |
| }, loading: () { | |
| return CircularProgressIndicator(); | |
| }, success: (List<AutocompletePrediction> value) { |
This file contains hidden or 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 PlacePredictionSearchBloc { | |
| StreamController<Result<List<Prediction>>> streamController = | |
| StreamController<Result<List<Prediction>>>(); | |
| AppRepository appRepository = AppRepository(); | |
| Future<void> getCurrentAddress(String search) async { | |
| streamController.sink.add(Result.loading()); | |
| try { |
This file contains hidden or 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
| // GENERATED CODE - DO NOT MODIFY BY HAND | |
| // ignore_for_file: deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named | |
| part of 'result.dart'; | |
| // ************************************************************************** | |
| // FreezedGenerator | |
| // ************************************************************************** | |
| T _$identity<T>(T value) => value; |
NewerOlder