Skip to content

Instantly share code, notes, and snippets.

View rrousselGit's full-sized avatar
🎯
Fluttering

Remi Rousselet rrousselGit

🎯
Fluttering
View GitHub Profile
@rrousselGit
rrousselGit / main.dart
Created December 5, 2018 14:29
Stateless widget
class StatelessExample extends StatelessWidget {
final int foo;
final int bar;
const StatelessExample({Key key, this.foo, this.bar}) : super(key: key);
@override
Widget build(BuildContext context) {
return Text('$foo $bar');
}
@rrousselGit
rrousselGit / main.dart
Created December 5, 2018 15:11
function widget
Widget statelessExample(BuildContext context, { Key key, int foo, int bar }) {
return Text('$foo $bar');
}
@rrousselGit
rrousselGit / main.dart
Last active December 5, 2018 15:42
functional_widget
import 'package:flutter/widgets.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
part 'main.g.dart';
@widget
Widget statelessExample({int foo, int bar}) {
return Text('$foo $bar');
}
@rrousselGit
rrousselGit / main.g.dart
Created December 5, 2018 15:41
functional_widget2
part of 'main.dart';
class StatelessExample extends StatelessWidget {
const Foo({Key key, this.foo, this.bar}) : super(key: key);
final int foo;
final int bar;
@override
Widget build(BuildContext _context) {
enum CounterEvent {
increment,
decrement,
}
class Counter extends Store<int, CounterEvent> {
Counter() : super(initialState: 0);
@override
int reducer(int previousState, CounterEvent action) {
import 'package:vanilla/reducer_provider.dart';
enum _Action {
increment,
decrement,
}
class MyStore extends ReducerStore<int, _Action> {
MyStore() : super(0);
// ignore_for_file: public_member_api_docs
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';
/// A provider that exposes a [ValueNotifier] in two independent pieces.
///
/// [StoreProvider] will expose both [ValueNotifier] and [ValueNotifier.value] independently
/// to its dependents.
class BlocProvider<Value, Bloc extends _bloc.Bloc<dynamic, Value>>
extends ValueDelegateWidget<Bloc> implements SingleChildCloneableWidget {
/// Allows to specify parameters to [BlocProvider].
BlocProvider({
Key key,
@required ValueBuilder<Bloc> builder,
UpdateShouldNotify<Value> updateShouldNotify,
UpdateShouldNotify<Value> blocUpdateShouldNotify,
Disposer<Bloc> dispose,
Widget child,
class UserDetails {
UserDetails(this.id);
final int id;
}
class User extends StatefulWidget {
const User({Key key, this.id, this.builder, this.child}) : super(key: key);
final int id;
class ProviderToStream<T> extends StatefulWidget
implements SingleChildCloneableWidget {
const ProviderToStream({Key key, this.builder, this.child}) : super(key: key);
final ValueWidgetBuilder<Stream<T>> builder;
final Widget child;
@override
_ProviderToStreamState<T> createState() => _ProviderToStreamState<T>();