Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MoCo SoSe22 Christopher_Luzzi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Luzzi
MoCo SoSe22 Christopher_Luzzi
Commits
765769b5
Commit
765769b5
authored
3 years ago
by
Christopher Luzzi
Browse files
Options
Downloads
Patches
Plain Diff
Aufgabe 2 fertig
parent
f14699b2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/main.dart
+12
-6
12 additions, 6 deletions
lib/main.dart
with
12 additions
and
6 deletions
lib/main.dart
+
12
−
6
View file @
765769b5
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:html'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'package:http/http.dart'
as
http
;
Future
<
List
<
Album
>>
fetchAlbum
()
async
{
Future
<
List
<
Album
>>
fetchAlbum
()
async
{
final
List
<
Album
>
jsonResponse
=
[];
final
response
=
await
http
final
response
=
await
http
.
get
(
Uri
.
parse
(
'https://jsonplaceholder.typicode.com/albums/'
));
.
get
(
Uri
.
parse
(
'https://jsonplaceholder.typicode.com/albums/'
));
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
statusCode
==
200
)
{
// If the server did return a 200 OK response,
// If the server did return a 200 OK response,
// then parse the JSON.
// then parse the JSON.
return
jsonResponse
.
map
((
data
)
=
>
Album
.
fromJson
(
jsonDecode
(
response
.
body
)))
.
toList
();
var
jsonResponse
=
jsonDecode
(
response
.
body
)
as
List
;
return
jsonResponse
.
map
((
data
)
=
>
Album
.
fromJson
(
data
))
.
toList
();
}
else
{
}
else
{
// If the server did not return a 200 OK response,
// If the server did not return a 200 OK response,
// then throw an exception.
// then throw an exception.
...
@@ -78,11 +79,16 @@ class _MyAppState extends State<MyApp> {
...
@@ -78,11 +79,16 @@ class _MyAppState extends State<MyApp> {
padding:
const
EdgeInsets
.
all
(
16.0
),
padding:
const
EdgeInsets
.
all
(
16.0
),
itemCount:
snapshot
.
data
!.
length
,
itemCount:
snapshot
.
data
!.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
){
itemBuilder:
(
BuildContext
context
,
int
index
){
return
ListTile
(
return
Card
(
title:
Text
(
child:
ListTile
(
snapshot
.
data
!
[
index
]
.
title
,
leading:
CircleAvatar
(
backgroundColor:
Colors
.
blue
,
child:
Text
(
snapshot
.
data
!
[
index
]
.
title
[
0
])
),
),
);
title:
Center
(
child:
Text
(
snapshot
.
data
!
[
index
]
.
title
)),
)
);
},
},
);
);
}
}
...
...
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