Skip to content

Instantly share code, notes, and snippets.

View CoderNamedHendrick's full-sized avatar
🥷

Sebastine Odeh CoderNamedHendrick

🥷
View GitHub Profile
@CoderNamedHendrick
CoderNamedHendrick / cache_item.dart
Last active May 24, 2024 16:58
Cache implementation. Provides basic building blocks to implement the popular caching strategies: read-aside, read-through and write-through. Also extendible enough to implement other strategies on.
import 'dart:convert';
final class CacheItem {
final String key;
final Object data;
final DateTime expiry;
const CacheItem._(this.key, this.data, this.expiry);
/// This factory constructor is used for caching data that shouldn't persist
import 'dart:async';
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
/// Connectivity service use to check if an app is connected to the internet.
/// Exposes a stream to allow the client perform more on time state changes as connectivity changes.
/// Also exposes a hasConnection getter for one-off on-demand connection checks.
/// Call ConnectivityService.instance.initialise() to get the service up and running.
/// Service depends on connectivity_plus.
@CoderNamedHendrick
CoderNamedHendrick / detectable_widget.dart
Last active June 7, 2024 08:00
Detect widget on screen
import 'package:flutter/material.dart';
// Records
typedef Position = ({double? x, double? y});
typedef VisibleArea = ({Position topLeft, Position bottomRight});
// Callbacks
typedef SizeCallback = void Function(({double? height, double? width}));
import 'dart:async';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'notification_dto.dart';
import 'service.dart';
Future<void> amplifyBackgroundNotificationReceivedHandler(
PushNotificationMessage notification) async {
NotificationService.backgroundNotificationReceivedHandler(
@CoderNamedHendrick
CoderNamedHendrick / widget_overlaly.dart
Created June 19, 2024 07:10
Highlight widget overlay
mixin OverlayStateMixin<T extends StatefulWidget> on State<T> {
@override
void dispose() {
removeOverlay();
super.dispose();
}
@override
void didChangeDependencies() {
removeOverlay();