Skip to content

Instantly share code, notes, and snippets.

Taking care of my mental health and in spare moments coding sometimes.

Samuel Matias samuelematias

Taking care of my mental health and in spare moments coding sometimes.
View GitHub Profile
samuelematias / url_state.dart
Last active Mar 10, 2021
Example of cubit state using const/factory in only one state.
View url_state.dart
part of 'url_cubit.dart';
enum ErrorType { defaultError, urlAlreadyExists, none }
class UrlState extends Equatable {
const UrlState({
samuelematias / doom.txt
Created Feb 11, 2021 — forked from hjertnes/doom.txt
Doom Emacs Cheatsheet
View doom.txt
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
samuelematias / modal_navigation_bar.dart
Last active Feb 2, 2021
If you need a modal (showModalBottomSheet) but you have a bottomnavigationbar and the modal needs to be on top of the bottomnavigationbar, use the userootnavigator = true property of showModalBottomSheet.
View modal_navigation_bar.dart
// This example on Dartpad:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
View settings.json
"": "/bin/zsh",
"workbench.colorTheme": "Dracula Pro",
"workbench.iconTheme": "vscode-icons",
"workbench.startupEditor": "newUntitledFile",
"terminal.integrated.rendererType": "dom",
"terminal.integrated.fontFamily": "Fira Code",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"window.title": "${activeEditorLong}${separator}${rootName}",
samuelematias / auth_interceptor.dart
Created Jan 29, 2021 — forked from douglasiacovelli/auth_interceptor.dart
This is a code for an auth interceptor for Dio, which uses a header to avoid retrying indefinitely to refresh the token.
View auth_interceptor.dart
/// This interceptor is simplified because is doesn't contemplate
/// a refresh token, which you should take care of.
/// I haven't tested this code, but I believe it should work.
/// If you have some feedback, please leave a comment and I'll review it :) Thanks.
class AuthInterceptor extends InterceptorsWrapper {
final Dio loggedDio;
final Dio tokenDio;
samuelematias / .zshrc
Created Jan 3, 2021
personal .zshrc configs v3
View .zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
samuelematias / app_info.dart
Created Dec 8, 2020
Get some informations about you Flutter app.
View app_info.dart
import 'package:package_info/package_info.dart'; //
class AppInfo {
Future<String> get version async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version ?? 'Unknown Version'; // 1.2.7
Future<String> get buildNumber async {
samuelematias / device_info.dart
Last active Dec 10, 2020
Get some informations of the device where you Flutter app is installed.
View device_info.dart
import 'dart:io';
import 'package:device_info/device_info.dart'; //
class DeviceInfo {
Future<String> get deviceModel async {
final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
final AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
final String manufacturer = androidInfo.manufacturer;
samuelematias / old_device_info.dart
Created Dec 8, 2020
[OLD] check some infos about the device in flutter.
View old_device_info.dart
import 'dart:ui' as ui;
import 'dart:io';
class DeviceInfo {
static double devicePixelRatio = ui.window.devicePixelRatio;
static ui.Size size = ui.window.physicalSize;
static double width = size.width;
static double height = size.height;
static double screenWidth = width / devicePixelRatio;
static double screenHeight = height / devicePixelRatio;
View padding_extensions.dart
import 'package:flutter/material.dart';
extension PaddingExtensions on Widget {
Widget horizontalListPadding({
@required int index,
@required int listLength,
double spacingFirstItem = 16,
double spacingLastItem = 16,
double spaceBetweenItems = 16,
}) {