Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amse
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matis SPINELLI
amse
Commits
1d7268c6
Commit
1d7268c6
authored
Feb 07, 2024
by
Timothe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mercredi 9h14 -6 ça fait pi
parent
555f9f42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
31 deletions
+71
-31
main.dart
tuto1/lib/main.dart
+71
-31
No files found.
tuto1/lib/main.dart
View file @
1d7268c6
...
...
@@ -27,6 +27,7 @@ class MyApp extends StatelessWidget {
}
}
class
MyAppState
extends
ChangeNotifier
{
var
current
=
WordPair
.
random
();
...
...
@@ -53,44 +54,60 @@ class MyHomePage extends StatefulWidget {
State
<
MyHomePage
>
createState
()
=>
_MyHomePageState
();
}
class
_MyHomePag
State
extends
State
<
MyHomePage
>
{
class
_MyHomePag
e
State
extends
State
<
MyHomePage
>
{
var
selectedIndex
=
0
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Row
(
children:
[
SafeArea
(
child:
NavigationRail
(
extended:
false
,
destinations:
[
NavigationRailDestination
(
icon:
Icon
(
Icons
.
home
),
label:
Text
(
'Home'
),
Widget
page
;
switch
(
selectedIndex
)
{
case
0
:
page
=
GeneratorPage
();
break
;
case
1
:
page
=
FavoritePage
();
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
)
{
print
(
'selected:
$value
'
);
setState
(()
{
selectedIndex
=
value
;
});
},
),
NavigationRailDestination
(
icon:
Icon
(
Icons
.
favorite
),
label:
Text
(
'Favorites'
),
),
Expanded
(
child:
Container
(
color:
Theme
.
of
(
context
).
colorScheme
.
primaryContainer
,
child:
page
,
),
],
selectedIndex:
selectedIndex
,
onDestinationSelected:
(
value
)
{
print
(
'selected:
$value
'
);
setState
(()
{
selectedIndex
=
value
;
});
},
),
),
Expanded
(
child:
Container
(
color:
Theme
.
of
(
context
).
colorScheme
.
primaryContainer
,
child:
GeneratorPage
(),
),
),
],
),
],
),
);
}
);
}
}
...
...
@@ -170,3 +187,26 @@ class BigCard extends StatelessWidget {
}
}
class
FavoritePage
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
var
appState
=
context
.
watch
<
MyAppState
>();
var
favorites
=
appState
.
favorites
;
return
Scaffold
(
body:
Column
(
children:
[
Text
(
'Favorites'
),
for
(
var
fav
in
favorites
)
Text
(
fav
.
asLowerCase
),
],)
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment