Skip to content

Instantly share code, notes, and snippets.

@osaxma
osaxma / svg_pattern_example.dart
Last active February 20, 2021 09:31
An example of using an svg pattern as a background with the help of Flutter Shape Maker
// so it doesn't conflict with Image from material package
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
// svg from hero patterns (I Like Food): https://www.heropatterns.com/
// converted to CustomPainter code using: https://fluttershapemaker.com/
void main() {
runApp(SvgPatternExample());
@osaxma
osaxma / hasura_connect_ex.dart
Last active March 4, 2024 09:38
a workaround for keeping haura_connect subscriptions alive when using JWT
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:hasura_connect/hasura_connect.dart';
import 'package:http/http.dart' as http;
// problem:
// when subscribing to`HasuraConnect.subscription`, a websocket connection is created on the first subscription
// call. The websocket connection is created only once with the initial subscription and the provided TokenInterceptor
// or headers. When the token expires during an active subscription, HasuraConnect doesn't stop the subscription, or try
// to reconnect with the latest token in in the TokenInterceptor nor does it throw an error. It'll keep calling `onRequest`
@osaxma
osaxma / datetime_bug.dart
Last active February 6, 2021 09:46
lost microseconds with DateTime.parse or DateTime.fromMicrosecondsSinceEpoch
// Based on Flutter 1.26.0-17.3.pre Dart SDK 2.10.4
// filed issue at https://github.com/dart-lang/sdk/issues/44876
main() {
final datetimeParsed = DateTime.parse('2021-02-05T22:37:12.933232+00:00');
final datetimeMS = DateTime.fromMicrosecondsSinceEpoch(1612564632933232);
print(datetimeParsed.toIso8601String()); // prints 2021-02-05T22:37:12.933Z
print(datetimeMS.toUtc().toIso8601String()); // prints 2021-02-05T22:37:12.933Z
print(datetimeParsed.microsecondsSinceEpoch); // prints 1612564632933000
@osaxma
osaxma / hasura_postgres_docker_notes.md
Last active December 4, 2021 20:59
Notes on working with Hasura, Postgres and Docker in local development
@osaxma
osaxma / SO_56071731.dart
Last active November 14, 2020 11:18
Expand Shrink Cards with Scrolling in ListView
// answer for:
// https://stackoverflow.com/questions/64826393/how-can-i-implement-this-specific-scroll-animation-using-flutter/
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@osaxma
osaxma / flutter_backdrop_ex.dart
Created December 22, 2019 17:32
Flutter Backdrop Example for DartPad
// taken from: https://github.com/iampawan/FlutterBackdrop
// copy paste to https://dartpad.dev/ and should work
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.teal),
home: BackdropPage(),