Skip to content

Commit f249ae8

Browse files
committed
Bug Fix
1 parent 803abd7 commit f249ae8

File tree

6 files changed

+66
-14
lines changed

6 files changed

+66
-14
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Flutter Core
22

3-
Projelerinizde kullanabileceğiniz çekirdek katman. [ Update: 02.07.2022 ]
3+
Projelerinizde kullanabileceğiniz çekirdek katman. [ Update: 27.08.2022 ]
44

55
#
66

@@ -44,6 +44,7 @@ NOT: Gerekli kütüphaneler yüklü değilse hata alabilirsiniz.
4444
- Map Service
4545
- google_maps_flutter
4646
- geolocator
47+
- geocoding
4748
- Other
4849
- path_provider
4950
- awesome_notifications
Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
1+
// ignore_for_file: empty_catches
2+
3+
import 'dart:io';
4+
15
import 'package:hive_flutter/hive_flutter.dart';
6+
import 'package:path_provider/path_provider.dart';
27

38
final cacheService = CacheService();
49

510
class CacheService {
611
late Box box;
12+
final String cacheName = "project_name_cache";
713

814
Future init() async {
9-
await Hive.initFlutter();
10-
box = await Hive.openBox('cache');
15+
final dir = await getDir();
16+
await Hive.initFlutter(dir.path);
17+
box = await openBox(dir);
18+
}
19+
20+
Future<Box> openBox(Directory dir) async {
21+
return await Hive.openBox(cacheName, path: dir.path);
22+
}
23+
24+
Future deleteBox() async {
25+
try {
26+
final dir = await getDir();
27+
await Hive.deleteBoxFromDisk(cacheName);
28+
box = await openBox(dir);
29+
} catch (e) {}
30+
}
31+
32+
Future<Directory> getDir() async {
33+
final appDocumentDirectory = await getApplicationDocumentsDirectory();
34+
return Directory('${appDocumentDirectory.path}/database');
1135
}
1236
}

lib/core/map_services/location_service.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Documents and Integration
22
// *https://pub.dev/packages/geolocator
3+
// https://pub.dev/packages/geocoding
34

45
import 'package:geolocator/geolocator.dart';
6+
import 'package:geocoding/geocoding.dart';
57

68
final locationService = LocationService();
79

@@ -31,4 +33,30 @@ class LocationService {
3133
return null;
3234
}
3335
}
36+
37+
Future<List<Placemark>?> getAddressFromLatLng(
38+
double? lat, double? lng) async {
39+
if (lat == null || lng == null) {
40+
return null;
41+
}
42+
43+
try {
44+
var placeMarkList = await placemarkFromCoordinates(lat, lng);
45+
return placeMarkList;
46+
} catch (e) {
47+
return null;
48+
}
49+
}
50+
51+
Future<List<Location>?> getLatLngFromAddress(String? address) async {
52+
if (address == null) {
53+
return null;
54+
}
55+
try {
56+
var locationList = await locationFromAddress(address);
57+
return locationList;
58+
} catch (e) {
59+
return null;
60+
}
61+
}
3462
}

lib/core/media_services/audio_service.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class AudioService {
8181
required String path,
8282
Function()? finishCallback,
8383
Function()? playCallback,
84-
double? pitch,
84+
// double? pitch,
8585
}) async {
8686
this.path = path;
8787

@@ -94,7 +94,7 @@ class AudioService {
9494
break;
9595
}
9696
final _duration = await player.load();
97-
await player.setPitch(pitch ?? 1);
97+
// await player.setPitch(pitch ?? 1);
9898
player.play();
9999
playCallback?.call();
100100
player.positionStream.listen((event) {
@@ -109,16 +109,16 @@ class AudioService {
109109
Future<void> stopAudio() async {
110110
await player.stop();
111111
player.seek(Duration.zero);
112-
await player.setPitch(1);
112+
// await player.setPitch(1);
113113
}
114114

115115
Future<void> pauseAudio() async {
116116
await player.pause();
117-
await player.setPitch(1);
117+
// await player.setPitch(1);
118118
}
119119

120120
Future<void> resumeAudio({Function()? callback, double? pitch}) async {
121-
await player.setPitch(pitch ?? 1);
121+
// await player.setPitch(pitch ?? 1);
122122
player.play();
123123
}
124124

lib/core/qr_service/qr_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// android/app/build.gradle
66
// minSdkVersion 20
77
// android/build.gradle
8-
// ext.kotlin_version = '1.5.10'
8+
// ext.kotlin_version = '1.5.10' // update last version
99
// classpath 'com.android.tools.build:gradle:4.2.0'
1010
// android/gradle/wrapper/gradle-wrapper.properties
1111
// distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip

lib/core/utils/mixins/context_mixin.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import 'package:flutter/material.dart';
22

33
import '../../../main.dart';
44

5+
final screenSizeNotifier = ValueNotifier(Size.infinite);
6+
57
mixin ContextMixin {
68
BuildContext get currentContext => navigatorKey.currentContext!;
7-
MediaQueryData get mediaQuery => MediaQuery.of(currentContext);
89
ThemeData get theme => Theme.of(currentContext);
910

10-
double dynamicWidth(double value) =>
11-
MediaQuery.of(currentContext).size.width * value;
12-
double dynamicHeight(double value) =>
13-
MediaQuery.of(currentContext).size.height * value;
11+
double dynamicWidth(double value) => screenSizeNotifier.value.width * value;
12+
double dynamicHeight(double value) => screenSizeNotifier.value.height * value;
1413
}

0 commit comments

Comments
 (0)