Skip to content

Instantly share code, notes, and snippets.

View HenriqueNas's full-sized avatar
:shipit:
damn.. Dart is really cool

HenriqueNas HenriqueNas

:shipit:
damn.. Dart is really cool
View GitHub Profile
@HenriqueNas
HenriqueNas / page_state_notifier.dart
Last active August 7, 2024 15:41
Easiest way to scale your management of your Flutter page/widget state without any package.
import 'package:flutter/widgets.dart';
/// Helper class to manage the state of a page/widget. </br>
class PageStateNotifier<Error> extends ChangeNotifier {
PageState _state = PageState.idle;
/// The current [PageState].
/// This is the main state of the notifier
/// and should be used to control the UI.
PageState get state => _state;
@HenriqueNas
HenriqueNas / main.dart
Created August 16, 2024 18:28
STATE Design Pattern in Dart
void main() {
final porta = Porta(PortaAberta());
print(porta.estado);
porta.fechar();
print(porta.estado);
porta.trancar();
print(porta.estado);
porta.abrir();
print(porta.estado);