Как искать песни в вашем списке FlutterAudioQuerry [закрыто]

      import 'screens/list_song.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

import 'package:flutter_audio_query/flutter_audio_query.dart';

class search extends StatefulWidget {
 @override
_searchState createState() => _searchState();
 }

 class _searchState extends State<search> {
 TextEditingController controller = TextEditingController();

 final FlutterAudioQuery audioQuery = FlutterAudioQuery();

 List<AlbumInfo> salbums = [];
List<SongInfo> ssongs = [];
@override
void initState() {
super.initState();
searchAlbums();
searchSongs();

}

        Future<List<AlbumInfo>> searchAlbums() async {
salbums = await audioQuery.searchAlbums();

}

        Future<List<SongInfo>> searchSongs() async {
ssongs = await audioQuery.searchSongs();
return ssongs;

}

       @override
 Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    backgroundColor: Colors.grey[900],
    toolbarHeight: 60.0,
    title: TextField(
      onChanged: (value) {
        setState(() {});
      },
      controller: controller,
      cursorColor: Colors.indigo[300],
      decoration: InputDecoration(
          hintText: " Search songs, albums, artist....",
          hintStyle: TextStyle(color: Colors.white),
          border: InputBorder.none,
          suffixIcon: IconButton(
              icon: Icon(Icons.search),
              color: Colors.indigo[300],
              onPressed: () {})),
      style: TextStyle(color: Colors.white, fontSize: 15.0),
    ),
  ),
  backgroundColor: Colors.grey[900],
  body: FutureBuilder(
      future: searchSongs(),
      builder: (context, item) {
        // Load items

        return ListView.builder(
          itemCount: ssongs.length,
          itemBuilder: (context, i) {
            if (controller.text.isEmpty) {
              return ListTile(
                title: Text(('${ssongs[i].title}')),
                subtitle: Text(('${ssongs[i].artist}')),
              );
            } else
              return ListTile(
                title: Text(('${ssongs[i].title}')),
              );
          },
        );
      }),
);

}}

         ///after running this code and input my text on the search bar it shows nothing.
  zzzzzzzz zzzzzzzz zzzzzzzz zzzzzzz zzzzz zzzzzz zzzzzz zzzzz zzzzz zzzzz zzzzzz zzzzzz .
   zzzzzz zzzzzzz zzzzzzz zzzzzz zzzzz zzzzz zzzz zzzzz zzz ssssss sssssss ssss ssss sss sss sss sss.
   sss ssss ssss sss ssss wwwww wwwww wwwww wwww wwwwww wwwww wwww wwwwww wwww wwww wwww www wwwwwwww wwwww wwwwwwww wwwwwww.
     wwww wwwww tttttttttttttttttttttttttt tttttttttttttttttttttttttttttt .
    ttttttttttttttttttttttttttt. 
 ttttttttttttttttttttttttttttt ttttttttttttttttttttttttttttttt.
 ttttttttttttttttttt ttttttttttttttttttttt .
  tttttttttttttttttttttttttttttttt t gggggggggggggggggggggggggggggggg//

сс ссс. sss ssss ssss sss ssss wwwww wwwww wwwww wwww wwwwww wwwww wwww wwwwww wwww wwww wwww www wwwwwwww wwwww wwwwwwww wwwwwww. wwww wwwww tttttttttttttttttttttttt tttttttttttttttttttttttttttttt. ttttttttttttttttttttttttttt. ttttttttttttttttttttttttttttt ttttttttttttttttttttttttttttt. ttttttttttttttttttt ttttttttttttttttttttt.

0 ответов

Другие вопросы по тегам