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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lee Jaehyeok
first_flutter
Commits
a0d60d54
Commit
a0d60d54
authored
8 months ago
by
Lee Jaehyeok
Browse files
Options
Downloads
Patches
Plain Diff
codelab7
parent
9c100443
Branches
Branches containing commit
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
+91
-30
91 additions, 30 deletions
lib/main.dart
with
91 additions
and
30 deletions
lib/main.dart
+
91
−
30
View file @
a0d60d54
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
()
{
...
@@ -45,7 +46,70 @@ class MyAppState extends ChangeNotifier {
...
@@ -45,7 +46,70 @@ 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
;
@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
,
destinations:
[
NavigationRailDestination
(
icon:
Icon
(
Icons
.
home
),
label:
Text
(
'Home'
),
),
NavigationRailDestination
(
icon:
Icon
(
Icons
.
favorite
),
label:
Text
(
'Favorites'
),
),
],
selectedIndex:
selectedIndex
,
onDestinationSelected:
(
value
)
{
setState
(()
{
selectedIndex
=
value
;
});
},
),
),
Expanded
(
child:
Container
(
color:
Theme
.
of
(
context
)
.
colorScheme
.
primaryContainer
,
child:
page
,
),
),
],
),
);
}
);
}
}
class
GeneratorPage
extends
StatelessWidget
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
var
appState
=
context
.
watch
<
MyAppState
>();
var
appState
=
context
.
watch
<
MyAppState
>();
...
@@ -58,8 +122,7 @@ class MyHomePage extends StatelessWidget {
...
@@ -58,8 +122,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:
[
...
@@ -76,7 +139,6 @@ class MyHomePage extends StatelessWidget {
...
@@ -76,7 +139,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
();
...
@@ -87,7 +149,6 @@ class MyHomePage extends StatelessWidget {
...
@@ -87,7 +149,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