This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.SharedPreferences; | |
import com.google.gson.Gson; | |
public class ComplexPreferences { | |
private static ComplexPreferences complexPreferences; | |
private Context context; | |
private SharedPreferences preferences; | |
private SharedPreferences.Editor editor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String calculateDistance(double lat1, double lon1, double lat2, double lon2) { | |
var p = 0.017453292519943295; | |
var c = cos; | |
var a = 0.5 - c((lat2 - lat1) * p) / 2 + c(lat1 * p) * c(lat2 * p) * (1 - c((lon2 - lon1) * p)) / 2; | |
double distance = 12742 * asin(sqrt(a)); | |
String strDistance = distance.toStringAsFixed(2); | |
return strDistance + " km"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool isValidEmail(String email) { | |
return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); | |
} | |
static bool isValidName(String name) { | |
return !name.contains(RegExp(r"[0-9!@#$%^&*()_+\-=\[\]{};':\\|,.<>\/?]")); | |
} | |
static bool isSpecialCharacter(String name) { | |
return RegExp(r"[!@#$%^&*()_+\-=\[\]{};':\\|,.<>\/?]").hasMatch(name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:rxdart/rxdart.dart'; | |
class SampleBloc { | |
static final SampleBloc _singletonBloc = new SampleBloc._internal(); | |
final sampleBlocObj = BehaviorSubject<int>(); | |
factory SampleBloc() { | |
return _singletonBloc; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static LatLngBounds getBounds(List<LatLng> polylineCoordinates) { | |
double x0, x1, y0, y1; | |
for (LatLng latLng in polylineCoordinates) { | |
if (x0 == null) { | |
x0 = x1 = latLng.latitude; | |
y0 = y1 = latLng.longitude; | |
} else { | |
if (latLng.latitude > x1) x1 = latLng.latitude; | |
if (latLng.latitude < x0) x0 = latLng.latitude; | |
if (latLng.longitude > y1) y1 = latLng.longitude; |