Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
first-flutter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kim hakjun
first-flutter
Commits
e16ba582
Commit
e16ba582
authored
1 year ago
by
kim hakjun
Browse files
Options
Downloads
Patches
Plain Diff
5 stage
parent
2df27b61
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/main.dart
+60
-17
60 additions, 17 deletions
lib/main.dart
with
60 additions
and
17 deletions
lib/main.dart
+
60
−
17
View file @
e16ba582
...
@@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
...
@@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
title:
'Namer App'
,
title:
'Namer App'
,
theme:
ThemeData
(
theme:
ThemeData
(
useMaterial3:
true
,
useMaterial3:
true
,
colorScheme:
ColorScheme
.
fromSeed
(
seedColor:
Color
s
.
deepOrange
),
colorScheme:
ColorScheme
.
fromSeed
(
seedColor:
Color
.
fromARGB
(
255
,
218
,
235
,
241
)
),
),
),
home:
MyHomePage
(),
home:
MyHomePage
(),
),
),
...
@@ -28,34 +28,77 @@ class MyApp extends StatelessWidget {
...
@@ -28,34 +28,77 @@ class MyApp extends StatelessWidget {
class
MyAppState
extends
ChangeNotifier
{
class
MyAppState
extends
ChangeNotifier
{
var
current
=
WordPair
.
random
();
var
current
=
WordPair
.
random
();
// ↓ Add this.
void
getNext
()
{
void
getNext
()
{
current
=
WordPair
.
random
();
current
=
WordPair
.
random
();
notifyListeners
();
notifyListeners
();
}
}
// ↓ Add the code below.
var
favorites
=
<
WordPair
>[];
void
toggleFavorite
()
{
if
(
favorites
.
contains
(
current
))
{
favorites
.
remove
(
current
);
}
else
{
favorites
.
add
(
current
);
}
notifyListeners
();
}
}
}
class
MyHomePage
extends
StatelessWidget
{
class
MyHomePage
extends
StatelessWidget
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
var
appState
=
context
.
watch
<
MyAppState
>();
var
appState
=
context
.
watch
<
MyAppState
>();
var
pair
=
appState
.
current
;
return
Scaffold
(
return
Scaffold
(
body:
Column
(
body:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Text
(
'A random AWESOME idea:'
),
BigCard
(
pair:
pair
),
Text
(
appState
.
current
.
asLowerCase
),
SizedBox
(
height:
10
),
// ↓ Add this.
ElevatedButton
(
ElevatedButton
(
onPressed:
()
{
onPressed:
()
{
appState
.
getNext
();
// ← This instead of print().
appState
.
getNext
();
},
},
child:
Text
(
'Next'
),
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
(
20
),
// ↓ Make the following change.
child:
Text
(
pair
.
asLowerCase
,
style:
style
,
semanticsLabel:
"
${pair.first}
${pair.second}
"
,
),
),
);
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment