This file contains 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
// Imports the Flutter Driver API | |
import 'package:flutter_driver/flutter_driver.dart'; | |
import 'package:test/test.dart'; | |
void main() { | |
group('scrolling performance test', () | |
{ | |
FlutterDriver driver; | |
setUpAll(() async { |
This file contains 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
muhammedsalihguler@Muhammeds-MBP ,~/development/flutter/flutter_popular_movies (FPM-Testing) $ flutter drive --target=test/MovieAppIntegrationTest.dart | |
Using device Pixel. | |
Starting application: test/MovieAppIntegrationTest.dart | |
Initializing gradle... 1.0s | |
Resolving dependencies... 0.8s | |
Installing build/app/outputs/apk/app.apk... 10.8s | |
Running 'gradlew assembleDebug'... 1.4s | |
Built build/app/outputs/apk/debug/app-debug.apk (32.0MB). | |
I/FlutterActivityDelegate(24184): onResume setting current activity to this | |
I/flutter (24184): Observatory listening on http://127.0.0.1:48109/ |
This file contains 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
... | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text(movie.title), | |
), | |
body: new ListView( | |
children: <Widget>[ | |
new Image.network( |
This file contains 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
@override | |
Widget build(BuildContext context) { | |
return new FutureBuilder( | |
future: getMovies(), | |
builder: (BuildContext context, | |
AsyncSnapshot<List> snapshot) { | |
if (!snapshot.hasData) | |
// Shows progress indicator until the data is load. | |
return new MaterialApp( | |
home: new Scaffold( |
This file contains 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
// Main method starts execution | |
void main() { | |
runApp( | |
new MaterialApp( | |
home: new Scaffold( | |
appBar: new AppBar( | |
title: new Text('Movie List Application'), | |
), | |
body: new Center( | |
child: new Text("Hello World"), |
This file contains 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
getMovies() async { | |
final String url = 'http://api.themoviedb.org/3/movie/top_rated?api_key=<your-api-key-here>'; | |
var httpClient = new HttpClient(); | |
try { | |
// Make the call | |
var request = await httpClient.getUrl(Uri.parse(url)); | |
var response = await request.close(); | |
if (response.statusCode == HttpStatus.OK) { | |
var json = await response.transform(UTF8.decoder).join(); | |
// Decode the json response |
This file contains 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 Movie { | |
String title; | |
String posterPath; | |
String backdropPath; | |
String originalTitle; | |
double voteAverage; | |
String overview; | |
String releaseDate; |
This file contains 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
/// Method to parse information from the retrieved data | |
List<Movie> createMovieList(List data) { | |
List<Movie> list = new List(); | |
for (int i = 0; i < data.length; i++) { | |
String title = data[i]["title"]; | |
String posterPath = data[i]["poster_path"]; | |
String backdropImage = data[i]["backdrop_path"]; | |
String originalTitle = data[i]["original_title"]; | |
double voteAverage = data[i]["vote_average"]; | |
String overview = data[i]["overview"]; |
This file contains 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
getMovies() async { | |
... | |
List results = data["results"]; | |
// Get the Movie list | |
List<Movie> movieList = createMovieList(results); | |
// Print the results. | |
print(movieList); | |
... | |
} |
This file contains 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
/// Method to get movies from the backend | |
Future<List<Movie>> getMovies() async { | |
... | |
List<Movie> movieList = createMovieList(results); | |
// Print the results. | |
return movieList; | |
... | |
} catch (exception) { | |
print(exception.toString()); | |
} |