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
Show 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 {
...
@@ -27,6 +27,7 @@ class MyApp extends StatelessWidget {
}
}
}
}
class
MyAppState
extends
ChangeNotifier
{
class
MyAppState
extends
ChangeNotifier
{
var
current
=
WordPair
.
random
();
var
current
=
WordPair
.
random
();
...
@@ -53,17 +54,31 @@ class MyHomePage extends StatefulWidget {
...
@@ -53,17 +54,31 @@ class MyHomePage extends StatefulWidget {
State
<
MyHomePage
>
createState
()
=>
_MyHomePageState
();
State
<
MyHomePage
>
createState
()
=>
_MyHomePageState
();
}
}
class
_MyHomePag
State
extends
State
<
MyHomePage
>
{
class
_MyHomePag
e
State
extends
State
<
MyHomePage
>
{
var
selectedIndex
=
0
;
var
selectedIndex
=
0
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
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
(
return
Scaffold
(
body:
Row
(
body:
Row
(
children:
[
children:
[
SafeArea
(
SafeArea
(
child:
NavigationRail
(
child:
NavigationRail
(
extended:
false
,
extended:
constraints
.
maxWidth
>=
600
,
destinations:
[
destinations:
[
NavigationRailDestination
(
NavigationRailDestination
(
icon:
Icon
(
Icons
.
home
),
icon:
Icon
(
Icons
.
home
),
...
@@ -86,13 +101,15 @@ class _MyHomePag State extends State<MyHomePage> {
...
@@ -86,13 +101,15 @@ class _MyHomePag State extends State<MyHomePage> {
Expanded
(
Expanded
(
child:
Container
(
child:
Container
(
color:
Theme
.
of
(
context
).
colorScheme
.
primaryContainer
,
color:
Theme
.
of
(
context
).
colorScheme
.
primaryContainer
,
child:
GeneratorPage
()
,
child:
page
,
),
),
),
),
],
],
),
),
);
);
}
}
);
}
}
}
...
@@ -170,3 +187,26 @@ class BigCard extends StatelessWidget {
...
@@ -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