Skip to content

Instantly share code, notes, and snippets.

@eduardoflorence
eduardoflorence / main.dart
Created March 23, 2021 19:12
GetX - Sample BottomNavigationBar
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: '/home',
defaultTransition: Transition.fade,
getPages: [
GetPage(
@eduardoflorence
eduardoflorence / main.dart
Created February 24, 2021 11:35
GetX - Sample GetMiddleware
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class GlobalMiddleware extends GetMiddleware {
final authController = Get.find<AuthController>();
@override
RouteSettings redirect(String route) {
return authController.authenticated || route == '/login'
? null
@eduardoflorence
eduardoflorence / main.dart
Last active November 14, 2024 06:21
Getx - Sample SuperController and FullLifeCycleController
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
initialRoute: '/home',
getPages: [
GetPage(
name: '/home',
page: () => HomePage(),
@eduardoflorence
eduardoflorence / main.dart
Created January 13, 2021 19:29
GetX - Sample GetWidget
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: '/home',
defaultTransition: Transition.fade,
getPages: [
GetPage(
@eduardoflorence
eduardoflorence / main.dart
Created December 24, 2020 20:03
GetX - Sample GetConnect
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(GetMaterialApp(
initialRoute: '/home',
getPages: [
GetPage(
name: '/home',
page: () => HomePage(),
@mhadaily
mhadaily / Update website if there is new servicer worker update found.md
Created November 14, 2020 14:14
Use it in your index.html file in Flutter Web.
function invokeServiceWorkerUpdateFlow() {
  // you have a better UI here, reloading is not a great user experince here.
  const confirmed = confirm('New version of the app is available. Refresh now');
  if (confirmed) {
    window.location.reload();
  }
}
async function handleServiceWorker() {
@av
av / main.dart
Created January 13, 2020 18:44
Flutter: neu
import 'package:flutter/material.dart';
void main() => runApp(NeumorphicApp());
class NeumorphicApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Neumorphic App',
theme: ThemeData(
@cetorres
cetorres / DetectiPhoneX.dart
Created October 9, 2019 16:51
Detect iPhone X or greater in Flutter / Dart
class DetectiPhoneXOrGreater {
static bool isiPhoneXOrGreater(context) {
if (Platform.isAndroid) {
return false;
}
else if (Platform.isIOS) {
double height = MediaQuery.of(context).size.height;
if (height >= 812.0) return true;
}
return false;
@vferreirati
vferreirati / print.dart
Created September 20, 2019 17:01
Exemplo de geração de imagem a partir de um widget
void _onShareReceipt(context) async {
final data = await _onCaptureReceipt();
// Utilizando o pacote "esys_flutter_share" para compartilhamento da imagem gerada
await Share.file('Comprovante de Venda', 'comprovante.png', data, 'image/png');
}
Future<Uint8List> _onCaptureReceipt() async {
// _receiptKey é uma GlobalKey que foi atribuida ao Widget pelo qual desejo imprimir
RenderRepaintBoundary boundary = _receiptKey.currentContext.findRenderObject();
@slightfoot
slightfoot / capture_widget.dart
Created August 12, 2019 12:58
Capture Flutter Widgets as Image but Off Screen
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
runApp(
MaterialApp(