Skip to content

Commit 70dd6ee

Browse files
authored
changed base url
Master
2 parents c075f94 + e1a7f94 commit 70dd6ee

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

lib/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_dotenv/flutter_dotenv.dart';
23
import 'package:hadithsearcher/views/about_view.dart';
34
import 'package:hadithsearcher/views/favourites_view.dart';
45
import 'package:hadithsearcher/views/search_view.dart';
@@ -13,6 +14,7 @@ void main() async {
1314
DatabaseHelper sqlDb = DatabaseHelper();
1415
await sqlDb.initialDb();
1516
final theme = await sqlDb.getTheme();
17+
await dotenv.load(fileName: ".env");
1618
runApp(HomePage(theme: theme));
1719
}
1820

lib/views/favourites_view.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
3+
import 'package:flutter_animate/flutter_animate.dart';
4+
import 'package:flutter_dotenv/flutter_dotenv.dart';
35
import 'package:hadithsearcher/utilities/show_navigation_drawer.dart';
46
import 'package:hadithsearcher/views/similar_hadith_view.dart';
57
import '../constants/routes.dart';
@@ -19,6 +21,8 @@ class FavouritesView extends StatefulWidget {
1921
class _FavouritesViewState extends State<FavouritesView> {
2022
DatabaseHelper sqlDb = DatabaseHelper();
2123

24+
String hadithApiBaseUrl = dotenv.env['HADITH_API_BASE_URL']!;
25+
2226
bool _isLoading = false;
2327

2428
bool _isEmpty = true;
@@ -249,7 +253,7 @@ class _FavouritesViewState extends State<FavouritesView> {
249253
'hasSharhMetadata'] ==
250254
true) {
251255
var url = Uri.parse(
252-
"https://dorar-hadith-api.cyclic.cloud/v1/site/sharh/${hadith['sharhMetadata']['id']}");
256+
"$hadithApiBaseUrl/v1/site/sharh/${hadith['sharhMetadata']['id']}");
253257
var response = await http
254258
.get(url)
255259
.timeout(const Duration(
@@ -427,7 +431,7 @@ class _FavouritesViewState extends State<FavouritesView> {
427431
),
428432
);
429433
},
430-
),
434+
).animate().fade(duration: 200.ms),
431435
),
432436
],
433437
),

lib/views/search_view.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_animate/flutter_animate.dart';
3+
import 'package:flutter_dotenv/flutter_dotenv.dart';
34
import 'package:hadithsearcher/db/database.dart';
45
import 'package:hadithsearcher/views/similar_hadith_view.dart';
56
import 'package:http/http.dart' as http;
@@ -20,6 +21,8 @@ class SearchView extends StatefulWidget {
2021
class _SearchViewState extends State<SearchView> {
2122
DatabaseHelper sqlDb = DatabaseHelper();
2223

24+
String hadithApiBaseUrl = dotenv.env['HADITH_API_BASE_URL']!;
25+
2326
bool _isLoading = false;
2427

2528
bool _isEmpty = true;
@@ -180,7 +183,7 @@ class _SearchViewState extends State<SearchView> {
180183
searchBook = '96';
181184
}
182185
var url = Uri.parse(
183-
'https://dorar-hadith-api.cyclic.cloud/v1/site/hadith/search?value=$searchKeyword&page=$searchPagaNumber&st=$searchWay&t=$searchRange&d[]=$searchGrade&m[]=$searchMohdith&s[]=$searchBook$searchExcludedWords');
186+
'$hadithApiBaseUrl/v1/site/hadith/search?value=$searchKeyword&page=$searchPagaNumber&st=$searchWay&t=$searchRange&d[]=$searchGrade&m[]=$searchMohdith&s[]=$searchBook$searchExcludedWords');
184187
var response = await http.get(url).timeout(const Duration(seconds: 24));
185188
var decodedBody = utf8.decode(response.bodyBytes);
186189
var jsonResponse = json.decode(decodedBody);
@@ -984,7 +987,7 @@ class _SearchViewState extends State<SearchView> {
984987
'hasSharhMetadata'] ==
985988
true) {
986989
var url = Uri.parse(
987-
"https://dorar-hadith-api.cyclic.cloud/v1/site/sharh/${hadith['sharhMetadata']['id']}");
990+
"$hadithApiBaseUrl/v1/site/sharh/${hadith['sharhMetadata']['id']}");
988991
var response = await http
989992
.get(url)
990993
.timeout(
@@ -1188,9 +1191,9 @@ class _SearchViewState extends State<SearchView> {
11881191
),
11891192
],
11901193
),
1191-
).animate().fade(duration: 200.ms);
1194+
);
11921195
},
1193-
),
1196+
).animate().fade(duration: 200.ms),
11941197
),
11951198
_isEmpty
11961199
? const Text('')

