diff --git a/lib/main.dart b/lib/main.dart index 1e4fe6dc96a8662d6a51e179ecf9b83b5b0cde99..43d05378111e377643876e54d9943b3f30b82c4e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -27,6 +27,12 @@ class MyApp extends StatelessWidget { class MyAppState extends ChangeNotifier { var current = WordPair.random(); + + // ↓ Add this. + void getNext() { + current = WordPair.random(); + notifyListeners(); + } } class MyHomePage extends StatelessWidget { @@ -37,8 +43,17 @@ class MyHomePage extends StatelessWidget { return Scaffold( body: Column( children: [ - Text('A random idea:'), + Text('A random AWESOME idea:'), Text(appState.current.asLowerCase), + + // ↓ Add this. + ElevatedButton( + onPressed: () { + appState.getNext(); // ← This instead of print(). + }, + child: Text('Next'), + ), + ], ), );