Skip to content

Instantly share code, notes, and snippets.

View miguelpruivo's full-sized avatar
🚀
Fluttering

Miguel Ruivo miguelpruivo

🚀
Fluttering
View GitHub Profile
import 'dart:math';
import 'package:flutter/material.dart';
const double _kMaxWidthRatio = 0.90;
const double _kMinWidthRatio = 0.45;
const int _kMaxCharRow = 25;
void main() => runApp(MaterialApp(home: Screen()));
@miguelpruivo
miguelpruivo / polygon_widget.dart
Created December 13, 2018 12:19
Polygon Widget
class ClipPolygon extends StatelessWidget {
final Widget child;
final int sides;
ClipPolygon({
@required this.child,
@required this.sides,
});
@override
@miguelpruivo
miguelpruivo / tracking_progress_line.dart
Created December 28, 2018 13:12
A progress line that goes from a starting date to an end date
class MyProgressLine extends CustomPainter {
MyProgressLine({this.shipped, this.estDelivery});
final DateTime shipped;
final DateTime estDelivery;
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..color = Colors.green
@miguelpruivo
miguelpruivo / carousel.dart
Created December 28, 2018 13:14
A carousel widget
import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:jnation/resources/constants.dart';
const double _kPercentageOfScreenAppBar = 0.25;
const double _kListViewTopBottomPadding = 25.0;
const double _kAppbarScrollOffset = 75.0;
Future<bool> checkConnection() async {
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
return true;
}
} on SocketException catch (_) {}
return false;
}
@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
@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 / 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 / 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 {