Skip to content

Instantly share code, notes, and snippets.

View ueman's full-sized avatar

Jonas Uekötter ueman

View GitHub Profile
@ueman
ueman / native_page.dart
Created February 2, 2024 15:51
hacky virtual navigation
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
void navigate(BuildContext context) {
Navigator.push<void>(
context,
NativePageRoute(
onPush: () => openAppSetttings(),
onResume: () => Future.value(),
),
@ueman
ueman / sentry_bloc_observer.dart
Created February 8, 2023 18:58
Sentry Bloc Observer
import 'dart:developer';
import 'package:bloc/bloc.dart';
import 'package:sentry/sentry.dart';
class SentryBlocObserver extends BlocObserver {
SentryBlocObserver({Hub? hub}) : _hub = hub ?? HubAdapter();
final Hub _hub;
@ueman
ueman / dio_image.dart
Created November 12, 2022 21:36
http and dio image
/// Requires at least Flutter 3.x
import 'dart:async';
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
import 'package:dio/dio.dart';
import 'package:flutter/widgets.dart';
/// Fetches the given URL from the network, associating it with the given scale.
///
@ueman
ueman / graphql.dart
Created October 11, 2022 15:52
Sentry Dart integrations
// Integration for http_link / GraphQL
// The following code can be used as
// final httpLink = HttpLink(
// appConfig.graphQL,
// httpClient: httpClient,
// useGETForQueries: true,
// serializer: SentryRequestSerializer(),
// httpResponseDecoder: sentryResponseDecoder,
// );
// add https://pub.dev/packages/stack_trace_parser to pubsepc.yaml
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sentry/sentry.dart';
import 'package:stack_trace_parser/stack_trace_parser.dart';
class PlatformExceptionEventProcessor implements EventProcessor {
@ueman
ueman / platform_exception.dart
Created February 9, 2022 15:20
Chained stacktraces for PlatformException
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sentry/sentry.dart';
import 'package:stack_trace_parser/stack_trace_parser.dart';
class PlatformExceptionEventProcessor implements EventProcessor {
final SentryOptions _options;
PackageInfo? _packageInfo;
import 'dart:convert';
void main() {
final dynamic smth = jsonDecode('''
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
@ueman
ueman / 6key.ino
Created July 26, 2018 16:59
6key arduino macro pad
#include <HID-Project.h>
#include <HID-Settings.h>
/**
HIGH = 1
LOW = 0
*/
#define PRESSED 1
#define RELEASED 0
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ueman
ueman / Adapter&Bridge.md
Last active January 2, 2017 10:30
Adapter & Bridge Pattern

Adapter Pattern

Es wird häufig auch Wrapper oder Hüllenklasse genannt.

Problem:

  • Man hat eine Klasse oder ein Interface welches nicht kompatibel mit der Vorhandenen Codebase oder dem angestrebten Aufbau ist

Lösung:

  • Das Adapter Pattern