Skip to content
Snippets Groups Projects
Commit 2df27b61 authored by kim hakjun's avatar kim hakjun
Browse files

4 stage

parent 6483e878
Branches
No related tags found
No related merge requests found
...@@ -27,6 +27,12 @@ class MyApp extends StatelessWidget { ...@@ -27,6 +27,12 @@ class MyApp extends StatelessWidget {
class MyAppState extends ChangeNotifier { class MyAppState extends ChangeNotifier {
var current = WordPair.random(); var current = WordPair.random();
// ↓ Add this.
void getNext() {
current = WordPair.random();
notifyListeners();
}
} }
class MyHomePage extends StatelessWidget { class MyHomePage extends StatelessWidget {
...@@ -37,8 +43,17 @@ class MyHomePage extends StatelessWidget { ...@@ -37,8 +43,17 @@ class MyHomePage extends StatelessWidget {
return Scaffold( return Scaffold(
body: Column( body: Column(
children: [ children: [
Text('A random idea:'), Text('A random AWESOME idea:'),
Text(appState.current.asLowerCase), Text(appState.current.asLowerCase),
// ↓ Add this.
ElevatedButton(
onPressed: () {
appState.getNext(); // ← This instead of print().
},
child: Text('Next'),
),
], ],
), ),
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment