Skip to content

Instantly share code, notes, and snippets.

@denniske
denniske / useAsyncStorageValue.ts
Created June 19, 2025 11:15
useAsyncStorageValue
function useAsyncStorageValue<T>(key: string) {
const [value, setValue] = useState<T>();
const { getItem, setItem } = useAsyncStorage(key);
const readItemFromStorage = async () => {
const item = await getItem();
setValue(item != null ? JSON.parse(item) : null);
};
const writeItemToStorage = async (newValue: T) => {
@denniske
denniske / custom-solution.dart
Last active May 30, 2021 09:48
Flutter Modal bottom sheet will not overlap keyboard (Fixed)
import 'package:flutter/material.dart';
class CustomPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(),
floatingActionButton: FloatingActionButton(
onPressed: () {
showModalBottomSheet(
@denniske
denniske / custom.dart
Created August 22, 2019 13:06
Flutter Modal bottom sheet will overlap keyboard
import 'package:flutter/material.dart';
class CustomPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(),
floatingActionButton: FloatingActionButton(
onPressed: () {
showModalBottomSheet(
expect.extend({
toHaveBeenCalledWithSome<A>(received: (a: A) => any, argument: (a: A) => void) {
const [a] = (received as jasmine.Spy).calls.allArgs()[0];
argument(a);
return {
message: () => "",