code improvements.

development
Sikander Saleem 5 years ago
parent 1e42ba6bd7
commit 8df6237d02

@ -69,7 +69,7 @@ class ApiClient {
try { try {
var jsonData = jsonDecode(response.body); var jsonData = jsonDecode(response.body);
return factoryConstructor(jsonData); return factoryConstructor(jsonData);
} catch (ex, tr) { } catch (ex) {
throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex);
} }
} }

@ -11,7 +11,7 @@ class AyaModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<AyaModelData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new AyaModelData.fromJson(v)); data.add(new AyaModelData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class AyaTangheemProperty {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<AyaTangheemPropertyData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new AyaTangheemPropertyData.fromJson(v)); data.add(new AyaTangheemPropertyData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class AyaTangheemType {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<AyaTangheemTypeData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new AyaTangheemTypeData.fromJson(v)); data.add(new AyaTangheemTypeData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class AyatTangheemTypeMapped {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<AyatTangheemTypeMappedData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new AyatTangheemTypeMappedData.fromJson(v)); data.add(new AyatTangheemTypeMappedData.fromJson(v));
}); });
@ -76,13 +76,13 @@ class AyatTangheemTypeMappedData {
userId = json['userId']; userId = json['userId'];
ayahTextBase = json['ayahTextBase']; ayahTextBase = json['ayahTextBase'];
if (json['property'] != null) { if (json['property'] != null) {
property = new List<TangheemProperty>(); property = [];
json['property'].forEach((v) { json['property'].forEach((v) {
property.add(new TangheemProperty.fromJson(v)); property.add(new TangheemProperty.fromJson(v));
}); });
} }
if (json['voiceNote'] != null) { if (json['voiceNote'] != null) {
voiceNote = new List<VoiceNote>(); voiceNote = [];
json['voiceNote'].forEach((v) { json['voiceNote'].forEach((v) {
voiceNote.add(new VoiceNote.fromJson(v)); voiceNote.add(new VoiceNote.fromJson(v));
}); });

@ -50,6 +50,6 @@ class BookMarkModel {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
List encodedList = list.map((e) => jsonEncode(e.toJson())).toList(); List encodedList = list.map((e) => jsonEncode(e.toJson())).toList();
var abc = await prefs.setStringList(GlobalConsts.bookmark, encodedList); await prefs.setStringList(GlobalConsts.bookmark, encodedList);
} }
} }

@ -11,7 +11,7 @@ class ContentInfoModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<ContentInfoDataModel>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new ContentInfoDataModel.fromJson(v)); data.add(new ContentInfoDataModel.fromJson(v));
}); });

@ -11,7 +11,7 @@ class CountryModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<CountryModelData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new CountryModelData.fromJson(v)); data.add(new CountryModelData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class DiscussionModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<DiscussionModelData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new DiscussionModelData.fromJson(v)); data.add(new DiscussionModelData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class MemberModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<MemberDataModel>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new MemberDataModel.fromJson(v)); data.add(new MemberDataModel.fromJson(v));
}); });

@ -11,7 +11,7 @@ class NavigationModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<NavigationDataModel>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new NavigationDataModel.fromJson(v)); data.add(new NavigationDataModel.fromJson(v));
}); });

@ -11,7 +11,7 @@ class QuickLinksModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<QuickLinksData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new QuickLinksData.fromJson(v)); data.add(new QuickLinksData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class SurahModel {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<SurahModelData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new SurahModelData.fromJson(v)); data.add(new SurahModelData.fromJson(v));
}); });

