Skip to content

Instantly share code, notes, and snippets.

View schultek's full-sized avatar

Kilian Schulte schultek

View GitHub Profile
@schultek
schultek / selection_transformer.dart
Last active April 11, 2024 01:49
A widget that transforms the text selection when copied.
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
typedef SelectionTransform = String Function(Iterable<String>);
/// A widget that transforms the text selection when copied.
///
/// This uses the [SelectionContainer] with a custom [SelectionContainerDelegate] to override the
/// [getSelectedContent] method with a custom implementation.
///
@schultek
schultek / riverpod_context_extension.dart
Created November 7, 2021 19:50
Proposal for a context extension for riverpod, including a working context.watch implementation.
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
/*
============
EXAMPLE PART
============
*/
// case 1: basic provider
import 'package:dart_json_mapper/dart_json_mapper.dart';
import 'main.mapper.g.dart';
@jsonSerializable
class Car {
String model;
int? miles;
List<String>? passengers;
Car(this.model, this.miles, this.passengers);
@schultek
schultek / nested_will_pop_scope.dart
Last active March 26, 2024 15:24
An improved WillPopScope widget to allow for nested navigators. See https://github.com/flutter/flutter/issues/47088
import 'package:flutter/material.dart';
class NestedWillPopScope extends StatefulWidget {
const NestedWillPopScope({
Key? key,
required this.child,
required this.onWillPop,
}) : super(key: key);
final Widget child;
{"networkStateVersions":{"MVG_RAD":1488789},"fullDataSet":{"MVG_RAD":true},"onlyNearbyData":false,"failingProviderIds":[],"addedBikes":[{"id":"96048","created":null,"updated":1522583999000,"bikeNumber":96048,"latitude":0.0,"longitude":0.0,"currentStationID":null,"bikeState":"FREE","bikeType":"STANDARD","positionType":"IN_OPERATING_AREA","localized":false,"district":null},{"id":"96101","created":1522583997000,"updated":1522583997000,"bikeNumber":96101,"latitude":48.150386810302734,"longitude":11.544791221618652,"currentStationID":"dead08f4081592823ada3017f622c695","bikeState":"FREE","bikeType":"STANDARD","positionType":"STATION","localized":true,"district":"Neuhausen-Nymphenburg"},{"id":"96102","created":1522583997000,"updated":1522583997000,"bikeNumber":96102,"latitude":48.139400482177734,"longitude":11.588881492614746,"currentStationID":"98ee05824cb579da3539acb38e63d81c","bikeState":"FREE","bikeType":"STANDARD","positionType":"STATION","localized":true,"district":"Altstadt-Lehel"},{"id":"96103","created":152