Skip to content

Instantly share code, notes, and snippets.

View dhruvanbhalara's full-sized avatar
👨‍💻
Focusing

Dhruvan Bhalara dhruvanbhalara

👨‍💻
Focusing
View GitHub Profile
@dhruvanbhalara
dhruvanbhalara / Makefile
Last active October 4, 2025 10:01
Makefile for flutter projects
# Makefile for Flutter project
# Includes targets for cleaning, dependencies, code generation (models via build_runner and localization via intl_utils), and building.
.PHONY: clean pubget generate-models generate-localization generate build-android build-ios build-apk build-aab run-android run-ios
# Clean the project
clean:
@echo "Cleaning Flutter project..."
flutter clean
class DashedBorder extends BoxBorder {
const DashedBorder({
this.top = BorderSide.none,
this.right = BorderSide.none,
this.bottom = BorderSide.none,
this.left = BorderSide.none,
this.dashLength = 5.0,
this.dashGap = 3.0,
});
import 'dart:async';
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
class MyConnectivity {
MyConnectivity._();
static final _instance = MyConnectivity._();
static MyConnectivity get instance => _instance;
@dhruvanbhalara
dhruvanbhalara / android.rb
Created October 9, 2024 07:57 — forked from jtmuller5/android.rb
Android and iOS Fastfiles for Flutter App
# android/fastlane/Fastfile
update_fastlane
default_platform(:android)
platform :android do
lane :bump_version_code do
versionCode = File.read("metadata/versionCode").to_i
versionCode = versionCode + 1
import "package:flutter/material.dart";
import "package:google_fonts/google_fonts.dart";
import "memory_usage.dart" if (dart.library.html) 'memory_usage_web.dart';
import "dart:async";
const showMemMonitor = bool.fromEnvironment("SHOW_MEM_MONITOR");
class MemoryMonitor extends StatefulWidget {
const MemoryMonitor({super.key});
@dhruvanbhalara
dhruvanbhalara / fluttercleanrecursive.sh
Created April 18, 2024 06:56 — forked from jeroen-meijer/fluttercleanrecursive.sh
Flutter Clean Recursive - Clear up space on your hard drive by cleaning your Flutter projects. This script searches for all Flutter projects in this directory and all subdirectories and runs 'flutter clean'. Note: may take a long time for folders with large amounts of projects.
#!/bin/sh
# To run, download the script or copy the code to a '.sh' file (for example 'fluttercleanrecursive.sh') and run like any other script:
# sh ./fluttercleanrecursive.sh
# or
# sudo sh fluttercleanrecursive.sh
echo "Flutter Clean Recursive (by jeroen-meijer on GitHub Gist)"
echo "Looking for projects... (may take a while)"

Location Service

you can just create an intsance/(you can register this with get_it/ioc contiainer) for easy usage

import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:your_project_folder/permission_manager.dart';
@dhruvanbhalara
dhruvanbhalara / flutter_build_analyze_cmd.md
Last active March 15, 2024 12:27
GIST to analyze build size of flutter build

Flutter Doc

App Bundle

flutter build appbundle --target-platform android-arm64 --analyze-size

Apk

flutter build apk --target-platform android-arm64 --analyze-size
@dhruvanbhalara
dhruvanbhalara / find_loc.md
Created March 13, 2024 08:16
Find line of code in particular git repository for flutter project

MacOS

git ls-files '*.dart' | grep -vE 'mapper|mocks|test|g.dart' | xargs wc -l
@dhruvanbhalara
dhruvanbhalara / git_remove_local_branches.md
Last active January 13, 2024 14:07
Git remove local branches that are not present on server

Original Answer

Windows

git checkout main; git remote update origin --prune; git branch -vv | Select-String -Pattern ": gone]" | % { $_.toString().Trim().Split(" ")[0]} | % {git branch -D $_}

Mac

for b in $(git for-each-ref --format='%(if:equals=[gone])%(upstream:track)%(then)%(refname:short)%(end)' refs/heads); do git branch -D $b; done