@ -11,7 +11,7 @@ class TangheemType {
statusCode = json['statusCode']; statusCode = json['statusCode'];
message = json['message']; message = json['message'];
if (json['data'] != null) { if (json['data'] != null) {
data = new List<TangheemTypeData>(); data = [];
json['data'].forEach((v) { json['data'].forEach((v) {
data.add(new TangheemTypeData.fromJson(v)); data.add(new TangheemTypeData.fromJson(v));
}); });

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

@ -36,11 +36,9 @@ class _BookmarkScreenState extends State<BookmarkScreen> {
getBookMark(); getBookMark();
} }
void handleSlideAnimationChanged(Animation<double> slideAnimation) { void handleSlideAnimationChanged(Animation<double> slideAnimation) {}
}
void handleSlideIsOpenChanged(bool isOpen) { void handleSlideIsOpenChanged(bool isOpen) {}
}
void getBookMark() async { void getBookMark() async {
Utils.showLoading(context); Utils.showLoading(context);

@ -36,7 +36,7 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
Utils.showToast("شكرا لك على مراسلتنا ، نحن نقدر كلماتك."); Utils.showToast("شكرا لك على مراسلتنا ، نحن نقدر كلماتك.");
Utils.hideLoading(context); Utils.hideLoading(context);
Navigator.pop(context); Navigator.pop(context);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
} }

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:tangheem/api/tangheem_user_api_client.dart'; import 'package:tangheem/api/tangheem_user_api_client.dart';
@ -31,7 +30,7 @@ class _ContentInfoScreenState extends State<ContentInfoScreen> {
try { try {
var membersData = await TangheemUserApiClient().getContentInfo(widget.contentId); var membersData = await TangheemUserApiClient().getContentInfo(widget.contentId);
contentList = membersData?.data ?? []; contentList = membersData?.data ?? [];
} catch (ex, tr) { } catch (ex) {
contentList = []; contentList = [];
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {

@ -37,7 +37,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
try { try {
await UserApiClient().forgotPassword(email); await UserApiClient().forgotPassword(email);
Utils.showToast("تم إرسال OTP"); Utils.showToast("تم إرسال OTP");
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
return; return;
@ -51,7 +51,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
await UserApiClient().verifyOTP(email, otp); await UserApiClient().verifyOTP(email, otp);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
return; return;
@ -66,7 +66,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
await UserApiClient().updatePassword(email, otp, password); await UserApiClient().updatePassword(email, otp, password);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
return; return;

@ -53,7 +53,7 @@ class _HomeScreenState extends State<HomeScreen> {
TangheemUserApiClient().addStatistics(1); TangheemUserApiClient().addStatistics(1);
setState(() {}); setState(() {});
Utils.hideLoading(context); Utils.hideLoading(context);
} catch (ex, tr) { } catch (ex) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(ex, null); Utils.handleException(ex, null);
} }
@ -63,7 +63,7 @@ class _HomeScreenState extends State<HomeScreen> {
try { try {
_tangheemType = await TangheemUserApiClient().getTangheemType(); _tangheemType = await TangheemUserApiClient().getTangheemType();
_tangheemListNotifier.value = _tangheemType?.data?.where((element) => element.isActive)?.toList()?.map((element) => element.tangheemTypeName)?.toList() ?? []; _tangheemListNotifier.value = _tangheemType?.data?.where((element) => element.isActive)?.toList()?.map((element) => element.tangheemTypeName)?.toList() ?? [];
} catch (ex, tr) {} } catch (ex) {}
} }
@override @override

@ -69,7 +69,7 @@ class _LoginScreenState extends State<LoginScreen> {
await prefs.setString(GlobalConsts.password, _password); await prefs.setString(GlobalConsts.password, _password);
Utils.hideLoading(context); Utils.hideLoading(context);
Navigator.pop(context); Navigator.pop(context);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
} }

@ -32,7 +32,7 @@ class _MemberScreenState extends State<MemberScreen> {
var membersData = await TangheemUserApiClient().getMembers(); var membersData = await TangheemUserApiClient().getMembers();
membersList = membersData?.data ?? []; membersList = membersData?.data ?? [];
membersList.sort((a, b) => a.orderNo.compareTo(b.orderNo)); membersList.sort((a, b) => a.orderNo.compareTo(b.orderNo));
} catch (ex, tr) { } catch (ex) {
membersList = []; membersList = [];
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {

@ -79,7 +79,7 @@ class _QuranScreenState extends State<QuranScreen> {
_surahList = _surahModel.data.map((element) => element.nameAR).toList(); _surahList = _surahModel.data.map((element) => element.nameAR).toList();
_currentPage = widget.bookmark?.page ?? 1; _currentPage = widget.bookmark?.page ?? 1;
Utils.hideLoading(context); Utils.hideLoading(context);
} catch (ex, tr) { } catch (ex) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(ex, null); Utils.handleException(ex, null);
} }
@ -115,7 +115,7 @@ class _QuranScreenState extends State<QuranScreen> {
try { try {
_ayatTangheemTypeMapped = await TangheemUserApiClient().getTangheemBySurah(_selectedSurah + 1); _ayatTangheemTypeMapped = await TangheemUserApiClient().getTangheemBySurah(_selectedSurah + 1);
_tangheemWords = _ayatTangheemTypeMapped?.data?.map((e) => e.highlightText)?.toList() ?? []; _tangheemWords = _ayatTangheemTypeMapped?.data?.map((e) => e.highlightText)?.toList() ?? [];
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally {} } finally {}
setState(() {}); setState(() {});
@ -125,7 +125,7 @@ class _QuranScreenState extends State<QuranScreen> {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
_ayaModel = await TangheemUserApiClient().getAyaByFilter(_selectedSurah + 1, _fromAyaList[_selectedFromAya], _toAyaList[_selectedToAya]); _ayaModel = await TangheemUserApiClient().getAyaByFilter(_selectedSurah + 1, _fromAyaList[_selectedFromAya], _toAyaList[_selectedToAya]);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {
Utils.hideLoading(context); Utils.hideLoading(context);
@ -139,7 +139,7 @@ class _QuranScreenState extends State<QuranScreen> {
_ayaModel = await TangheemUserApiClient().getQuranByPageNo(_currentPage); _ayaModel = await TangheemUserApiClient().getQuranByPageNo(_currentPage);
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
} }
@ -234,7 +234,7 @@ class _QuranScreenState extends State<QuranScreen> {
child: CommonDropDownButton(_selectedFromAya, hintText: "من الاية", list: _fromAyaList.map((e) => "من الاية" + " $e").toList(), onSelect: (index) { child: CommonDropDownButton(_selectedFromAya, hintText: "من الاية", list: _fromAyaList.map((e) => "من الاية" + " $e").toList(), onSelect: (index) {
if (_selectedFromAya != index) { if (_selectedFromAya != index) {
_selectedFromAya = index; _selectedFromAya = index;
var abc = filteredAyahList.indexOf(_selectedFromAya); filteredAyahList.indexOf(_selectedFromAya);
_toAyaList = filteredAyahList.getRange(_selectedFromAya + 1, filteredAyahList.length)?.toList() ?? []; _toAyaList = filteredAyahList.getRange(_selectedFromAya + 1, filteredAyahList.length)?.toList() ?? [];
setState(() {}); setState(() {});
} }

@ -47,7 +47,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
_selectedCountry = _countryModel.data.first; _selectedCountry = _countryModel.data.first;
} }
setState(() {}); setState(() {});
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {
Utils.hideLoading(context); Utils.hideLoading(context);
@ -61,7 +61,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
Utils.showToast("تسجيل بنجاح"); Utils.showToast("تسجيل بنجاح");
Utils.hideLoading(context); Utils.hideLoading(context);
Navigator.pop(context); Navigator.pop(context);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
} }

@ -21,6 +21,7 @@ import 'login_screen.dart';
class TangheemDetailScreen extends StatefulWidget { class TangheemDetailScreen extends StatefulWidget {
static const String routeName = "/tangheem_detail"; static const String routeName = "/tangheem_detail";
final List<AyatTangheemTypeMappedData> ayatTangheemTypeMappedDataList; final List<AyatTangheemTypeMappedData> ayatTangheemTypeMappedDataList;
TangheemDetailScreen({Key key, this.ayatTangheemTypeMappedDataList}) : super(key: key); TangheemDetailScreen({Key key, this.ayatTangheemTypeMappedDataList}) : super(key: key);
@override @override
@ -82,7 +83,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
_discussionModel = await TangheemUserApiClient().getDiscussionByTangheemID(_discussionPage, _ayatTangheemTypeMappedFirstData.ayaTangheemTypeId); _discussionModel = await TangheemUserApiClient().getDiscussionByTangheemID(_discussionPage, _ayatTangheemTypeMappedFirstData.ayaTangheemTypeId);
Utils.hideLoading(context); Utils.hideLoading(context);
setState(() {}); setState(() {});
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
} }
@ -95,7 +96,7 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
Utils.showToast("تم إرسال التعليق ، سيكون مرئيًا بمجرد موافقة المسؤول عليه"); Utils.showToast("تم إرسال التعليق ، سيكون مرئيًا بمجرد موافقة المسؤول عليه");
Utils.hideLoading(context); Utils.hideLoading(context);
Navigator.pop(context); Navigator.pop(context);
} catch (ex, tr) { } catch (ex) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
} }

@ -38,7 +38,7 @@ class _TangheemScreenState extends State<TangheemScreen> {
try { try {
_ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah?.surahID, widget.tangheemTypeName, widget.tangheemQuery); _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah?.surahID, widget.tangheemTypeName, widget.tangheemQuery);
_dataList = _ayatTangheemTypeMapped?.data ?? []; _dataList = _ayatTangheemTypeMapped?.data ?? [];
} catch (ex, tr) { } catch (ex) {
_dataList = []; _dataList = [];
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {

@ -48,9 +48,9 @@ class TextHighLightWidget extends StatelessWidget {
} }
} }
List<TextSpan> _spans = List(); List<TextSpan> _spans = [];
int _start = 0; int _start = 0;
List<String> _lowerCaseHighlights = List(); List<String> _lowerCaseHighlights = [];
highlights.forEach((element) { highlights.forEach((element) {
_lowerCaseHighlights.add(element.toLowerCase()); _lowerCaseHighlights.add(element.toLowerCase());
@ -67,7 +67,7 @@ class TextHighLightWidget extends StatelessWidget {
} }
if (_highlightsMap.isNotEmpty) { if (_highlightsMap.isNotEmpty) {
List<int> _indexes = List(); List<int> _indexes = [];
_highlightsMap.forEach((key, value) => _indexes.add(key)); _highlightsMap.forEach((key, value) => _indexes.add(key));
int _currentIndex = _indexes.reduce(min); int _currentIndex = _indexes.reduce(min);

Loading…
Cancel
Save