Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / Resource.kt
Created January 13, 2022 02:25
A generic class that holds a value with its loading status.
/**
* A generic class that holds a value with its loading status.
* @param <T>
*/
// ImmutableClass
class Resource<T> private constructor(
val status: Status,
val data: T? = null,
val throwable: Throwable? = null,
val id: Long = 0
@granoeste
granoeste / date_time_serializer.dart
Last active February 16, 2022 08:43
RFC3339 DateTime Serializer
class DateTimeSerializer {
static DateTime? deserialize(String? serialized) {
if (serialized == null) return null;
final serializedString = serialized;
final fixed = serializedString.replaceAllMapped(
RegExp(r'(.*:\d\d)(\.\d+)?(Z|[+-]\d{2}:\d{2})'),
(match) {
// #1 capturing group is date and time without a fraction of a second
@granoeste
granoeste / pretty_log_printer.dart
Last active December 17, 2021 12:15
Pretty Log Printer
import 'dart:convert';
import 'package:logger/logger.dart';
class PrettyLogPrinter extends LogPrinter {
static final levelColors = {
Level.verbose: AnsiColor.fg(AnsiColor.grey(0.5)),
Level.debug: AnsiColor.none(),
Level.info: AnsiColor.fg(12),
Level.warning: AnsiColor.fg(208),
@granoeste
granoeste / logging_interceptor.dart
Created August 13, 2021 05:55
Dio Loggin Interceptor
import 'dart:convert';
import 'package:dio/dio.dart';
/// Log Level
enum Level {
/// No logs.
none,
/// Logs request and response lines.
@granoeste
granoeste / main.dart
Created October 8, 2020 04:11
Custom Dialog Demo
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@granoeste
granoeste / main.dart
Last active October 8, 2020 04:12
Navigation Drawer in Contents Demo
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final appTitle = 'Drawer Demo';
@override
Widget build(BuildContext context) {
return MaterialApp(
@granoeste
granoeste / main.dart
Last active October 5, 2020 12:19 — forked from jcollins-g/index.html
Navigation Drawer
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final appTitle = 'Drawer Demo';
@override
Widget build(BuildContext context) {
return MaterialApp(
@granoeste
granoeste / index.html
Created October 5, 2020 12:15 — forked from jcollins-g/index.html
Sunflower
<!-- Copyright 2011 the Dart project authors. All rights reserved.
Use of this source code is governed by a BSD-style license
that can be found in the LICENSE file. -->
<h2>Dr. Fibonacci's Sunflower Spectacular</h2>
<div>
<canvas id="canvas" width="300" height="300"></canvas>
</div>
@granoeste
granoeste / .env
Last active June 15, 2020 05:33
GitHub Releases Migration Script
GITHUB_MIGRATOR_SOURCE_TOKEN={{your_access_tokens}}
GITHUB_MIGRATOR_SOURCE_HOSTNAME=github.example.com/api/v3
GITHUB_MIGRATOR_SOURCE_REPO={{source_repository}}
GITHUB_MIGRATOR_DESTINATION_TOKEN={{your_access_tokens}}
GITHUB_MIGRATOR_DESTINATION_HOSTNAME=
GITHUB_MIGRATOR_DESTINATION_REPO={{destination_repository}}