Skip to content

Instantly share code, notes, and snippets.

View khkred's full-sized avatar

Harish Kunchala khkred

  • GotInfo
  • Los Angeles
  • 01:05 (UTC -07:00)
  • LinkedIn in/khkred
View GitHub Profile
@khkred
khkred / .gitignore
Last active May 7, 2024 04:25
Comprehensive .gitignore File for Flutter Projects: Includes entries to safely ignore Firebase configuration files across all supported platforms.
# Do not remove or rename entries in this file, only add new ones
# See https://github.com/flutter/flutter/issues/128635 for more context.
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
void main() {
print('Start of Task A');
taskA();
print('End of Task A\n');
print('Start of Task B');
taskB();
print('End of Task B');
}
import 'package:geolocator/geolocator.dart';
class GetLocationState {
final Position? position;
final LocationPermission permission;
GetLocationState({
this.position,
required this.permission,
});
@khkred
khkred / location_state.dart
Created April 27, 2024 00:16
Location State to check service and permission state
import 'package:geolocator/geolocator.dart';
sealed class LocationState {
final bool isServiceEnabled;
final LocationPermission permissionState;
const LocationState(
{required this.isServiceEnabled, required this.permissionState});
}
@khkred
khkred / Info.plist
Created April 26, 2024 20:48
My Info.plist with location permissions added
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- =============START OF LOCATION PERMISSIONS============= -->
<!-- Here we are adding the location permissions, since this is production we are adding multiple permissions and their descriptions -->
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We use your location data to send you notifications when you check in to certain places to enhance your experience in our app.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Our app may also use your location in the background to send you timely notifications about important community alerts and updates relevant to your area, even when you're not actively using the app.</string>
@khkred
khkred / AndroidManifest.xml
Created April 26, 2024 20:33
After adding the final permission inside the manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:label="flutter_location_permissions_handling"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
/** For this example, assume that
* public static final int GENDER_MALE = 0;
* public static final int GENDER_FEMALE = 1;
**/
String[] projection = { PetEntry.COLUMN_PET_BREED,
PetEntry.COLUMN_PET_WEIGHT };
String selection = PetEntry.COLUMN_PET_GENDER + “=?”;
String selectionArgs = new String[] { PetEntry.GENDER_FEMALE };
@khkred
khkred / WeatherContract.java
Created April 8, 2021 09:31
Full class to show to how to create a contract
package com.example.android.sunshine.app.data;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;
import android.text.format.Time;
/**
public final class StoreContract {
public static abstract class HeadphoneEntry implements BaseColumns {
public static final String TABLE_NAME = "headphones";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_PRICE = "price";
public static final String COLUMN_STYLE = "style";
public static final String COLUMN_IN_STOCK = "in_stock";
public static final String COLUMN_DESCRIPTION = "description";
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingEnd="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingStart="16dp">
<TextView