Skip to content

Instantly share code, notes, and snippets.

@peerwaya
peerwaya / lru_cache.dart
Created November 6, 2023 03:29 — forked from slightfoot/lru_cache.dart
Time Aware Least Recently Used Cache - by Simon Lightfoot http://en.wikipedia.org/wiki/Cache_algorithms#LRU
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@peerwaya
peerwaya / main.dart
Created August 14, 2023 00:15 — forked from webianks/main.dart
Scanning Animation In Flutter
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:scanning_aimation/scanner.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@peerwaya
peerwaya / main.dart
Created August 14, 2023 00:15 — forked from webianks/main.dart
Scanning Animation In Flutter
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:scanning_aimation/scanner.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@peerwaya
peerwaya / torus-firebase-react.js
Created May 5, 2021 04:24 — forked from phuctm97/torus-firebase-react.js
Integrate Torus CustomAuth with Firebase (React)
import { useState } from "react";
import TorusSdk from "@toruslabs/torus-direct-web-sdk";
const App = () => {
const [torusSdk, setTorusSdk] = useState();
const onMount = async () => {
const sdk = new TorusSdk({
baseUrl: `${window.location.origin}/auth`,
enableLogging: true,
@peerwaya
peerwaya / page_flip_ios_jank.dart
Created February 22, 2021 20:29 — forked from bizz84/page_flip_ios_jank.dart
Example Flutter app showing iOS jank on first launch with full-screen page flip animation
// Related: https://github.com/flutter/flutter/issues/76180
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@peerwaya
peerwaya / sliver_scroll.dart
Created June 14, 2020 05:50 — forked from slightfoot/sliver_scroll.dart
Example of having a layout with nested scrolling tabs with Slivers.
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@peerwaya
peerwaya / database.rules.json
Created July 24, 2019 00:15 — forked from codediodeio/database.rules.json
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@peerwaya
peerwaya / Flutter MediaQuery
Created April 17, 2019 13:28 — forked from bdiegel/Flutter MediaQuery
flutter - device pixel ratio
queryData = MediaQuery.of(context);
double devicePixelRatio = queryData.devicePixelRatio;
'size (pixels): w=${queryData.size.width * devicePixelRatio}, h=${queryData.size.height * devicePixelRatio}'
'devicePixelRatio: $devicePixelRatio'
'size: w=${queryData.size.width}, h=${queryData.size.height}'
'textScaleFactor: w=${queryData.textScaleFactor}'
From example:
@peerwaya
peerwaya / swipe_button.dart
Created December 9, 2018 15:12 — forked from slightfoot/swipe_button.dart
Flutter Swipe Button Demo
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
void main() => runApp(SwipeDemoApp());
class SwipeDemoApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
import 'model.dart';
typedef OnChatMessageCallback = void Function(int index, ChatMessage message);
abstract class ChatManager {
ChatManager();
ChatSession getNamedSession(String name);
}