Skip to content

Instantly share code, notes, and snippets.

View sahildev001's full-sized avatar
🎯
Focusing

sahil kumar sahildev001

🎯
Focusing
View GitHub Profile
@sahildev001
sahildev001 / injector.dart
Created January 24, 2024 10:45
caeate interceptor in flutter
class Injector {
static final Injector _singleton = new Injector._internal();
static final dio = Dio();
factory Injector() {
return _singleton;
}
Injector._internal();
RestApiClient getClient() {
// dio.options.connectTimeout = 10000;
// dio.options.receiveTimeout = 3000;
@sahildev001
sahildev001 / flutter router
Created January 24, 2024 10:39
create routs in flutter
static const String routeName = '/LogInScreen';
static Route route() {
return PageRouteBuilder(
settings: RouteSettings(name: routeName),
pageBuilder: (context, animation, secondaryAnimation) => LogInScreen(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(1.0, 0.0);
@sahildev001
sahildev001 / UseMarkerGenetarorFromWidget.dart
Created March 29, 2023 11:48
This Will generate markers from widget.
// Use this class as
MapMarkerGeneratorFromWidget(CommonMethods.customNumberMarker("${i+1}"), (bitmaps) {
setState(() {
BitmapDescriptor icon = BitmapDescriptor.fromBytes(bitmaps);
dev.log("$TAG icon :-- $icon");
if(updatedOrders[i].addressDelivery?.latLng != null) {
LatLng markerLatLng = LatLng(
(updatedOrders[i].addressDelivery?.latLng?.latitude ?? 0.0)
@sahildev001
sahildev001 / gradientsliderbutton.dart
Created March 29, 2023 11:24
This class create Gradient slider button in dart.
import 'package:flutter/material.dart';
class GradientSliderButton extends StatefulWidget {
/// the width of the SlidableButton
final double width;
/// the height of the SlidableButton
final double height;
/// the size of the draggable icon
@sahildev001
sahildev001 / CreateListFileFromDirectory.kt
Created March 29, 2023 11:21
Kotlin function to make list from directory files
fun listFilesInDirectory(directoryPath: String): List<File> {
val directory = File(directoryPath)
return directory.listFiles()?.toList() ?: emptyList()
}
//--- Implement Read text from file
fun readTextFromFile(filePath: String): String? {
val file = File(filePath)
if (!file.exists() || !file.isFile) {
return null
@sahildev001
sahildev001 / shortestpath.dart
Created March 29, 2023 11:14
Implement Shortest path from map markers positions and short orders
class Order {
String? uid;
String? orderNo;
String? email;
String? phoneNumber;
String? firstName;
String? lastName;
String? numberOfAdults;
String? numberOfChildren;
String? table;
@sahildev001
sahildev001 / lowercase_file_name.sh
Created August 13, 2022 04:23
convert file names from uppercase to lowecase
#!/bin/sh
# lowerit
# convert all file names in the current directory to lower case
# only operates on plain files--does not change the name of directories
# will ask for verification before overwriting an existing file
for x in `ls`
do
if [ ! -f $x ]; then
continue
fi
@sahildev001
sahildev001 / remove_spaces_from_file_name.sh
Last active March 29, 2023 13:04
Shell script for remove whitespace from file name
find . -depth -name '* *' | while read fname
do
new_fname=`echo $fname | tr " " "_"`
if [ -e $new_fname ]
then
echo "File $new_fname already exists. Not replacing $fname"
else
@sahildev001
sahildev001 / drawable_to_uri.md
Created June 16, 2022 10:08
get image uri from drawable android
private fun changedrawabletoUri(resourceId :Int):Uri{
        val imageUri = (Uri.Builder())
                .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
            .authority(resources.getResourcePackageName(resourceId))
            .appendPath(resources.getResourceTypeName(resourceId))
            .appendPath(resources.getResourceEntryName(resourceId))
            .build()
        return imageUri
 }
@sahildev001
sahildev001 / country code list.txt
Last active March 29, 2023 12:53
kotlin country code arrylist java country code array list
countries.add(Country("af", "+93", "Afghanistan"))
countries.add(Country("al", "+355", "Albania"))
countries.add(Country("dz", "+213", "Algeria"))
countries.add(Country("ad", "+376", "Andorra"))
countries.add(Country("ao", "+244", "Angola"))
countries.add(Country("ai", "+1", "Anguilla"))
countries.add(Country("aq", "+672", "Antarctica"))
countries.add(Country("ag", "+1", "Antigua and Barbuda"))
countries.add(Country("ar", "+54", "Argentina"))
countries.add(Country("am", "+374", "Armenia"))