Skip to content

Instantly share code, notes, and snippets.

View miguelpruivo's full-sized avatar
🚀
Fluttering

Miguel Ruivo miguelpruivo

🚀
Fluttering
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
@miguelpruivo
miguelpruivo / ios_status_bar_controller.dart
Last active May 7, 2020 13:27
A way to easily handle status bar taps on custom ScrollController instances. Thanks @Kavantix.
class _ScrollController extends ScrollController {
final attachedPositions = <ScrollPosition>{};
ScrollController _scaffoldScrollController;
void init(BuildContext context) {
_scaffoldScrollController = PrimaryScrollController.of(context);
}
set scaffoldScrollController(ScrollController value) {
if (_scaffoldScrollController != value) {
@miguelpruivo
miguelpruivo / Diacritics.dart
Created October 16, 2019 22:05
Diacritics for Flutter
class DiacriticsHelper {
static final defaultDiacriticsRemovalap = [
{
'base': 'A',
'letters':
'\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'
},
{'base': 'AA', 'letters': '\uA732'},
{'base': 'AE', 'letters': '\u00C6\u01FC\u01E2'},
{'base': 'AO', 'letters': '\uA734'},
import 'package:flare_flutter/flare.dart';
import 'package:flare_flutter/flare_controls.dart';
class MyControls extends FlareControls {
@override
void initialize(FlutterActorArtboard artboard) {
super.initialize(artboard);
play("first animation");
}
@miguelpruivo
miguelpruivo / CircularProgressPainter.dart
Created September 3, 2019 00:04
Circular progress painter (wip)
class ProgressPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
double percent = 85;
Paint p = Paint()
..color = Colors.white24
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round
..strokeWidth = 4.0;
@miguelpruivo
miguelpruivo / NativeCupertinoPicker.dart
Last active July 30, 2019 14:01
A helper method that opens a native iOS flavor `CupertinoTextPicker` and `CupertinoDatePicker`
void showCupertinoPicker<T>(BuildContext context,
{bool isDatePicker = false,
List<T> options,
T selectedValue,
DateTime minDate,
DateTime lastDate,
DateTime initialDate,
Function(T) onChanged}) {
showCupertinoModalPopup(
context: context,
@miguelpruivo
miguelpruivo / MethodResultWrapper.java
Created July 15, 2019 15:23
A result wrapper for Flutter Android plugins
package io.ptech.cc.plugins.flutter;
import android.os.Handler;
import android.os.Looper;
import io.flutter.plugin.common.MethodChannel;
public class MethodResultWrapper implements MethodChannel.Result {
@miguelpruivo
miguelpruivo / animated_clock_toggle.dart
Created April 30, 2019 10:18
An animated clock toggle widget for setting alarms in lists or similliar.
class AnimatedClock extends StatefulWidget {
final bool isToggled;
const AnimatedClock({
Key key,
this.isToggled,
}) : super(key: key);
@override
_AnimatedClockState createState() => _AnimatedClockState();
}
@miguelpruivo
miguelpruivo / back_swipe.dart
Created April 29, 2019 23:07
Back swipe navigation gesture
class BackSwipe extends StatelessWidget {
final Widget child;
BackSwipe({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
double start = 0.0;
return GestureDetector(
onHorizontalDragStart: (details) => start = details.globalPosition.dx,
@miguelpruivo
miguelpruivo / scrollable_footer.dart
Created April 17, 2019 15:26 — forked from evelyne24/scrollable_footer.dart
Flutter scrollable footer - a footer that stays at the bottom of the screen and scrolls with its container; also see https://docs.flutter.dev/flutter/widgets/SingleChildScrollView-class.html