Skip to content

Instantly share code, notes, and snippets.

View CoderNamedHendrick's full-sized avatar
🥷

Sebastine Odeh CoderNamedHendrick

🥷
View GitHub Profile
import '/features/architecture/logging.dart';
class CachedQuery<T> {
final Duration invalidation;
final Future<T> Function(String key) fn;
CachedQuery(
this.fn,
this.invalidation,
);
@AkinAguda
AkinAguda / range.ts
Last active January 26, 2024 22:53
A `Range` type in typescript that ensures that a value is within a certain range of positive values (not inclusive of the last)
// Convert string to number
type ToNumber<S> = S extends `${infer N extends number}` ? N : never;
// Creates an array with a particular length
type ArrayWithLength<
T extends number,
A extends number[] = number[],
> = A["length"] extends T ? A : ArrayWithLength<T, [...A, A["length"]]>;
// Generates a union type with all the numbers from zero -> n
@BarryDaBee
BarryDaBee / password_validator.dart
Last active March 2, 2023 13:04
A simple widget for validating password conditions like length >= 8, hasNumber etc
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
@craiglabenz
craiglabenz / chat_message_render_box.dart
Last active May 27, 2024 19:24
Demonstrates a custom RenderObject that draws chat messages like WhatsApp, where the `sentAt` timestamp is tucked into the last line if it fits
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@medwonuola
medwonuola / main.dart
Last active December 27, 2022 16:54 — forked from CoderNamedHendrick/main.dart
Quad selector widget
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@jogboms
jogboms / space.dart
Created January 24, 2022 06:14
A low-overhead Space widget for all Flex needs
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
class Space extends LeafRenderObjectWidget {
const Space(this.space, {Key? key}) : super(key: key);
final double space;
@override
RenderObject createRenderObject(BuildContext context) => RenderSpace(space: space);
@LordGhostX
LordGhostX / banks.json
Last active June 3, 2024 09:16
List of Nigerian Banks and Codes
{
"9 payment service Bank": "120001",
"AB MICROFINANCE BANK": "090270",
"ABBEY MORTGAGE BANK": "070010",
"ABOVE ONLY MICROFINANCE BANK": "090260",
"ABU MICROFINANCE BANK": "090197",
"ACCESS BANK": "000014",
"ACCESSMONEY": "100013",
"ACCION MFB": "090134",
"ADDOSSER MFBB": "090160",
@nikhilmufc7
nikhilmufc7 / auth.dart
Last active June 2, 2024 08:26
Firebase Flutter Platform Exception Codes and example
// Error Codes for SignUp
ERROR_OPERATION_NOT_ALLOWED` - Indicates that Anonymous accounts are not enabled.
ERROR_WEAK_PASSWORD - If the password is not strong enough.
ERROR_INVALID_EMAIL` - If the email address is malformed.
ERROR_EMAIL_ALREADY_IN_USE - If the email is already in use by a different account.
ERROR_INVALID_CREDENTIAL` - If the [email] address is malformed.
// sending password reset email
ERROR_INVALID_EMAIL` - If the [email] address is malformed.
@lopspower
lopspower / README.md
Last active June 22, 2024 03:58
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@psayre23
psayre23 / gist:c30a821239f4818b0709
Last active June 8, 2024 19:07
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array