Skip to content

Instantly share code, notes, and snippets.

View gildaswise's full-sized avatar
🏠
Working from home

Gildásio Filho gildaswise

🏠
Working from home
View GitHub Profile
@gildaswise
gildaswise / AppDelegate.swift
Last active December 8, 2022 04:48
Gists from the --dart-define article
let dartDefinesString = Bundle.main.infoDictionary!["DART_DEFINES"] as! String
var dartDefinesDictionary = [String:String]()
for definedValue in dartDefinesString.components(separatedBy: ",") {
let decoded = String(data: Data(base64Encoded: definedValue)!, encoding: .utf8)!
let values = decoded.components(separatedBy: "=")
dartDefinesDictionary[values[0]] = values[1]
}
@gildaswise
gildaswise / main.dart
Last active February 22, 2024 15:10
Quick transition between list of widgets
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
@gildaswise
gildaswise / format_duration.dart
Last active April 30, 2019 19:14
An implementation of formatDuration in Dart, probably needs optimizations but it works and has support for changing the strings; getDateDifference by @app-o-matix
import 'package:collection/collection.dart';
Function listEquals = const ListEquality().equals;
class DateUtils {
static String formatDuration(DateTime dateTime,
{String years = "year(s)",
String months = "month(s)",
String days = "day(s)",
@gildaswise
gildaswise / sliver_refresh_indicator.dart
Created September 13, 2018 20:08
Apple's and Android's refresh indicator to use with CupertinoSliverRefreshControl
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
Widget buildAppleRefreshIndicator(
BuildContext context,
RefreshIndicatorMode refreshState,
double pulledExtent,
double refreshTriggerPullDistance,
@gildaswise
gildaswise / long_hold.dart
Created September 13, 2018 14:44
A gesture listener that repeats an action at a default of 200ms
import 'dart:async';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
/// Signature for when a pointer has remained in contact with the screen at the
/// same location for a long period of time.
typedef void GestureHoldCallback();
/// Signature for when the pointer that previously triggered a
@gildaswise
gildaswise / rounded_modal.dart
Last active October 7, 2021 09:39
A custom implementation of the showModalBottomSheet, with rounded corners
import 'dart:async';
import 'package:flutter/material.dart';
/// Below is the usage for this function, you'll only have to import this file
/// [radius] takes a double and will be the radius to the rounded corners of this modal
/// [color] will color the modal itself, the default being `Colors.white`
/// [builder] takes the content of the modal, if you're using [Column]
/// or a similar widget, remember to set `mainAxisSize: MainAxisSize.min`
/// so it will only take the needed space.