Skip to content

Instantly share code, notes, and snippets.

View salihgueler's full-sized avatar
🖖
Aloha

Muhammed Salih Guler salihgueler

🖖
Aloha
View GitHub Profile
// 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 {
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/
...
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(movie.title),
),
body: new ListView(
children: <Widget>[
new Image.network(
@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(
// 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"),
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
@salihgueler
salihgueler / model.dart
Created January 6, 2019 19:43
Saturday
class Movie {
String title;
String posterPath;
String backdropPath;
String originalTitle;
double voteAverage;
String overview;
String releaseDate;
/// 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"];
@salihgueler
salihgueler / update.dart
Created January 6, 2019 19:49
Saturday
getMovies() async {
...
List results = data["results"];
// Get the Movie list
List<Movie> movieList = createMovieList(results);
// Print the results.
print(movieList);
...
}
/// 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());
}