Skip to content

Instantly share code, notes, and snippets.

@antklim
Last active November 9, 2020 21:43
Show Gist options
  • Save antklim/6c2c99fcc5cab8dbf58817a8a1d089e1 to your computer and use it in GitHub Desktop.
Save antklim/6c2c99fcc5cab8dbf58817a8a1d089e1 to your computer and use it in GitHub Desktop.
class CalculusScreen extends StatefulWidget {
@override
_CalculusScreenState createState() => _CalculusScreenState();
}
class _CalculusScreenState extends State<CalculusScreen> {
num memory;
num calculatorResult; // current operation result
void onMemorise() {
setState(() {
memory = calculatorResult;
});
}
void onResetMemory() {
setState(() {
memory = null;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
...
// memory and callbacks passed to nested elements
MemoryInfo(memory: memory),
MemoryManagement(onMemorise: onMemorise, onResetMemory: onResetMemory),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment