This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//avaliable in Dart 2.13 | |
typedef ProductList = List<Product>; | |
class ProductStore extends StreamStore<Exception, ProductList> { | |
final ProductRepository repository; | |
Counter({required this.repository}): super([]); | |
fetchProduct() async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter extends StreamStore<Exception, int> { | |
Counter(): super(0) | |
increment(){ | |
update(state + 1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# backup | |
docker run -v [volume]:/volume --rm loomchild/volume-backup backup - > [backupfile.tar.bz2] | |
# restore | |
cat [backupfile.tar.bz2] | docker run -i -v [volume2]:/volume --rm loomchild/volume-backup restore - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomePage extends StatelessWidget { | |
final counter = RxNotifier<int>(0); | |
_increment() => counter.value++; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text('Counter')), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomePage extends StatelessWidget { | |
final counter = ValueNotifier<int>(0); | |
_increment() => counter.value++; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text('Counter')), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Computed<T> extends ChangeNotifier implements ValueNotifier<T> { | |
final List<Listenable> values; | |
final T Function() resolver; | |
Listenable listenable; | |
T _value; | |
Computed(this.values, {this.resolver}) { | |
listenable = Listenable.merge(values)..addListener(_listener); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyGuard extends RouteGuard { | |
@override | |
Future<bool> canActivate(String path, ModularRoute router) async { | |
if (path == '/admin') { | |
return await UserService().isAdmin(); | |
} else { | |
return true; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// StartPage | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
// Nested Pages | |
body: RouterOutlet(), | |
// bottomBar | |
bottomNavigationBar: BottomNavigationBar( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
final List<ModularRoute> routes = [ | |
... | |
ChildRoute('/start', child: (_, args) => StartPage(), children: [ | |
ModuleRoute('/home', module: HomeModule()), | |
ChildRoute('/config', child: (_, args) => ConfigPage()), | |
ChildRoute('/perfil', child: (_, args) => PerfilPage()), | |
]), | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
final List<ModularRoute> routes = [ | |
ChildRoute('/', child: (_, args) => HomePage()), | |
ChildRoute('/details/:id', | |
child: (_, args) => DetailsPage(id: args?.params?['id'])), | |
]; |