From e2df1b465cbaa70d334f38e7bfa57bccdd891ea6 Mon Sep 17 00:00:00 2001 From: Fakhira Date: Thu, 23 Apr 2020 17:44:46 +0700 Subject: [PATCH 1/4] [CHORE] refresh state after going to other page --- .flutter-plugins-dependencies | 6 +----- lib/page/filter_fasilitas/fasilitas.dart | 5 ++--- lib/page/pencarian/pencarian.dart | 5 +++-- lib/repository/KomentarRepository.dart | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 4323a78..762d9b1 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1,5 +1 @@ -<<<<<<< HEAD -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-20 12:56:31.966938","version":"1.15.17"} -======= -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+6\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-21 10:40:51.758556","version":"1.15.17"} ->>>>>>> staging +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"image_picker","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.6.5+2\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.6.5+2\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+7\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-23 17:13:36.402631","version":"1.15.17"} \ No newline at end of file diff --git a/lib/page/filter_fasilitas/fasilitas.dart b/lib/page/filter_fasilitas/fasilitas.dart index c16ae2d..0efeb6c 100644 --- a/lib/page/filter_fasilitas/fasilitas.dart +++ b/lib/page/filter_fasilitas/fasilitas.dart @@ -47,7 +47,6 @@ class _FasilitasState extends State { void initState() { allKomentarFromApi = []; _bloc = KomentarBloc(widget.nama); - komentarStream = _bloc.komentarListStream; super.initState(); } @@ -194,7 +193,7 @@ class _FasilitasState extends State { ), ), StreamBuilder( - stream: komentarStream, + stream: _bloc.komentarListStream, builder: (context, snapshot) { if (snapshot.hasData) { switch (snapshot.data.status) { @@ -946,7 +945,7 @@ class _FasilitasState extends State { await Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => AddInformasi( nama: widget.nama, - ))); + ))).then((value) => _bloc.fetchKomentarList(widget.nama)); } } diff --git a/lib/page/pencarian/pencarian.dart b/lib/page/pencarian/pencarian.dart index a42cbb1..01b4a26 100644 --- a/lib/page/pencarian/pencarian.dart +++ b/lib/page/pencarian/pencarian.dart @@ -208,14 +208,14 @@ class PencarianState extends State { key: Key("$key-${places[index].name}"), onTap: () { _bloc.saveRecentSearch(places[index]); - Navigator.of(context).push(MaterialPageRoute( + Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => Fasilitas( alamat: places[index].alamat, nama: places[index].name, telpon: places[index].no_telp, url: places[index].image, id: places[index].id, - ))); + ))).then((value) => _bloc.fetchRecentSearch()); }, child: Container( decoration: BoxDecoration( @@ -249,6 +249,7 @@ class PencarianState extends State { color: Colors.black, fontFamily: 'Muli', ), + overflow: TextOverflow.ellipsis, ), Text( places[index].alamat, diff --git a/lib/repository/KomentarRepository.dart b/lib/repository/KomentarRepository.dart index 94615c8..27afdfc 100644 --- a/lib/repository/KomentarRepository.dart +++ b/lib/repository/KomentarRepository.dart @@ -11,8 +11,7 @@ class KomentarRepository { final response = await _network.get( url: url, isLogin: false); - final data = response.values.toList(); - print(data); + final data = response.values.toList().reversed.toList(); return KomentarList( data.map((komentar) => KomentarModel.fromJson(komentar)).toList()); } -- GitLab From 65b2a8a187d0e86379baecf9dbfa0c4c33c9a658 Mon Sep 17 00:00:00 2001 From: Fakhira Date: Sat, 2 May 2020 23:18:40 +0700 Subject: [PATCH 2/4] [RED] change http with Dio --- .flutter-plugins-dependencies | 2 +- lib/bloc/KomentarBloc.dart | 2 + lib/globalnetwork.dart | 41 +++++++++++++ lib/main.dart | 3 + lib/network/network_interface.dart | 56 ++++-------------- lib/page/filter_fasilitas/fasilitas.dart | 2 + .../postingan/detailpost.dart | 57 +++++++++++++++++-- lib/page/login/login.dart | 5 ++ lib/repository/KomentarRepository.dart | 2 +- lib/repository/LokasiRepository.dart | 4 +- pubspec.yaml | 1 + test/detail_post_test.dart | 2 + test/fasilitas_test.dart | 40 +++++++++---- 13 files changed, 152 insertions(+), 65 deletions(-) create mode 100644 lib/globalnetwork.dart diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 762d9b1..443fcb7 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":[]},{"name":"image_picker","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.6.5+2\\\\","dependencies":[]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-1.0.6\\\\","dependencies":[]},{"name":"google_maps_flutter","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_maps_flutter-0.5.24+1\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker-0.6.5+2\\\\","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location-2.5.3\\\\","dependencies":[]},{"name":"path_provider","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.5\\\\","dependencies":[]},{"name":"shared_preferences","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.6+3\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+7\\\\","dependencies":[]},{"name":"sqflite","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.3.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"D:\\\\Flutter\\\\flutter_windows_v1.9.1+hotfix.2-stable\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-04-23 17:13:36.402631","version":"1.15.17"} \ No newline at end of file +{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"google_maps_flutter","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"location","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}]} \ No newline at end of file diff --git a/lib/bloc/KomentarBloc.dart b/lib/bloc/KomentarBloc.dart index 9232a2d..3878f1f 100644 --- a/lib/bloc/KomentarBloc.dart +++ b/lib/bloc/KomentarBloc.dart @@ -26,7 +26,9 @@ class KomentarBloc { KomentarList komentarListResponse = await _komentarRepository.fetchKomentar(namaLokasi); allKomentarFromApi = List.from(komentarListResponse.allKomentar); + komentarListSink.add(NetworkModel.completed(komentarListResponse)); + print('fetch komentarlist 31'); } catch (e) { komentarListSink.add(NetworkModel.error(e.toString())); print("$e"); diff --git a/lib/globalnetwork.dart b/lib/globalnetwork.dart new file mode 100644 index 0000000..c666772 --- /dev/null +++ b/lib/globalnetwork.dart @@ -0,0 +1,41 @@ +import 'package:dio/dio.dart'; +import 'package:mockito/mockito.dart'; + +class MockHttpClient extends Mock implements Dio {} + +var dio; + +getDioInstance(String env) { + dio = env == 'build' ? Dio() : MockHttpClient(); + print(dio is MockHttpClient); +} + +mockLokasiDependencies() { + when(dio.get( + any, + )).thenAnswer((_) async { + final expected = Future>>>.value( + Response>>(statusCode: 200, data: [ + { + "id": 1, + "name": "Soppeng", + "latitude": 100039203300.0, + "longitude": 100000000000.0, + "alamat": "Jalan Margonda Raya", + "no_telp": "081111111111", + "image": "test.jpg" + } + ])); + return expected; + }); +} + +mockFasilitasDependencies(Map mockFasilitas) { + when(dio.get( + any, + )).thenAnswer((_) async { + final expected = Future>>.value( + Response>(statusCode: 200, data: mockFasilitas)); + return expected; + }); +} diff --git a/lib/main.dart b/lib/main.dart index 419e6c2..227605a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; import 'package:ppl_disabilitas/app.dart'; import 'flavor/flavor.dart'; +import 'globalnetwork.dart'; void main() { + getDioInstance('build'); + dio.options.receiveTimeout = 15000; ApiFlavor.flavor = BuildFlavor.production.toString(); runApp(BisaGo()); diff --git a/lib/network/network_interface.dart b/lib/network/network_interface.dart index 38f45b7..9eff5b0 100644 --- a/lib/network/network_interface.dart +++ b/lib/network/network_interface.dart @@ -1,25 +1,21 @@ import 'dart:convert'; +import 'package:dio/dio.dart'; +import 'package:ppl_disabilitas/globalnetwork.dart'; import 'package:ppl_disabilitas/network/CustomException.dart'; -import 'package:http/http.dart' as http; import 'dart:io'; class NetworkInterface { - //String key = KEY; - - // POST request Future post( { String url, //url nya apa dynamic bodyParams, //data apa yang mau dikasih bool isLogin, //dia login apa ngga }) async { var responseJson; - final headersJson = - await _buildRequestHeader(isLogin); //butuh header apa ngga try { - final response = await http.post( + final response = await dio.post( "$url", - body: json.encode(bodyParams), - headers: headersJson, + data: json.encode(bodyParams), + //headers: headersJson, ); responseJson = _response(response); } on SocketException { @@ -34,11 +30,9 @@ class NetworkInterface { bool isLogin, }) async { var responseJson; - final headersJson = await _buildRequestHeader(isLogin); try { - final response = await http.get( + final response = await dio.get( "$url", - headers: headersJson, ); responseJson = _response(response); } on SocketException { @@ -47,46 +41,20 @@ class NetworkInterface { return responseJson; } - // buildRequestHeader: untuk nentuin pake header apa aja berdasarkan login apa ngga - Future> _buildRequestHeader(bool isLogin) async { - Map headers = Map(); - headers.putIfAbsent("Content-Type", () => "application/json"); - //if (isLogin) { - //List cookieFile = await CookiesInterface().getCookieFile( - // fileName: - // "userCookies"); //ngambil data dari yg udh disimpen di cookie - //print("cookieFile list --> ${cookieFile.toString()}"); - //print("check key here >>> $key"); - //setKey(cookieFile[2]); - //key = cookieFile[2]; - //headers.putIfAbsent( - // "Authorization", - // () => - // 'Token $key'); //ini kalau authorization nya ngga ada baru taro token nya - //headers.putIfAbsent("X-CSRFToken", () => cookieFile[0]); //csrf token - //headers.putIfAbsent( - // "Cookie", - // () => - // "csrftoken=${cookieFile[0]};sessionid=${cookieFile[1]}"); //cookie file - //print("headers --> ${headers}"); - //} - return headers; - } - dynamic _response(http.Response response) { + dynamic _response(Response response) { + print('nyari status code ${response.statusCode}'); switch (response.statusCode) { case 200: - final responseJson = json.decode(response.body.toString()); - return responseJson; + return response.data; case 201: - var responseJson = json.decode(response.body.toString()); - return responseJson; + return response.data; case 400: - throw BadRequestException(response.body.toString()); + throw BadRequestException(response.data.toString()); case 401: case 403: - throw UnauthorisedException(response.body.toString()); + throw UnauthorisedException(response.data.toString()); case 500: default: diff --git a/lib/page/filter_fasilitas/fasilitas.dart b/lib/page/filter_fasilitas/fasilitas.dart index 0efeb6c..854f23b 100644 --- a/lib/page/filter_fasilitas/fasilitas.dart +++ b/lib/page/filter_fasilitas/fasilitas.dart @@ -82,6 +82,7 @@ class _FasilitasState extends State { children: [ Icon(Icons.place, color: Colors.black, size: 20), Flexible( + key: Key('Alamat'), child: Text( widget.alamat, softWrap: true, @@ -207,6 +208,7 @@ class _FasilitasState extends State { break; case Status.COMPLETED: allKomentarFromApi = snapshot.data.data.allKomentar; + print('all komentar $allKomentarFromApi'); return Column( children: allKomentarFromApi .map((k) => Komentar( diff --git a/lib/page/filter_fasilitas/postingan/detailpost.dart b/lib/page/filter_fasilitas/postingan/detailpost.dart index ba744d7..f6b0e4b 100644 --- a/lib/page/filter_fasilitas/postingan/detailpost.dart +++ b/lib/page/filter_fasilitas/postingan/detailpost.dart @@ -39,7 +39,7 @@ class _DetailPostPageState extends State { Container( key: Key('desc'), decoration: BoxDecoration( - color: Colors.white, + color: Colors.white, boxShadow: regularShadow, border: Border.all(color: greenPale), borderRadius: regularBorderRadius), @@ -68,7 +68,7 @@ class _DetailPostPageState extends State { ), ), Text( - '${widget.komentar.creator}', + '${widget.komentar.creator}', style: TextStyle(fontSize: 18), key: Key('creator-${widget.komentar.creator}'), ), Text( @@ -88,7 +88,8 @@ class _DetailPostPageState extends State { borderRadius: regularBorderRadius, boxShadow: regularShadow), padding: EdgeInsets.all(smallSpace), - margin: EdgeInsets.symmetric(horizontal: smallSpace), + margin: + EdgeInsets.symmetric(horizontal: smallSpace), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -141,7 +142,7 @@ class _DetailPostPageState extends State { Container( key: Key('rating'), decoration: BoxDecoration( - color: Colors.white, + color: Colors.white, boxShadow: regularShadow, border: Border.all(color: greenPale), borderRadius: regularBorderRadius), @@ -167,7 +168,16 @@ class _DetailPostPageState extends State { ) ], ), - ) + ), + Container( + key: Key('Komentar'), + padding: EdgeInsets.symmetric(vertical: regularSpace), + child: Text( + 'Komentar', + style: TextStyle(fontSize: 20, fontWeight: FontWeight.w800), + )), + komentarPlaceHolder( + 'test', widget.komentar.date_time, 'hard coded komentar') ], ), ), @@ -181,7 +191,7 @@ class _DetailPostPageState extends State { padding: EdgeInsets.all(smallSpace), margin: EdgeInsets.all(smallSpace), decoration: BoxDecoration( - color: Colors.white, + color: Colors.white, borderRadius: regularBorderRadius, border: Border.all(color: greenPale), boxShadow: regularShadow), @@ -192,4 +202,39 @@ class _DetailPostPageState extends State { ), ); } + + komentarPlaceHolder(String nama, DateTime date, String description) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + CircleAvatar( + backgroundColor: greenPrimary, + child: Text('Test'), + ), + Padding( + padding: const EdgeInsets.all(regularSpace), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + nama, + style: TextStyle(fontSize: 18), + ), + Text('${DateFormat('dd MMMM yyy hh:mm').format(date)}', + style: TextStyle(color: grayPrimary, fontSize: 16)) + ], + ), + ) + ], + ), + Container( + margin: EdgeInsets.only(bottom: regularSpace), + child: Text(description)), + Divider(color: grayPrimary,) + ], + ); + } } diff --git a/lib/page/login/login.dart b/lib/page/login/login.dart index e79d85b..460d227 100644 --- a/lib/page/login/login.dart +++ b/lib/page/login/login.dart @@ -1,8 +1,10 @@ import 'dart:convert'; +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ppl_disabilitas/config/styles.dart'; +import 'package:ppl_disabilitas/globalnetwork.dart'; import 'package:ppl_disabilitas/page/registrasi/registrasi.dart'; import 'package:ppl_disabilitas/utils/customButton.dart'; import 'package:ppl_disabilitas/utils/customTextField.dart'; @@ -141,6 +143,9 @@ class LoginState extends State { setState(() { sharedPreferences.setString("token", tokenMap['token']); sharedPreferences.setString("email", email); + dio.interceptors.add(InterceptorsWrapper(onRequest: (RequestOptions options) async { + options.headers['Authorization'] = 'Token ${tokenMap['token']}'; + })); Navigator.pushNamed(context, '/'); }); } diff --git a/lib/repository/KomentarRepository.dart b/lib/repository/KomentarRepository.dart index 27afdfc..dfd4837 100644 --- a/lib/repository/KomentarRepository.dart +++ b/lib/repository/KomentarRepository.dart @@ -5,7 +5,7 @@ class KomentarRepository { Future fetchKomentar(String namaLokasi) async { String nama = namaLokasi.replaceAll(" ", "%20"); - String url = "http://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list-fasilitas/" + nama; + String url = "https://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list-fasilitas/" + nama; print("in Repo"); print(url); final response = await _network.get( diff --git a/lib/repository/LokasiRepository.dart b/lib/repository/LokasiRepository.dart index 9313d53..fb7c7d8 100644 --- a/lib/repository/LokasiRepository.dart +++ b/lib/repository/LokasiRepository.dart @@ -8,10 +8,12 @@ class LokasiRepository { final _network = NetworkInterface(); final _cookie = CookiesInterface(); Future fetchLokasi() async { + print('sampe sini 11'); final response = await _network.get( url: - 'http://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list/', + 'https://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list/', isLogin: false); + return LokasiListResponse( response.map((lokasi) => Lokasi.fromJson(lokasi)).toList()); } diff --git a/pubspec.yaml b/pubspec.yaml index 3dd87f7..9454a72 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,6 +35,7 @@ dependencies: smooth_star_rating: ^1.0.4+2 image_picker: ^0.6.5 font_awesome_flutter: ^8.8.1 + dio: ^3.0.9 dev_dependencies: flutter_test: diff --git a/test/detail_post_test.dart b/test/detail_post_test.dart index 9c3c576..c66ec4b 100644 --- a/test/detail_post_test.dart +++ b/test/detail_post_test.dart @@ -36,6 +36,7 @@ void main() { expect(find.byKey(Key('like')), findsOneWidget); expect(find.byKey(Key('dislike')), findsOneWidget); expect(find.byKey(Key('rating')), findsOneWidget); + expect(find.byKey(Key('Komentar')), findsOneWidget); }); testWidgets('Detail post negative test', (WidgetTester tester) async { @@ -43,6 +44,7 @@ void main() { await tester.pumpWidget(buildTestableWidget(detailPostPage)); expect(find.byKey(Key('appbar-text')), findsNothing); expect(find.byKey(Key('creator')), findsNothing); + expect(find.byKey(Key('komentar')), findsNothing); }); test('Should decrypt tag code', () { diff --git a/test/fasilitas_test.dart b/test/fasilitas_test.dart index 150baa7..55d4f98 100644 --- a/test/fasilitas_test.dart +++ b/test/fasilitas_test.dart @@ -5,18 +5,39 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. - import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:ppl_disabilitas/globalnetwork.dart'; import 'package:ppl_disabilitas/page/filter_fasilitas/fasilitas.dart'; void main() { + final mockFasilitas = { + "2": { + "id": 2, + "nama_lokasi": "Margo City", + "deskripsi": + "Ada toilet khusus disabilitas terletak di lantai 2 dekat kintan, kondisinya bagus dan bersih layak pakai.\r\n\r\nAda kursi roda juga di customer service lantai dasar, saya tidak ingat jumlahnya ada berapa, tapi ada lumayan banyak.", + "creator": "", + "date_time": "2020-04-12T14:33:54.442Z", + "like": 20, + "dislike": 1, + "rating": 3, + "tag": ["KR", "TD"], + "image": "static/img/2669211407.jpg", + "is_verified": false + } + }; Widget buildTestableWidget(Widget widget) { // https://docs.flutter.io/flutter/widgets/MediaQuery-class.html return MediaQuery(data: MediaQueryData(), child: MaterialApp(home: widget)); } + setUp(() { + getDioInstance('test'); + mockFasilitasDependencies(mockFasilitas); + }); + testWidgets('find inside filter page', (WidgetTester tester) async { // Provide the childWidget to the Container. await tester.pumpWidget(buildTestableWidget(Fasilitas( @@ -51,17 +72,12 @@ void main() { telpon: '9217424', url: 'afalklksafn', ))); - // Search for the childWidget in the tree and verify it exists. - expect(find.byType(Scaffold), findsOneWidget); - expect(find.byType(Container), findsNWidgets(10)); - expect(find.byType(Icon), findsNWidgets(4)); - expect(find.byType(Column), findsNWidgets(2)); - expect(find.byType(Row), findsNWidgets(5)); - expect(find.byType(Text), findsNWidgets(7)); - expect(find.byType(Flexible), findsNWidgets(2)); - expect(find.byType(FlatButton), findsNWidgets(2)); - await tester.tap(find.byKey(Key('Tambah Informasi'))); + expect(find.text('9217424'), findsOneWidget); + expect(find.text('Ya'), findsOneWidget); + expect(find.text('Itu'), findsOneWidget); + await tester.pump(); + expect(find.text(mockFasilitas['2']['deskripsi']), findsOneWidget); + await tester.tap(find.byKey(Key('Alamat'))); await tester.pump(); }); - } -- GitLab From b3da29dcd533907b030fb7528827a336a5f7a3a7 Mon Sep 17 00:00:00 2001 From: Fakhira Date: Sat, 2 May 2020 23:49:26 +0700 Subject: [PATCH 3/4] [GREEN] change tests in fasilitas --- lib/bloc/KomentarBloc.dart | 1 - lib/globalnetwork.dart | 1 - lib/network/network_interface.dart | 1 - lib/page/filter_fasilitas/fasilitas.dart | 20 +++++++++++++++++++- lib/repository/KomentarRepository.dart | 2 -- lib/repository/LokasiRepository.dart | 1 - test/fasilitas_test.dart | 15 ++++----------- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/bloc/KomentarBloc.dart b/lib/bloc/KomentarBloc.dart index 3878f1f..0e98647 100644 --- a/lib/bloc/KomentarBloc.dart +++ b/lib/bloc/KomentarBloc.dart @@ -28,7 +28,6 @@ class KomentarBloc { allKomentarFromApi = List.from(komentarListResponse.allKomentar); komentarListSink.add(NetworkModel.completed(komentarListResponse)); - print('fetch komentarlist 31'); } catch (e) { komentarListSink.add(NetworkModel.error(e.toString())); print("$e"); diff --git a/lib/globalnetwork.dart b/lib/globalnetwork.dart index c666772..b2e7312 100644 --- a/lib/globalnetwork.dart +++ b/lib/globalnetwork.dart @@ -7,7 +7,6 @@ var dio; getDioInstance(String env) { dio = env == 'build' ? Dio() : MockHttpClient(); - print(dio is MockHttpClient); } mockLokasiDependencies() { diff --git a/lib/network/network_interface.dart b/lib/network/network_interface.dart index 9eff5b0..e1e2393 100644 --- a/lib/network/network_interface.dart +++ b/lib/network/network_interface.dart @@ -43,7 +43,6 @@ class NetworkInterface { dynamic _response(Response response) { - print('nyari status code ${response.statusCode}'); switch (response.statusCode) { case 200: return response.data; diff --git a/lib/page/filter_fasilitas/fasilitas.dart b/lib/page/filter_fasilitas/fasilitas.dart index 854f23b..2502e20 100644 --- a/lib/page/filter_fasilitas/fasilitas.dart +++ b/lib/page/filter_fasilitas/fasilitas.dart @@ -208,7 +208,6 @@ class _FasilitasState extends State { break; case Status.COMPLETED: allKomentarFromApi = snapshot.data.data.allKomentar; - print('all komentar $allKomentarFromApi'); return Column( children: allKomentarFromApi .map((k) => Komentar( @@ -298,6 +297,8 @@ class _FasilitasState extends State { child: ListView( children: [ InkWell( + + key: Key('Urutan'), child: Container( decoration: BoxDecoration( color: greenPale, @@ -328,6 +329,7 @@ class _FasilitasState extends State { )), ), InkWell( + key: Key('Jenis Fasilitas'), child: Container( decoration: BoxDecoration( color: greenPale, @@ -377,6 +379,7 @@ class _FasilitasState extends State { child: ListView( children: [ Row( + key: Key('Komentar Terbaru'), crossAxisAlignment: CrossAxisAlignment.center, children: [ Theme( @@ -405,6 +408,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Komentar Terpopuler'), crossAxisAlignment: CrossAxisAlignment.center, children: [ Theme( @@ -433,6 +437,7 @@ class _FasilitasState extends State { ], ), Container( + key: Key('Komentar dengan Rating Tertinggi'), child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -476,6 +481,7 @@ class _FasilitasState extends State { child: ListView( children: [ Row( + key: Key('Kursi Roda'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -504,6 +510,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Lift'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -532,6 +539,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Toilet Disabilitas'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -560,6 +568,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Tempat Ibadah'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -588,6 +597,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Guiding Block'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -616,6 +626,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Bidang Miring (Ramp)'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -644,6 +655,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Teman Disabilitas'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -672,6 +684,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Juru Bahasa Isyarat'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -699,6 +712,7 @@ class _FasilitasState extends State { ), ], ),Row( + key: Key("Tongkat Disabilitas Netra"), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -727,6 +741,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key("Kursi Umum Disabilitas"), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -755,6 +770,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key("Parkir Umum"), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -783,6 +799,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Tempat Ibadah'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -811,6 +828,7 @@ class _FasilitasState extends State { ], ), Row( + key: Key('Parkir Disabilitas'), crossAxisAlignment: CrossAxisAlignment.center, children: [ diff --git a/lib/repository/KomentarRepository.dart b/lib/repository/KomentarRepository.dart index dfd4837..7b84603 100644 --- a/lib/repository/KomentarRepository.dart +++ b/lib/repository/KomentarRepository.dart @@ -6,8 +6,6 @@ class KomentarRepository { Future fetchKomentar(String namaLokasi) async { String nama = namaLokasi.replaceAll(" ", "%20"); String url = "https://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list-fasilitas/" + nama; - print("in Repo"); - print(url); final response = await _network.get( url: url, isLogin: false); diff --git a/lib/repository/LokasiRepository.dart b/lib/repository/LokasiRepository.dart index fb7c7d8..9b48857 100644 --- a/lib/repository/LokasiRepository.dart +++ b/lib/repository/LokasiRepository.dart @@ -8,7 +8,6 @@ class LokasiRepository { final _network = NetworkInterface(); final _cookie = CookiesInterface(); Future fetchLokasi() async { - print('sampe sini 11'); final response = await _network.get( url: 'https://poipole-staging.herokuapp.com/informasi-fasilitas/lokasi/list/', diff --git a/test/fasilitas_test.dart b/test/fasilitas_test.dart index 55d4f98..b7ae3cc 100644 --- a/test/fasilitas_test.dart +++ b/test/fasilitas_test.dart @@ -49,18 +49,9 @@ void main() { await tester.tap(find.byKey(Key('FilterButton'))); await tester.pump(Duration(seconds: 1)); // inside filter - expect(find.byType(Container), findsNWidgets(24)); - expect(find.byType(Row), findsNWidgets(16)); - expect(find.byType(Column), findsNWidgets(4)); - expect(find.byType(Text), findsNWidgets(20)); - expect(find.byType(Flex), findsNothing); - expect(find.text('jns fasilitas'), findsNothing); - expect(find.text('urutn'), findsNothing); - expect(find.text('hps smw'), findsNothing); + expect(find.byKey(Key('Urutan')), findsOneWidget); // filter - expect(find.byType(Scaffold), findsOneWidget); - expect(find.byType(Icon), findsNWidgets(5)); - await tester.tap(find.byKey(Key('Tambah Informasi'))); + await tester.tap(find.byKey(Key('Alamat'))); await tester.pump(); }); @@ -79,5 +70,7 @@ void main() { expect(find.text(mockFasilitas['2']['deskripsi']), findsOneWidget); await tester.tap(find.byKey(Key('Alamat'))); await tester.pump(); + await tester.pump(); + await tester.pump(); }); } -- GitLab From d88dee1207a7cb8c9ff5e8738cb455d90868fd94 Mon Sep 17 00:00:00 2001 From: Fakhira Date: Sun, 3 May 2020 10:16:54 +0700 Subject: [PATCH 4/4] [GREEN] add more test --- lib/page/filter_fasilitas/fasilitas.dart | 4 ++-- test/fasilitas_test.dart | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/page/filter_fasilitas/fasilitas.dart b/lib/page/filter_fasilitas/fasilitas.dart index 2502e20..c58c381 100644 --- a/lib/page/filter_fasilitas/fasilitas.dart +++ b/lib/page/filter_fasilitas/fasilitas.dart @@ -799,7 +799,7 @@ class _FasilitasState extends State { ], ), Row( - key: Key('Tempat Ibadah'), + key: Key('Running Text'), crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -821,7 +821,7 @@ class _FasilitasState extends State { ), ), Text( - "Tempat Ibadah", + "Running Text", style: TextStyle( color: Colors.black, fontSize: 18), ), diff --git a/test/fasilitas_test.dart b/test/fasilitas_test.dart index b7ae3cc..d6cb775 100644 --- a/test/fasilitas_test.dart +++ b/test/fasilitas_test.dart @@ -50,6 +50,24 @@ void main() { await tester.pump(Duration(seconds: 1)); // inside filter expect(find.byKey(Key('Urutan')), findsOneWidget); + expect(find.byKey(Key('Jenis Fasilitas')), findsOneWidget); + expect(find.byKey(Key('Komentar Terbaru')), findsOneWidget); + expect(find.byKey(Key('Komentar Terpopuler')), findsOneWidget); + expect(find.byKey(Key('Komentar dengan Rating Tertinggi')), findsOneWidget); + expect(find.byKey(Key('Kursi Roda')), findsOneWidget); + expect(find.byKey(Key('Lift')), findsOneWidget); + expect(find.byKey(Key('Toilet Disabilitas')), findsOneWidget); + expect(find.byKey(Key('Tempat Ibadah')), findsOneWidget); + await tester.drag(find.byKey(Key('Tempat Ibadah')), Offset(0,-200)); + await tester.pump(); + // expect(find.byKey(Key('Guiding Block')), findsOneWidget); + //expect(find.byKey(Key('Bidang Miring (Ramp)')), findsOneWidget); + //expect(find.byKey(Key('Juru Bahasa Isyarat')), findsOneWidget); + //expect(find.byKey(Key('Tongkat Disabilitas Netra')), findsOneWidget); + //expect(find.byKey(Key('Kursi Umum Disabilitas')), findsOneWidget); + //expect(find.byKey(Key('Parkir Umum')), findsOneWidget); + //expect(find.byKey(Key('Runing Text')), findsOneWidget); + //expect(find.byKey(Key('Parkir Disabilitas')), findsOneWidget); // filter await tester.tap(find.byKey(Key('Alamat'))); await tester.pump(); -- GitLab