Skip to content

Instantly share code, notes, and snippets.

View chimon2000's full-sized avatar

Ryan chimon2000

View GitHub Profile

Keybase proof

I hereby claim:

  • I am chimon2000 on github.
  • I am chimon (https://keybase.io/chimon) on keybase.
  • I have a public key ASBC8JzAWtEGVqem8e2M5UfYTFCO2XaY42p0bce6fCtpdgo

To claim this, I am signing this object:

@chimon2000
chimon2000 / main.dart
Created February 26, 2020 20:32
Hello World
import 'package:flutter/material.dart';
void main() => runApp(
Center(
child: Text(
'Hello Charlotte Devs!',
textDirection: TextDirection.ltr,
),
),
);
@chimon2000
chimon2000 / cloudSettings
Last active March 5, 2020 07:06
Provider Widget Rebuild
{"lastUpload":"2020-03-05T07:06:07.448Z","extensionVersion":"v3.4.3"}
@chimon2000
chimon2000 / reducer_notifier.dart
Last active April 14, 2020 19:07
Reducer with State Notifier
import 'dart:async';
import 'package:state_notifier/state_notifier.dart';
class ReducerNotifier<State> extends StateNotifier<State> {
final Reducer<State> reducer;
ReducerNotifier(state, this.reducer) : super(state);
FutureOr<void> dispatch(Action action) async {
@chimon2000
chimon2000 / counter_page.dart
Created July 16, 2020 06:53
counter_page.dart
class CounterPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Counter')),
body: BlocBuilder<CounterCubit, int>(
builder: (context, count) => Center(child: Text('$count')),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
@chimon2000
chimon2000 / counter_bloc.dart
Last active July 16, 2020 07:06
Bloc counter
enum CounterEvent { increment }
class CounterBloc extends Bloc<CounterEvent, int> {
CounterBloc() : super(0);
@override
Stream<int> mapEventToState(CounterEvent event) async* {
switch (event) {
case CounterEvent.increment:
yield state + 1;
@chimon2000
chimon2000 / counter_cubit.dart
Created July 16, 2020 07:07
counter_cubit.dart
class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);
void increment() => emit(state + 1);
}
@chimon2000
chimon2000 / base_command.dart
Created October 22, 2020 00:54
Command Pattern in Dart (Cubit + GetIt)
import 'package:get_it/get_it.dart';
abstract class BaseCommand<T> {
GetIt getIt = GetIt.instance;
D locate<D>() => getIt.get<D>();
Future<T> run();
}
@chimon2000
chimon2000 / base_command.dart
Created October 27, 2020 06:17
Command Pattern in Dart (binder)
abstract class BaseCommand<T> {
BuildContext _context;
BaseCommand(this._context);
T locate<T>(LogicRef<T> ref) => _context.use(ref);
T read<T>(StateRef<T> ref) => _context.read(ref);
Future<T> run();
}
@chimon2000
chimon2000 / notes.cubit.dart
Created November 1, 2020 06:10
state_examples: notes cubit
class NotesCubit extends Cubit<NotesState> {
NotesCubit(): super(NotesState.initial());
void addNote() {
emit(state.copyWith(notes: state.notes.concat(state.input), input: ''));
}
void updateInput(String input) => emit(state.copyWith(input: input));
}