Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3708

Search functionality is not properly working

$
0
0

I have show loading in else conditionif there search controller contain text it show that card otherwise it show loading in every empty cardand if only one item is present than 13loading showingand also show loading that i discuss to add space Now instead of space it has loadingNow I want if there is search controller contain no text then it show one loading but my code show 14(length) loading 😥And Also i want the item in arrangement and don't show loading if there is an itemis present I think you understand very wellError

ListView.builder(                            itemCount: data.length,                            itemBuilder: (BuildContext context, int index) {                              final video = data[index];                              print("Length is ${snapshot.data!.length}");                             try {                               if (_searchController.text                                   .toString()                                   .isEmpty) {                                 return InkWell(                                   onTap: () {                                     Navigator.push(                                       context,                                       MaterialPageRoute(                                         builder: (builder) =>                                             video_detail(                                               data: video['snippet']["publishTime"],                                               title: video['snippet']["title"],                                               videoId: video["id"]["videoId"],                                               channelTitle: video["snippet"]["channelTitle"],                                               descrption: video["snippet"]["description"],                                               thumbnail: video['snippet']['thumbnails']['medium']['url'],                                             ),                                       ),                                     );                                   },                                   child: Card(                                     margin: const EdgeInsets.all(8),                                     color: AppColor.grey200,                                     child: Column(                                       crossAxisAlignment: CrossAxisAlignment                                           .start,                                       children: [                                         Image.network(                                           video['snippet']['thumbnails']['medium']['url'],                                           width: MediaQuery                                               .of(context)                                               .size                                               .width * 1,                                         ),                                         Padding(                                           padding: const EdgeInsets.all(8),                                           child: Column(                                             crossAxisAlignment: CrossAxisAlignment                                                 .start,                                             children: [                                               Text(                                                 video['snippet']['title'],                                                 style: const TextStyle(                                                   fontWeight: FontWeight.bold,                                                   fontSize: 18,                                                 ),                                               ),                                             ],                                           ),                                         ),                                       ],                                     ),                                   ),                                 );                               }                               else if (video['snippet']['title']                                   .toString()                                   .toLowerCase()                                   .contains(_searchController.text.toString()                                   .trim()                                   .toLowerCase()) ||                                   video['snippet']['description']                                       .toString()                                       .toLowerCase()                                       .contains(_searchController.text.toString()                                       .trim()                                       .toLowerCase())                               ) {                                 return Padding(                                   padding: const EdgeInsets.all(10.0),                                   child: Card(                                     child: ListTile(                                       leading: Image.network(                                         video['snippet']['thumbnails']['medium']['url'],                                         width: 50,                                       ),                                       title: Text(video['snippet']['title']),                                       trailing: Icon(Icons.arrow_forward),                                       onTap: () {                                         Navigator.push(                                           context,                                           MaterialPageRoute(                                             builder: (builder) =>                                                 video_detail(                                                   data: video['snippet']["publishTime"],                                                   title: video['snippet']["title"],                                                   videoId: video["id"]["videoId"],                                                   channelTitle: video["snippet"]["channelTitle"],                                                   descrption: video["snippet"]["description"],                                                   thumbnail: video['snippet']['thumbnails']['medium']['url'],                                                 ),                                           ),                                         );                                       },                                     ),                                   ),                                 );                               }                               else{                                 return Center(                                   child: LoadingAnimationWidget.fourRotatingDots(                                     color: AppColor.grey,                                     size: 200,                                   ),                                 );                               }                             }                             catch(e){                               print(e);                             }                            },                          ),

Viewing all articles
Browse latest Browse all 3708


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>