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 MovieScreen extends StatefulWidget { | |
@override | |
_MovieScreenState createState() => _MovieScreenState(); | |
} | |
class _MovieScreenState extends State<MovieScreen> { | |
MovieBloc _bloc; | |
@override | |
void 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
class MovieBloc { | |
MovieRepository _movieRepository; | |
StreamController _movieListController; | |
StreamSink<ApiResponse<List<Movie>>> get movieListSink => | |
_movieListController.sink; | |
Stream<ApiResponse<List<Movie>>> get movieListStream => | |
_movieListController.stream; |
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 MovieRepository { | |
final String _apiKey = "Paste your api key here"; | |
ApiBaseHelper _helper = ApiBaseHelper(); | |
Future<List<Movie>> fetchMovieList() async { | |
final response = await _helper.get("movie/popular?api_key=$_apiKey"); | |
return MovieResponse.fromJson(response).results; | |
} | |
} |
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 ApiResponse<T> { | |
Status status; | |
T data; | |
String message; | |
ApiResponse.loading(this.message) : status = Status.LOADING; | |
ApiResponse.completed(this.data) : status = Status.COMPLETED; | |
ApiResponse.error(this.message) : status = Status.ERROR; | |
@override |
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 totalResults; | |
List<Movie> results; | |
MovieResponse.fromJson(Map<String, dynamic> json) { | |
totalResults = json['total_results']; | |
if (json['results'] != null) { | |
results = new List<Movie>(); | |
json['results'].forEach((v) { | |
results.add(new Movie.fromJson(v)); |
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 AppException implements Exception { | |
final _message; | |
final _prefix; | |
AppException([this._message, this._prefix]); | |
String toString() { | |
return "$_prefix$_message"; | |
} | |
} |
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 ApiBaseHelper { | |
final String _baseUrl = "http://api.themoviedb.org/3/"; | |
Future<dynamic> get(String url) async { | |
var responseJson; | |
try { | |
final response = await http.get(_baseUrl + url); | |
responseJson = _returnResponse(response); | |
} on SocketException { |
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
public class PermissionSwitches extends BaseObservable { | |
private boolean usageAccess; | |
private boolean drawOverAccess; | |
private boolean notificationAccess; | |
@Bindable | |
public boolean isPermissionsAvailable() { | |
return isNotificationAccess() | |
&& isDrawOverAccess() |
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
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
final FirebaseAuth _auth = FirebaseAuth.instance; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |