hypen 0.2.0+1
hypen: ^0.2.0+1 copied to clipboard
A set of libraries that help you design robust, testable, and maintainable apps.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:hypen/hypen.dart';
part 'main.hypen_state.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
body: Center(
child: CounterWidget(),
),
),
);
}
}
class CounterWidget extends HypenWidget {
const CounterWidget({super.key});
@override
Widget build(BuildContext context) {
final (myState, setMyState) = useMyState();
final (family, setFamily) = useParameterizedCounter(10, 20)();
return Column(
children: [
GestureDetector(
onTap: () {
setMyState(myState..a += 1);
},
child: Text(
'Count: ${myState.a}',
style: const TextStyle(fontSize: 30),
),
),
GestureDetector(
onTap: () => setFamily(family + 1),
child: Text('Family: $family'),
),
],
);
}
}
@HypenState()
MyState myState() {
return MyState(0);
}
class MyState {
MyState(this.a);
int a;
void asdf() {}
}
@HypenState()
int parameterizedCounter(int a, int b) {
final (myState, _) = useMyState();
return a + b + myState.a;
}