Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MyFlutter
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
정 원빈
MyFlutter
Commits
d18dda1f
Commit
d18dda1f
authored
2 months ago
by
wonbin
Browse files
Options
Downloads
Patches
Plain Diff
myflutter
parent
af2865a0
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
+97
-27
97 additions, 27 deletions
lib/main.dart
with
97 additions
and
27 deletions
lib/main.dart
+
97
−
27
View file @
d18dda1f
...
...
@@ -47,20 +47,50 @@ class MyAppState extends ChangeNotifier {
// ...
// ...
// ...
// ...
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
=
FavoritesPage
();
break
;
default
:
throw
UnimplementedError
(
'no widget for
$selectedIndex
'
);
}
// ...
return
LayoutBuilder
(
builder:
(
context
,
constrains
)
{
return
Scaffold
(
body:
Row
(
children:
[
SafeArea
(
child:
NavigationRail
(
extended:
false
,
extended:
constrains
.
maxWidth
>
=
600
,
destinations:
[
NavigationRailDestination
(
icon:
Icon
(
Icons
.
home
),
...
...
@@ -71,24 +101,33 @@ class _MyHomePageState extends State<MyHomePage> {
label:
Text
(
'Favorites'
),
),
],
selectedIndex:
0
,
selectedIndex:
selectedIndex
,
// ← Change to this.
onDestinationSelected:
(
value
)
{
print
(
'selected:
$value
'
);
// ↓ Replace print with this.
setState
(()
{
selectedIndex
=
value
;
});
},
),
),
Expanded
(
child:
Container
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
primaryContainer
,
child:
GeneratorP
age
()
,
child:
p
age
,
),
),
],
),
);
}
);
}
}
// ...
class
GeneratorPage
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -135,6 +174,37 @@ class GeneratorPage extends StatelessWidget {
// ...
class
FavoritesPage
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
var
appState
=
context
.
watch
<
MyAppState
>();
if
(
appState
.
favorites
.
isEmpty
)
{
return
Center
(
child:
Text
(
'No favorites yet.'
),
);
}
return
ListView
(
children:
[
Padding
(
padding:
const
EdgeInsets
.
all
(
20
),
child:
Text
(
'You have '
'
${appState.favorites.length}
favorites:'
),
),
for
(
var
pair
in
appState
.
favorites
)
ListTile
(
leading:
Icon
(
Icons
.
favorite
),
title:
Text
(
pair
.
asLowerCase
),
),
],
);
}
}
// ...
// ...
// ...
class
BigCard
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