Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ambient
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Furaev
Ambient
Commits
61036409
Commit
61036409
authored
2 years ago
by
Erik Hinkelmanns
Browse files
Options
Downloads
Patches
Plain Diff
- fixed image bug for music bar
parent
c039ef05
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/homepage.dart
+2
-26
2 additions, 26 deletions
lib/homepage.dart
lib/main.dart
+49
-52
49 additions, 52 deletions
lib/main.dart
lib/widgets/musicPlayerState.dart
+3
-1
3 additions, 1 deletion
lib/widgets/musicPlayerState.dart
with
54 additions
and
79 deletions
lib/homepage.dart
+
2
−
26
View file @
61036409
...
...
@@ -118,7 +118,7 @@ class HomePage extends StatelessWidget {
fontWeight:
FontWeight
.
bold
,
color:
Colors
.
black
)),
MusicPlayerState
.
of
(
context
)
.
connected
?
spotifyImageWidget
(
track
.
imageUri
)
?
MusicPlayerState
.
of
(
context
)
.
spotifyImageWidget
()
:
const
Text
(
'Connect to see an image...'
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
...
...
@@ -157,31 +157,7 @@ class HomePage extends StatelessWidget {
);
}
Widget
spotifyImageWidget
(
ImageUri
image
)
{
return
FutureBuilder
(
future:
SpotifySdk
.
getImage
(
imageUri:
image
,
dimension:
ImageDimension
.
large
,
),
builder:
(
BuildContext
context
,
AsyncSnapshot
<
Uint8List
?
>
snapshot
)
{
if
(
snapshot
.
hasData
)
{
return
Image
.
memory
(
snapshot
.
data
!
);
}
else
if
(
snapshot
.
hasError
)
{
setStatus
(
snapshot
.
error
.
toString
());
return
SizedBox
(
width:
ImageDimension
.
large
.
value
.
toDouble
(),
height:
ImageDimension
.
large
.
value
.
toDouble
(),
child:
const
Center
(
child:
Text
(
'Error getting image'
)),
);
}
else
{
return
SizedBox
(
width:
ImageDimension
.
large
.
value
.
toDouble
(),
height:
ImageDimension
.
large
.
value
.
toDouble
(),
child:
const
Center
(
child:
Text
(
'Getting image...'
)),
);
}
});
}
Future
getPlayerState
()
async
{
try
{
...
...
This diff is collapsed.
Click to expand it.
lib/main.dart
+
49
−
52
View file @
61036409
...
...
@@ -109,8 +109,7 @@ class _HUDState extends State<HUD> {
},
),
],
),
);
));
}
}
...
...
@@ -123,11 +122,9 @@ class MusicBar extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
return
StreamBuilder
<
PlayerState
>(
stream:
SpotifySdk
.
subscribePlayerState
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
<
PlayerState
>
snapshot
)
{
builder:
(
BuildContext
context
,
AsyncSnapshot
<
PlayerState
>
snapshot
)
{
var
track
=
snapshot
.
data
?.
track
;
MusicPlayerState
.
of
(
context
)
.
currentTrackImageUri
=
track
?.
imageUri
;
MusicPlayerState
.
of
(
context
)
.
currentTrackImageUri
=
track
?.
imageUri
;
var
playerState
=
snapshot
.
data
;
if
(
playerState
==
null
||
track
==
null
)
{
return
const
Center
(
...
...
@@ -139,7 +136,7 @@ class MusicBar extends StatelessWidget {
color:
Colors
.
grey
,
child:
Row
(
children:
[
MusicPlayerState
.
of
(
context
)
.
spotifyImageWidget
()
,
MusicPlayerState
.
of
(
context
)
.
albumImage
,
playerState
.
isPaused
?
const
IconButton
(
icon:
Icon
(
Icons
.
play_arrow_outlined
),
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/musicPlayerState.dart
+
3
−
1
View file @
61036409
...
...
@@ -14,6 +14,7 @@ class MusicPlayerState extends InheritedWidget {
bool
connected
=
false
;
StreamController
<
void
>
rebuildStream
=
new
StreamController
.
broadcast
();
late
ImageUri
?
currentTrackImageUri
;
late
Image
albumImage
;
static
MusicPlayerState
?
maybeOf
(
BuildContext
context
)
=
>
context
.
dependOnInheritedWidgetOfExactType
<
MusicPlayerState
>();
...
...
@@ -76,7 +77,8 @@ class MusicPlayerState extends InheritedWidget {
),
builder:
(
BuildContext
context
,
AsyncSnapshot
<
Uint8List
?
>
snapshot
)
{
if
(
snapshot
.
hasData
)
{
return
Image
.
memory
(
snapshot
.
data
!
);
albumImage
=
Image
.
memory
(
snapshot
.
data
!
);
return
albumImage
;
}
else
if
(
snapshot
.
hasError
)
{
setStatus
(
snapshot
.
error
.
toString
());
return
SizedBox
(
...
...
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