Skip to content

Instantly share code, notes, and snippets.

View nxcco's full-sized avatar

Nico Teufel nxcco

View GitHub Profile
@nxcco
nxcco / sliver_layout_delegate.dart
Created September 24, 2021 11:04
This code snippets provide a delegate to build separators in a SliverList. Original code from https://github.com/BreX900/easy_widget. I rewrote it, so that it's null-safety conform.
import 'package:flutter/widgets.dart';
class SliverLayoutDelegate extends SliverChildBuilderDelegate {
SliverLayoutDelegate({
bool addAutomaticKeepAlives = true,
bool addRepaintBoundaries = true,
bool addSemanticIndexes = true,
SemanticIndexCallback? semanticIndexCallback,
int semanticIndexOffset = 0,
required int childCount,
import 'package:flutter/widgets.dart';
import 'dart:math';
class SnappingListView extends StatefulWidget {
final Axis scrollDirection;
final ScrollController? controller;
final IndexedWidgetBuilder? itemBuilder;
final List<Widget>? children;
final int? itemCount;
import 'package:flutter/widgets.dart';
class ColumnBuilder extends StatelessWidget {
final IndexedWidgetBuilder itemBuilder;
final MainAxisAlignment mainAxisAlignment;
final MainAxisSize mainAxisSize;
final CrossAxisAlignment crossAxisAlignment;
final TextDirection? textDirection;
final VerticalDirection verticalDirection;
final int itemCount;
@nxcco
nxcco / cloud_firestore_mocks_extension.dart
Last active May 31, 2020 17:32
This extension makes testing easier, regarding populating the fake database. Also, it adds a convenient way for checking whether the database was successfully modified by another function.
import 'dart:convert';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_mocks/cloud_firestore_mocks.dart';
import 'package:collection/collection.dart';
extension MockFirestoreTesting on MockFirestoreInstance {
/// Populates the [MockFirestoreInstance] with data from a JSON-String.
Future<void> populate(String jsonSource) async {
final Map<String, dynamic> sourceMap = json.decode(jsonSource);