Select Git revision
searchpage.dart
-
Daniel Furaev authoredDaniel Furaev authored
searchpage.dart 3.21 KiB
import 'package:flutter/material.dart';
import 'dart:developer';
import 'package:ambient/services/spotify.dart';
import 'package:ambient/homepage.dart';
import 'package:flutter/services.dart';
import 'package:spotify_sdk/spotify_sdk.dart';
class StateSearcgPage extends StatefulWidget {
const StateSearcgPage({super.key});
@override
State<StateSearcgPage> createState() => SearchPage();
}
class SearchPage extends State<StateSearcgPage> {
final controller = TextEditingController();
Spotify spotifyApi = Spotify();
HomePage homePage = HomePage();
List<Song> songs = List.empty(growable: true);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: [
const SizedBox(
height: 20,
),
TextField(
onChanged: (value) {
updateList(value);
setState(() {
log(songs.length.toString());
songs;
});
},
decoration: const InputDecoration(
labelText: 'Search', suffixIcon: Icon(Icons.search)),
),
const SizedBox(
height: 20,
),
Expanded(
child: ListView.builder(
itemCount: songs.length,
itemBuilder: ((context, index) {
Song song = songs[index];
return GestureDetector(
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
Image.network(
song.image,
height: 50,
width: 50,
fit: BoxFit.fill,
),
Container(
width: 10,
),
Expanded(child: Text(song.name)),
Expanded(child: Text(song.artist)),
],
),
),