Skip to content

Instantly share code, notes, and snippets.

View TesteurManiak's full-sized avatar
🎯
Dart/Flutter Software Engineer

Guillaume Roux TesteurManiak

🎯
Dart/Flutter Software Engineer
View GitHub Profile
@TesteurManiak
TesteurManiak / optional.dart
Created September 29, 2025 07:52
Dart implementation of Swift's Optional type
import 'package:meta/meta.dart';
/// Dart implementation of Swift's `Optional` type.
///
/// {@template optional}
/// Creates an object that holds a nullable value which can be unwrapped
/// safely.
/// {@endtemplate}
///
/// Swift specs: https://developer.apple.com/documentation/swift/optional
@TesteurManiak
TesteurManiak / simple_state_management.dart
Last active March 6, 2025 15:50
Simple state management experiment only with Flutter tools.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@TesteurManiak
TesteurManiak / tachiyomi_generate_id.dart
Created May 14, 2024 15:40
Dart version of the Tachiyomi algorithm used to generate source ids.
import 'dart:convert';
import 'dart:math';
import 'package:crypto/crypto.dart';
int generateId(String name, String lang, int versionId) {
String key = "${name.toLowerCase()}/$lang/$versionId";
List<int> bytes = md5.convert(utf8.encode(key)).bytes;
int result = 0;
@TesteurManiak
TesteurManiak / refresh_notifier.dart
Created February 27, 2024 15:30
A ChangeNotifier that listens to multiple Listenables.
/// A [ChangeNotifier] that listens to multiple [Listenable]s.
class RefreshNotifier extends ChangeNotifier {
RefreshNotifier(this._listenables) {
for (final listenable in _listenables) {
listenable.addListener(notifyListeners);
}
}
final List<Listenable> _listenables;
@TesteurManiak
TesteurManiak / inactivity_detector.dart
Last active August 14, 2024 08:04
A widget that will detect inactivity of the user.
import 'package:async/async.dart';
import 'package:flutter/material.dart';
final navigatorKey = GlobalKey<NavigatorState>();
class InactivityObserver extends StatefulWidget {
const InactivityObserver({
super.key,
required this.inactivityTimeout,
required this.child,
@TesteurManiak
TesteurManiak / riverpod_localization_sample.dart
Last active February 27, 2024 15:32
Flutter code sample to manage localization using riverpod
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class LocalizationNotifier extends StateNotifier<Locale?> {
LocalizationNotifier({
required this.defaultLocale,
required this.supportedLocales,
}) : super(defaultLocale);
final Locale defaultLocale;
@TesteurManiak
TesteurManiak / sliver_separated_child_builder_delegate.dart
Created December 5, 2022 16:42
Showcase of SliverSeparatedChildBuilderDelegate
import 'dart:math' as math;
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
final elements = List<int>.generate(100, (i) => i);
void main() {
runApp(MyApp());
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_fcm_web_example/notification_encapsulation.dart';
import 'package:flutter_fcm_web_example/notification_model.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
import 'package:flutter_fcm_web_example/notification_helper.dart';
import 'firebase_mobile_messaging.dart'
if (dart.library.js) 'firebase_web_messaging.dart' as notifInstance;
abstract class NotificationEncapsulation {
static NotificationHelper get instance =>
notifInstance.FirebaseMessagingHelper();
}
importScripts('https://www.gstatic.com/firebasejs/7.23.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.23.0/firebase-messaging.js');
var firebaseConfig = {
apiKey: "API_KEY",
authDomain: "AUTH_DOMAIN",
databaseURL: "DB_URL",
projectId: "PROJECT_ID",
storageBucket: "STORAGE_BUCKET",
messagingSenderId: "SENDER_ID",