Skip to content

Instantly share code, notes, and snippets.

@callmephil
callmephil / base_firestore_service.dart
Created April 21, 2025 07:05
Base Firestore Service
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/foundation.dart';
/// Base service class for handling CRUD operations with Firestore
abstract class BaseFirestoreService<T> {
/// Constructor
BaseFirestoreService(String collectionPath) {
_collection = _firestore.collection(collectionPath);
}
@callmephil
callmephil / fireworks.dart
Last active April 5, 2025 11:34
flutter fireworks (gemini)
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'dart:math';
import 'dart:async';
import 'dart:ui' as ui;
import 'dart:typed_data';
const bool kDebugMode = false;
const int kLaunchIntervalBaseMs = 400;
@callmephil
callmephil / main.dart
Created March 7, 2025 09:18
Go like error handling in Dart
typedef AsyncErrorRecord = ({Object error, StackTrace? stackTrace});
abstract class Async<T> {
const Async();
static Future<(AsyncErrorRecord? error, T? result)> guard<T>(
Future<T> Function() future,
) async {
try {
final result = await future();
@callmephil
callmephil / gradient_border_progress.dart
Last active February 28, 2025 14:37
bi-directional gradient border progress on hover
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
@callmephil
callmephil / animated_shadermask_gradient.dart
Created February 26, 2025 18:13
AnimatedBuilder + ShaderMask and LinearGradient
import 'package:flutter/material.dart';
import 'dart:ui';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@callmephil
callmephil / quotation.html
Last active February 26, 2025 14:07
Quotation generator: Generate a quotation and allow you to download it as pdf.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Quotation</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
@callmephil
callmephil / linkedin_scrapper.js
Created February 26, 2025 12:40
linkedIn and threads scrapper
(function () {
const Selectors = {
COMMENTER_NAME: ".comments-comment-meta__description-title",
COMMENT_TEXT: ".comments-comment-item__main-content",
LIKES_COUNT: ".comments-comment-social-bar__reactions-count--cr span.v-align-middle",
REPLY_ELEMENTS: ":scope article.comments-comment-entity--reply",
TOP_LEVEL_COMMENTS: "article.comments-comment-entity:not(.comments-comment-entity--reply)",
LOAD_MORE_BUTTON: ".comments-comments-list__load-more-comments-button--cr",
};
@callmephil
callmephil / main.dart
Created February 2, 2025 23:25
widget_rebuild_evaluation
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@callmephil
callmephil / text_reader_prototype.dart
Created January 31, 2025 09:01
Text Reader Prototype
import 'dart:async';
import 'package:collection/collection.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
@callmephil
callmephil / firebase_error_validation.dart
Created January 24, 2025 15:44
firebase error validation example
class FirebaseErrorValidation {
const FirebaseErrorValidation._();
/// default messages for firebase auth exceptions
static const Map<String, String> _kErrorMessages = {
'unknown': 'An unknown exception occurred.',
'invalid-email': 'Email is not valid or badly formatted.',
'user-disabled':
'This user has been disabled. Please contact support for help.',
'email-already-in-use': 'An account already exists for that email.',