Skip to content

Instantly share code, notes, and snippets.

View samuelematias's full-sized avatar

samuca samuelematias

View GitHub Profile
@samuelematias
samuelematias / extension_example.dart
Created March 12, 2020 20:06
Examples of Dart extension methods
extension Paddings on Widget {
Widget paddingAll(double padding) => Padding(
padding: EdgeInsets.all(padding),
child: this,
);
}
extension TextStyles on Text {
Text h1() {
if (this is Text) {
import 'package:flutter/material.dart';
class NameInitialsWidget extends StatelessWidget {
final double width;
final double height;
final String text;
final double fontSize;
final double margin;
const NameInitialsWidget(
extension TextExtension on Text {
Text h1({TextStyle style}) {
TextStyle defaultStyle = TextStyle(
fontFamily: 'Nunito_Sans',
fontSize: 36,
fontWeight: FontWeight.w900,
fontStyle: FontStyle.normal,
letterSpacing: -0.02,
color: SoulphiaTheme.defaultGraySwatch[50],
);
@samuelematias
samuelematias / modal_with_keyboard.dart
Created May 15, 2020 16:28
Modal with keyboard Flutter
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) {
return SingleChildScrollView(
child:Container(
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: AnyChild(),
)
@samuelematias
samuelematias / launch.json
Last active June 10, 2020 13:57
[Flutter] Open 2 devices in debug mode on VsCode.
//To get your devideId follow this steps:
//1 - Open your emulator/simulator (Android/iOS/Browser)
//2 - Run on terminal "flutter devices"
//3 - Get de deviceId (second param: https://i.imgur.com/dZHsyrc.png)
// More infos: https://github.com/flutter/flutter/wiki/Multi-device-debugging-in-VS-Code
{
"version": "0.2.0",
"configurations": [
{
"name": "Android",
@samuelematias
samuelematias / flutter_github_ci.yml
Created June 22, 2020 23:10 — forked from rodydavis/flutter_github_ci.yml
Flutter Github Actions Build and Deploy Web to Firebase Hosting, iOS to Testflight, Android to Google Play (fastlane)
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_web:
import 'package:flutter/foundation.dart';
import 'dart:io';
bool get isWeb => kIsWeb;
bool get isMobile => !isWeb && (Platform.isIOS || Platform.isAndroid);
bool get isDesktop =>
!isWeb && (Platform.isMacOS || Platform.isWindows || Platform.isLinux);
bool get isApple => !isWeb && (Platform.isIOS || Platform.isMacOS);
bool get isGoogle => !isWeb && (Platform.isAndroid || Platform.isFuchsia);
@samuelematias
samuelematias / app_theme.dart
Created June 24, 2020 20:21
Customize/Theming the ThemeData to Light/Dark Theme
import 'package:flutter/material.dart';
class AppTheme {
AppTheme._();
static final Color _iconColor = Colors.redAccent.shade200;
static const Color _lightPrimaryColor = Colors.white;
static const Color _lightPrimaryVariantColor = Color(0xFFE1E1E1);
static const Color _lightSecondaryColor = Colors.green;
@samuelematias
samuelematias / pre-push
Created July 7, 2020 01:15 — forked from rogood/pre-push
Flutter Pre Push Hook with Console Messages
#!/usr/bin/env bash
if [[ `git status --porcelain` ]]; then
printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.'
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer'
flutter analyze
if [ $? -ne 0 ]; then
printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error'
exit 1
@samuelematias
samuelematias / pre-commit
Created July 7, 2020 01:15 — forked from rogood/pre-commit
Flutter Pre Commit Hook with Console Messages
#!/usr/bin/env bash
printf "\e[33;1m%s\e[0m\n" 'Running the Flutter formatter'
flutter format .
printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter formatter'