Skip to content

Instantly share code, notes, and snippets.

View CoderNamedHendrick's full-sized avatar
🥷

Sebastine Odeh CoderNamedHendrick

🥷
View GitHub Profile
@CoderNamedHendrick
CoderNamedHendrick / example.dart
Last active January 14, 2023 08:32
Detect visiblity of widget(s) in scrollables
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
@CoderNamedHendrick
CoderNamedHendrick / quad_selector.dart
Last active April 27, 2025 09:31
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);
@CoderNamedHendrick
CoderNamedHendrick / init.lua
Last active December 29, 2022 12:54
My configuration for neovim with flutter in mind
-- Install packer
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
local is_bootstrap = false
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
is_bootstrap = true
vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path }
vim.cmd [[packadd packer.nvim]]
end
require('packer').startup(function(use)
@CoderNamedHendrick
CoderNamedHendrick / receipt_clipper.dart
Last active January 5, 2023 12:40
Receipt clipper showing making some cuts in a widget
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
darkTheme: ThemeData.dark(),
theme: ThemeData.light(),
home: const MyHomePage(),
debugShowCheckedModeBanner: false,
);
}
@CoderNamedHendrick
CoderNamedHendrick / util.dart
Created January 16, 2023 09:29
An extension on strings to format inputted string to required international format. Currently static and not injectable.
extension StringNumberExtension on String {
static final zeroFirstDigitRegExp = RegExp('^0');
static final internationalFormatWithPlusFirstDigitsRegExp =
RegExp('^[+234]{4}');
static final internationalFormatWithoutPlusFirstDigitsRegExp =
RegExp('^[234]{3}');
String toNumberFormat() {
if (isEmpty) {
return '';
@CoderNamedHendrick
CoderNamedHendrick / main.dart
Created March 4, 2023 22:00
Some animations
class MyWidget extends StatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget>
with SingleTickerProviderStateMixin {
late final AnimationController controller;
@CoderNamedHendrick
CoderNamedHendrick / firestore_exception_transformer.dart
Created March 11, 2023 14:06
A wrapper around firstore functions, great for abstracting firestore CRUD operations.
Future<Either<Exception, E>> firebaseTransform<E>(
Future<E> Function() callToStore) async {
try {
return Right(await callToStore.call());
} on Exception catch (e) {
if (e is FirebaseException && e.code == 'permission-denied') {
return const Left(
AuthException('You have no permission to this resource'));
}
if (e is FirebaseException) {
@CoderNamedHendrick
CoderNamedHendrick / amount_formatter.dart
Created March 24, 2023 13:05
Amount input formatter with decimal entry
import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
final RegExp _mantissaSeparatorRegexp = RegExp(r'[,.]');
final RegExp _illegalCharsRegexp = RegExp(r'[^\d-,.]+');
class AmountInputFormatter implements TextInputFormatter {
final int mantissaLength;
@CoderNamedHendrick
CoderNamedHendrick / either.dart
Last active August 2, 2023 16:09
Implementing Options in dart
import 'dart:async';
typedef Lazy<T> = T Function();
/// Represents a value of one of two possible types.
/// Instances of [Either] are either an instance of [Left] or [Right].
///
/// [Left] is used for "failure".
/// [Right] is used for "success".
abstract class Either<L, R> {
/// A resuable widget for getting a page to refresh without needing to scroll with the ugly scroll behaviour
/// on ios. Used by wrapping the widget with the view with this widget as so
/// class MyHomePage extends StatelessWidget {
/// const MyHomePage({super.key, required this.title});
///
/// final String title;
///
/// @override
/// Widget build(BuildContext context) {
/// return NoScrollRefreshWidget(