lib/views/similar_hadith_view.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:flutter/material.dart';
2+
import 'package:flutter_animate/flutter_animate.dart';
3+
import 'package:flutter_dotenv/flutter_dotenv.dart';
24
import 'package:http/http.dart' as http;
35
import 'dart:async';
46
import 'dart:convert';
@@ -17,6 +19,8 @@ class SimilarHadithView extends StatefulWidget {
1719
class _SimilarHadithViewState extends State<SimilarHadithView> {
1820
DatabaseHelper sqlDb = DatabaseHelper();
1921

22+
String hadithApiBaseUrl = dotenv.env['HADITH_API_BASE_URL']!;
23+
2024
bool _isLoading = false;
2125

2226
bool _showBackToTopButton = false;
@@ -88,8 +92,7 @@ class _SimilarHadithViewState extends State<SimilarHadithView> {
8892
);
8993
}
9094
try {
91-
var url = Uri.parse(
92-
'https://dorar-hadith-api.cyclic.cloud/v1/site/hadith/similar/$hadithId');
95+
var url = Uri.parse('$hadithApiBaseUrl/v1/site/hadith/similar/$hadithId');
9396
var response = await http.get(url).timeout(const Duration(seconds: 24));
9497
var decodedBody = utf8.decode(response.bodyBytes);
9598
var jsonResponse = json.decode(decodedBody);
@@ -266,7 +269,7 @@ class _SimilarHadithViewState extends State<SimilarHadithView> {
266269
if (hadith['hasSharhMetadata'] ==
267270
true) {
268271
var url = Uri.parse(
269-
"https://dorar-hadith-api.cyclic.cloud/v1/site/sharh/${hadith['sharhMetadata']['id']}");
272+
"$hadithApiBaseUrl/v1/site/sharh/${hadith['sharhMetadata']['id']}");
270273
var response = await http
271274
.get(url)
272275
.timeout(
@@ -417,7 +420,7 @@ class _SimilarHadithViewState extends State<SimilarHadithView> {
417420
),
418421
);
419422
},
420-
),
423+
).animate().fade(duration: 200.ms),
421424
),
422425
],
423426
),

pubspec.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ packages:
126126
url: "https://pub.dev"
127127
source: hosted
128128
version: "4.2.0+1"
129+
flutter_dotenv:
130+
dependency: "direct main"
131+
description:
132+
name: flutter_dotenv
133+
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
134+
url: "https://pub.dev"
135+
source: hosted
136+
version: "5.1.0"
129137
flutter_launcher_icons:
130138
dependency: "direct main"
131139
description:

pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies:
4646
in_app_update: ^4.1.4
4747
flutter_launcher_icons: ^0.13.1
4848
flutter_animate: ^4.2.0+1
49+
flutter_dotenv: ^5.1.0
4950

5051
flutter_native_splash:
5152
color: "#ffffff"
@@ -83,6 +84,7 @@ flutter:
8384
# To add assets to your application, add an assets section, like this:
8485
assets:
8586
- assets/icons/logo.png
87+
- .env
8688
# - images/a_dot_ham.jpeg
8789

8890
# An image asset can refer to one or more resolution-specific "variants", see

0 commit comments

Comments
 (0)