Skip to content

Instantly share code, notes, and snippets.

View UcGeorge's full-sized avatar
👨‍💻
Working & Learning

George U UcGeorge

👨‍💻
Working & Learning
View GitHub Profile
@UcGeorge
UcGeorge / endpoint.dart
Last active May 16, 2024 21:54
A dart networking utility
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:async';
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../core.dart';
@UcGeorge
UcGeorge / polling.dart
Created May 1, 2024 11:31
A mixin providing polling functionality to stateful widgets
import 'dart:async';
import 'package:flutter/material.dart';
import '../core.dart';
typedef MaybeFutureVoidCallback = FutureOr<void> Function();
/// A mixin class providing polling functionality for stateful widgets.
mixin PollingMixin<T extends StatefulWidget> on State<T> {
@UcGeorge
UcGeorge / scaled_app.dart
Last active July 26, 2024 17:19
Scales entire app based on a scaleFactor callback which is usually used to scale app based on design width
import 'dart:async' show scheduleMicrotask, Timer;
import 'dart:collection' show Queue;
import 'dart:ui' show PointerDataPacket;
import 'package:flutter/gestures.dart' show FlutterView, PointerEventConverter;
import 'package:flutter/rendering.dart' show RenderView, ViewConfiguration;
import 'package:flutter/widgets.dart';
/// The size of the screen is in logical pixels.
///
@UcGeorge
UcGeorge / constants.service.dart
Last active January 27, 2024 13:35
A construct that represents individual endpoints in an API
/// A service for retrieving application service constants.
abstract class ServiceConstantsService {
/// Factory constructor to create an instance of [ServiceConstantsService].
factory ServiceConstantsService() => _instance;
/// Singleton instance of [ServiceConstantsService].
static final ServiceConstantsService _instance = _ServiceConstantsService();
/// Retrieves a list of countries.
///
@UcGeorge
UcGeorge / Mocking Cat class using Mockito annotations.md
Created September 18, 2023 02:33
This code snippet imports the `mockito/annotations.dart` and `mockito/mockito.dart` packages. It also uses the `@GenerateNiceMocks` annotation to generate a mock library and a `MockCat` class based on the `Cat

Mocking Cat class using Mockito annotations

Preview:
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';

// Annotation which generates the cat.mocks.dart library and the MockCat class.
@GenerateNiceMocks([MockSpec<Cat>()])
import 'cat.mocks.dart';
@UcGeorge
UcGeorge / FlowUtil - Flutter Navigation and Transition Utility.md
Last active September 18, 2023 02:33
The code snippet defines a utility class called FlowUtil that provides methods for navigating between screens in a Flutter application. It includes methods for moving to a new screen and replacing the current screen, moving to a new screen and removing all previous screens, moving to This code defines a Flutter utility class that allows for movi…

FlowUtil - Flutter Navigation and Transition Utility

Preview:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// Enumeration of different page transition types.
enum FlowTransition {
  cupertino, // Cupertino-style transition
 material, // Material-style transition