Skip to content

Instantly share code, notes, and snippets.

@granoeste
granoeste / Resource.kt
Created Jan 13, 2022
A generic class that holds a value with its loading status.
View Resource.kt
/**
* 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 Feb 16, 2022
RFC3339 DateTime Serializer
View date_time_serializer.dart
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
View pretty_log_printer.dart
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),
View logging_interceptor.dart
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 Oct 8, 2020
Custom Dialog Demo
View main.dart
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 Oct 8, 2020
Navigation Drawer in Contents Demo
View main.dart
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 Oct 5, 2020 — forked from jcollins-g/index.html
Navigation Drawer
View main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final appTitle = 'Drawer Demo';
@override
Widget build(BuildContext context) {
return MaterialApp(
View index.html
<!-- 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 Jun 15, 2020
GitHub Releases Migration Script
View .env
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}}