Skip to content

Instantly share code, notes, and snippets.

View aytunch's full-sized avatar
Working from anywhere with a plug

aytunc aytunch

Working from anywhere with a plug
View GitHub Profile
@slightfoot
slightfoot / wizard_buttons.dart
Last active December 20, 2023 20:19
Wizard Buttons - by Simon Lightfoot - Humpday Q&A :: 20th December 2023 #HumpdayQandA #Flutter #Dart - https://www.youtube.com/live/kJWtSAFnJxk?si=nWEXHtV1NmT6jJCd&t=6509
// MIT License
//
// Copyright (c) 2023 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
private fun launchIntents(context: Context) {
val whatsappIntent = getWhatsappIntent(context)
val telegramIntent = getTelegramIntent(context)
val intents = listOfNotNull(whatsappIntent, telegramIntent)
val globalIntent = Intent()
val chooserIntent = Intent.createChooser(globalIntent, "Send message")
.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toTypedArray())
@kangabru
kangabru / magnifying_glass.dart
Last active August 17, 2020 08:45
Allows you to display a 'magnifying glass' widget which helps users see what's under their finger while they are drawing
import 'dart:math';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// The radius of the mag glass.
const double _RADIUS = 60.0;
/// The distance the mag glass will be offset from the touch point.
const double _OFFSET = _RADIUS * 1.5;
@kangabru
kangabru / screenshot.dart
Last active November 9, 2020 13:27
Allows you extract an image of specific widgets within your app. Includes the ability to ignore certain widgets and to crop the final image.
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
// Note: [ui.Image] represents the lower level image data while [Image] represents a renderable image.
/// Provides the ability to take screenshots of specific widgets.
mixin Screenshot<T extends StatefulWidget> on State<T> {
@kangabru
kangabru / list_picker.dart
Last active August 17, 2020 08:47
A Flutter scrollable horizontal list widget which animates into place on load.
import 'package:flutter/material.dart';
import './animation_mixins.dart'; // See my other gist for this
/// A scrollable horizontal list which animates into place on load.
class ListPicker extends StatefulWidget {
final List<Widget> children;
final double paddingX, paddingY;
const ListPicker({
this.children,
this.paddingX = 12.0,
@kangabru
kangabru / animation_widgets.dart
Last active January 2, 2021 12:41
A couple of handy Flutter widgets I use for animations.
import 'package:flutter/material.dart';
import './animation_mixins.dart'; // See my other gist for this
// Ímplicitly animates an int to the given value.
class AnimatedInt extends StatelessWidget {
final int value;
final Duration duration; // milliseconds
final TextStyle style;
AnimatedInt({
@required this.value,
@kangabru
kangabru / animation_mixins.dart
Created June 7, 2020 00:51
A couple of handy Flutter mixins I use for animations.
import 'dart:async';
import 'package:flutter/material.dart';
/// A mixin to perform context dependent function when the widget loads.
mixin FirstLoad<T extends StatefulWidget> on State<T> {
bool _hasLoaded = false;
bool get isFirstLoad => !_hasLoaded;
/// Calls the given callback on the first load only.
/// This should NOT be called in [initState] as the UI will not have rendered it.
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:xml/xml.dart';
import 'package:flutter/services.dart';
/// An example widget which uses an [SvgOverride] widget to render an SVG with dynamic colors.
class ZenButtonCookie extends StatelessWidget {
final CookieColor color; // My internal color object. Adapt this for your needs.
const ZenButtonCookie(this.color);
@CodingDoug
CodingDoug / README.md
Created December 5, 2019 02:24
How to schedule a Cloud Function to run in the future (in order to build a Firestore document TTL)
@lukepighetti
lukepighetti / extents_page_view.dart
Last active January 19, 2025 11:24
Flutter PageView that loads the next/previous page off-screen
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart' hide PageView;
/// This is copy-pasted from the Flutter framework with a support added for building
/// pages off screen using [Viewport.cacheExtents] and a [LayoutBuilder]
///
/// Based on commit 3932ffb1cd5dfa0c3891c60977ee4f9cd70ade66 on channel dev
// Having this global (mutable) page controller is a bit of a hack. We need it