Last active
November 9, 2020 21:43
-
-
Save antklim/6c2c99fcc5cab8dbf58817a8a1d089e1 to your computer and use it in GitHub Desktop.
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 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