From 2df27b610d164ce73cc514066cd633714f0f67a8 Mon Sep 17 00:00:00 2001 From: kim hakjun <swkhj2022@ajou.ac.kr> Date: Wed, 5 Jun 2024 19:20:50 +0900 Subject: [PATCH] 4 stage --- lib/main.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 1e4fe6d..43d0537 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'), + ), + ], ), ); -- GitLab