Skip to content

Instantly share code, notes, and snippets.

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

Julian Bissekkou JulianBissekkou

🏠
Working from home
View GitHub Profile
{
"version": 8,
"sprite": "https://www.arcgis.com/sharing/rest/content/items/2979525c704b4900811fb29822e0f27c/resources/sprites/sprite-1650359779877",
"glyphs": "https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/resources/fonts/{fontstack}/{range}.pbf",
"sources": {
"esri": {
"type": "vector",
"url": "https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer",
"tiles": [
"https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf"
@override
Widget build(BuildContext context) {
return PullToReachScope(
child: Scaffold(
appBar: AppBar(
actions: [
ReachableIcon(
child: Icon(Icons.search),
index: 2,
onSelect: () => _routeToPage("search!"),
class ReachableIcon extends StatefulWidget {
final Widget child;
final int index;
final VoidCallback onSelect;
ReachableIcon({
@required this.child,
@required this.index,
@required this.onSelect,
});
@immutable
class Reachable extends StatefulWidget {
final Widget child;
final int index;
final ValueChanged<bool> onFocusChanged;
final VoidCallback onSelect;
Reachable({
@required this.child,
bool _didDragEnd(ScrollNotification notification) {
// Whenever dragDetails are null the scrolling happends without the users input
// meaning that the user release the finger --> drag has ended.
// For Cupertino Scrollables the ScrollEndNotification can not be used
// since it will be send after the list scroll has completely ended and
// the list is in its initial state
if (notification is ScrollUpdateNotification &&
notification.dragDetails == null) {
return true;
}
bool _handleScrollNotification(ScrollNotification notification) {
if (_didDragStart(notification)) {
_dragOffset = 0;
_pullToReachStarted = true;
}
if (_didDragEnd(notification)) {
_dragOffset = 0;
_pullToReachStarted = false;
class ScrollToIndexConverter extends StatefulWidget {
final Widget child;
final int itemCount;
final double dragExtentPercentage;
ScrollToIndexConverter({
@required this.child,
@required this.itemCount,
this.dragExtentPercentage = 0.2,
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:pull_down_to_reach/index_calculator/index_calculator.dart';
import 'package:pull_down_to_reach/widgets/pull_to_reach_scope.dart';
abstract class IndexCalculator {
int getIndexForScrollPercent(double scrollPercent);
}
class ScrollToIndexConverter extends StatefulWidget {
double _calculateScrollProgress(ScrollNotification notification) {
var containerExtent = notification.metrics.viewportDimension;
if (notification is ScrollUpdateNotification) {
_dragOffset -= notification.scrollDelta;
}
if (notification is OverscrollNotification) {
_dragOffset -= notification.overscroll;
}
NotificationListener<ScrollNotification>(
onNotification: (notification) {
// return true if
// the notification shouldn't be forwarded to any parent widgets
// false otherwise
_handleScrollNotification(notification);
return false;
},
child: child,