Skip to content

Instantly share code, notes, and snippets.

View samuelematias's full-sized avatar

samuca samuelematias

View GitHub Profile
@samuelematias
samuelematias / dart_extensions_methods_example_3.dart
Last active November 23, 2020 00:30
Dart Extensions methods example 3
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@samuelematias
samuelematias / dart_extensions_methods_example_4.dart
Last active November 23, 2020 00:30
Dart Extensions methods example 4
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@samuelematias
samuelematias / padding_extensions.dart
Created November 24, 2020 21:45
Padding Extensions
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,
}) {
@samuelematias
samuelematias / old_device_info.dart
Created December 8, 2020 16:27
[OLD] check some infos about the device in flutter.
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;
@samuelematias
samuelematias / device_info.dart
Last active December 10, 2020 13:29
Get some informations of the device where you Flutter app is installed.
import 'dart:io';
import 'package:device_info/device_info.dart'; //https://pub.dev/packages/device_info
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
samuelematias / app_info.dart
Created December 8, 2020 19:33
Get some informations about you Flutter app.
import 'package:package_info/package_info.dart'; //https://pub.dev/packages/package_info
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
samuelematias / .zshrc
Created January 3, 2021 15:06
personal .zshrc configs v3
# 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"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
@samuelematias
samuelematias / auth_interceptor.dart
Created January 29, 2021 10:37 — 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.
/// 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
samuelematias / settings.json
Created February 1, 2021 22:36
vsCode configs
{
"terminal.integrated.shell.osx": "/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
samuelematias / modal_navigation_bar.dart
Last active November 16, 2023 05:47
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.
// This example on Dartpad:
// https://dartpad.dev/cbbfed060a664b6fdaf4229b02cd1add
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(