Compare commits

..

2 Commits

Author SHA1 Message Date
66e1f3a05b Begin styling the app. 2025-01-27 13:07:00 -07:00
0cd06931bb Get the button working. 2025-01-27 12:49:00 -07:00

View File

@ -14,10 +14,10 @@ class MyApp extends StatelessWidget {
return ChangeNotifierProvider(
create: (context) => MyAppState(),
child: MaterialApp(
title: 'Namer App',
title: 'Namer App (EXAMPLE PROJECT)',
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple),
),
home: MyHomePage(),
),
@ -26,21 +26,61 @@ class MyApp extends StatelessWidget {
}
class MyAppState extends ChangeNotifier {
var current = WordPair.random();
var current = WordPair.random();// ...
// ↓ Add this.
void getNext() {
current = WordPair.random();
notifyListeners();
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var appState = context.watch<MyAppState>();
var pair = appState.current;
return Scaffold(
body: Column(
children: [
Text('A random idea:'),
Text(appState.current.asLowerCase),
Text('A random wordpair:'),
BigCard(pair: pair),
ElevatedButton(
onPressed: () {
appState.getNext();
},
child: Text('Next'),
),
],
),
);
}
}
class BigCard extends StatelessWidget {
const BigCard({
super.key,
required this.pair,
});
final WordPair pair;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final style = theme.textTheme.displayMedium!.copyWith(
color: theme.colorScheme.onPrimary,
);
return Card(
color: theme.colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Text(pair.asLowerCase, style: style),
),
);
}
}