Skip to content

Instantly share code, notes, and snippets.

View chimon2000's full-sized avatar

Ryan chimon2000

View GitHub Profile
@chimon2000
chimon2000 / mobx.page.dart
Last active November 3, 2020 05:48
state_example: mobx page
class MobxPage extends StatefulWidget {
const MobxPage({Key key}) : super(key: key);
@override
_MobxPageState createState() => _MobxPageState();
}
class _MobxPageState extends State<MobxPage> {
var _notesStore = Notes();
TextEditingController _controller;
@chimon2000
chimon2000 / main.dart
Last active November 3, 2020 04:36
state_example: binder root
void main() {
// For widgets to be able to read app state, we need to wrap the entire
// application in a "BinderScope" widget.
runApp(BinderScope(child: App()));
}
@chimon2000
chimon2000 / notes.dart
Last active November 3, 2020 05:30
state_example: binder notes
// We create a "state ref", which will store a reference to NotesState.
final notesRef = StateRef(NotesState.initial());
@chimon2000
chimon2000 / notes.viewlogic.dart
Last active November 3, 2020 05:29
state_example: notes viewlogic
// We create a "logic ref", which will store a reference to NotesViewLogic.
final notesViewLogicRef = LogicRef((scope) => NotesViewLogic(scope));
class NotesViewLogic with Logic {
const NotesViewLogic(this.scope);
@override
final Scope scope;
void addNote() {
@chimon2000
chimon2000 / binder.page.dart
Last active November 3, 2020 04:45
state_example: binder page
class BinderPage extends StatefulWidget {
const BinderPage({Key key}) : super(key: key);
@override
_BinderPageState createState() => _BinderPageState();
}
class _BinderPageState extends State<BinderPage> {
TextEditingController _controller;
@chimon2000
chimon2000 / main.dart
Last active November 3, 2020 04:40
state_example: bloc main
void main() {
// For widgets to be able to read providers, we need to wrap the entire
// application in a "BlocProvider" widget.
// This is where the state of our NotesCubit will be stored.
runApp(BlocProvider<NotesCubit>(create: (_) => NotesCubit(), child: App()));
}
@chimon2000
chimon2000 / main.dart
Last active February 9, 2022 19:52
state_example: app widget
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
@chimon2000
chimon2000 / get_it_web_bug.dart
Last active April 1, 2021 23:15
get_it_web_bug.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
Future<void> main() async {
await initApp();
runApp(MyApp());
}
@chimon2000
chimon2000 / main.dart
Created May 9, 2022 07:07
Riverpod Countdown
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
void main() {
runApp(const ProviderScope(child: MyApp()));
}
class MyApp extends StatelessWidget {
@chimon2000
chimon2000 / main.dart
Last active May 3, 2023 18:58
Counter Notifier
import 'package:flutter/material.dart';
void main() => runApp(CounterApp());
class CounterApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,