Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
my-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
juseong ahn
my-first-flutter
Commits
543f3da9
Commit
543f3da9
authored
1 year ago
by
ahnjuseong
Browse files
Options
Downloads
Patches
Plain Diff
7단계 완료
parent
98995d82
No related branches found
No related tags found
1 merge request
!1
Roll Packages from 611aea1657fb to 28d126c54c63 (1 revision) (#145690)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
.github/workflows/flutter_application_1/assign/lib/main.dart
+93
-33
93 additions, 33 deletions
.github/workflows/flutter_application_1/assign/lib/main.dart
with
93 additions
and
33 deletions
.github/workflows/flutter_application_1/assign/lib/main.dart
+
93
−
33
View file @
543f3da9
import
'package:english_words/english_words.dart'
;
import
'package:english_words/english_words.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:provider/provider.dart'
;
import
'package:provider/provider.dart'
;
void
main
()
{
void
main
()
{
...
@@ -46,13 +47,77 @@ class MyAppState extends ChangeNotifier {
...
@@ -46,13 +47,77 @@ class MyAppState extends ChangeNotifier {
}
}
}
}
class
MyHomePage
extends
StatelessWidget
{
class
MyHomePage
extends
StatefulWidget
{
@override
State
<
MyHomePage
>
createState
()
=
>
_MyHomePageState
();
}
class
_MyHomePageState
extends
State
<
MyHomePage
>
{
var
selectedIndex
=
0
;
// ← Add this property.
@override
Widget
build
(
BuildContext
context
)
{
Widget
page
;
switch
(
selectedIndex
)
{
case
0
:
page
=
GeneratorPage
();
break
;
case
1
:
page
=
Placeholder
();
break
;
default
:
throw
UnimplementedError
(
'no widget for
$selectedIndex
'
);
}
return
LayoutBuilder
(
builder:
(
context
,
constraints
)
{
return
Scaffold
(
body:
Row
(
children:
[
SafeArea
(
child:
NavigationRail
(
extended:
constraints
.
maxWidth
>
=
600
,
// ← Here.
destinations:
[
NavigationRailDestination
(
icon:
Icon
(
Icons
.
home
),
label:
Text
(
'Home'
),
),
NavigationRailDestination
(
icon:
Icon
(
Icons
.
favorite
),
label:
Text
(
'Favorites'
),
),
],
selectedIndex:
selectedIndex
,
// ← Change to this.
onDestinationSelected:
(
value
)
{
// ↓ Replace print with this.
setState
(()
{
selectedIndex
=
value
;
});
},
),
),
Expanded
(
child:
Container
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
primaryContainer
,
child:
page
,
//GeneratorPage(),
),
),
],
),
);
}
);
}
}
class
GeneratorPage
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
;
var
pair
=
appState
.
current
;
// ↓ Add this.
IconData
icon
;
IconData
icon
;
if
(
appState
.
favorites
.
contains
(
pair
))
{
if
(
appState
.
favorites
.
contains
(
pair
))
{
icon
=
Icons
.
favorite
;
icon
=
Icons
.
favorite
;
...
@@ -60,8 +125,7 @@ class MyHomePage extends StatelessWidget {
...
@@ -60,8 +125,7 @@ class MyHomePage extends StatelessWidget {
icon
=
Icons
.
favorite_border
;
icon
=
Icons
.
favorite_border
;
}
}
return
Scaffold
(
return
Center
(
body:
Center
(
child:
Column
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
...
@@ -70,8 +134,6 @@ class MyHomePage extends StatelessWidget {
...
@@ -70,8 +134,6 @@ class MyHomePage extends StatelessWidget {
Row
(
Row
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
children:
[
children:
[
// ↓ And this.
ElevatedButton
.
icon
(
ElevatedButton
.
icon
(
onPressed:
()
{
onPressed:
()
{
appState
.
toggleFavorite
();
appState
.
toggleFavorite
();
...
@@ -80,7 +142,6 @@ class MyHomePage extends StatelessWidget {
...
@@ -80,7 +142,6 @@ class MyHomePage extends StatelessWidget {
label:
Text
(
'Like'
),
label:
Text
(
'Like'
),
),
),
SizedBox
(
width:
10
),
SizedBox
(
width:
10
),
ElevatedButton
(
ElevatedButton
(
onPressed:
()
{
onPressed:
()
{
appState
.
getNext
();
appState
.
getNext
();
...
@@ -91,7 +152,6 @@ class MyHomePage extends StatelessWidget {
...
@@ -91,7 +152,6 @@ class MyHomePage extends StatelessWidget {
),
),
],
],
),
),
),
);
);
}
}
}
}
...
...
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