Skip to content

Instantly share code, notes, and snippets.

View rrousselGit's full-sized avatar
🎯
Fluttering

Remi Rousselet rrousselGit

🎯
Fluttering
View GitHub Profile
import 'package:flutter_web/material.dart';
import 'package:flutter_web_test/flutter_web_test.dart';
import 'package:flutter_web_ui/ui.dart' as ui;
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Transform.translate(
offset: Offset(100, 0),
child: Transform.rotate(
@rrousselGit
rrousselGit / main.dart
Last active October 14, 2019 12:03
scoped inherited widget
class _Type implements Type {
_Type(this.key);
final Object key;
@override
operator ==(Object other) => other is _Type && other.key == key;
@override
int get hashCode => key.hashCode;
@rrousselGit
rrousselGit / union.dart
Last active October 21, 2019 15:24
type safe Unions
enum _Union {
first,
second,
third,
forth,
fifth,
sixth,
seventh,
eighth,
ninth,
void main() {
A a = B();
if (a.property is int) {
print(a.property.runtimeType); // double
}
}
class A {
A(this.property);
abstract class Locator {
Resolver<T, Locator> resolve<T>() => Resolver(this);
}
class Resolver<T, L extends Locator> {
Resolver(this._locator);
final L _locator;
}
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@rrousselGit
rrousselGit / main.dart
Created January 8, 2020 17:23
Inherited notification listener
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class InheritedNotificationListener<T> extends InheritedWidget {
InheritedNotificationListener({Key key, this.listener, Widget child})
@rrousselGit
rrousselGit / main.dart
Last active January 8, 2020 17:49
InheritedNotificationListener with subclass and event blubbling
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class _InheritedNotificationListener extends InheritedWidget {
_InheritedNotificationListener({
@rrousselGit
rrousselGit / main.dart
Last active February 8, 2022 13:53
Provider dartpad
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:flutter/foundation.dart';
import 'dart:collection';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
class Person with DiagnosticableTreeMixin {
Person({this.name, this.age});
@rrousselGit
rrousselGit / main.dart
Last active March 3, 2020 15:50
SliderIterableChildDelegate
class SliverIterableChildDelegate extends SliverChildDelegate {
SliverIterableChildDelegate(this.children);
final Iterable<Widget> children;
int _lastAccessedIndex;
Iterator<Widget> _lastAccessedIterator;
@override
Widget build(BuildContext context, int index) {
if (_lastAccessedIndex == null || _lastAccessedIndex > index) {