Skip to content

Instantly share code, notes, and snippets.

View CoderNamedHendrick's full-sized avatar
🥷

Sebastine Odeh CoderNamedHendrick

🥷
View GitHub Profile
@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();
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 / 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 '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 / 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
@CoderNamedHendrick
CoderNamedHendrick / example.dart
Last active January 19, 2024 08:02
A simple toast messaging service
import 'package:flutter/material.dart';
import 'package:notification_poc/toast_notification.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@CoderNamedHendrick
CoderNamedHendrick / interaction_inactivity.dart
Created January 9, 2024 14:03
Interaction inactivity widget
import 'package:flutter/material.dart';
/// Widget which determines users inactivity by listening for touch actions, best used at the root(MaterialApp)
/// of your project.
/// Inactivity duration is the duration to listen for
/// onNoActiveInteraction is callback to perform action when the app hasn't been interacted with
/// for [inactivityDuration].
class InteractionInactivityWidget extends StatefulWidget {
const InteractionInactivityWidget({
super.key,
@CoderNamedHendrick
CoderNamedHendrick / example.dart
Last active December 14, 2023 08:42
Animate animate animate
/// Example Usage
class MyWidget extends StatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
double _progress = 1;
@CoderNamedHendrick
CoderNamedHendrick / countdown_indicator.dart
Created November 23, 2023 18:36
Customisable circular countdown
import 'package:flutter/material.dart';
import 'dart:math';
class CountdownOTPWidget extends StatefulWidget {
const CountdownOTPWidget({
super.key,
required this.countDownDurationInMinutes,
this.children = const [],
this.progressColor,
this.progressBackgroundColor,
@CoderNamedHendrick
CoderNamedHendrick / biometrics_implementation.dart
Last active April 11, 2024 12:06
Clean Biometrics implementation
import 'package:flutter/services.dart';
import 'package:local_auth/error_codes.dart' as auth_error;
import 'package:local_auth/local_auth.dart' as local_auth;
class BiometricsService implements BiometricsInterface {
const BiometricsService();
static final _auth = local_auth.LocalAuthentication();