Skip to content

Commit

Permalink
[Modify] Enhance Search Functionality with Debouncing, Error Handling…
Browse files Browse the repository at this point in the history
…, and Video Player Resizing

Merge pull request #4 from nisargpro/fix's_and_changes
  • Loading branch information
kananinirav authored Mar 19, 2024
2 parents 17a6558 + 379f5b0 commit eb357a9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 45 deletions.
34 changes: 23 additions & 11 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/material.dart';
import '/screens/player.dart';
import '../model/channel.dart';
Expand All @@ -16,6 +18,7 @@ class _HomeState extends State<Home> {
TextEditingController searchController = TextEditingController();
final ChannelsProvider channelsProvider = ChannelsProvider();
bool _isLoading = true;
Timer? _debounceTimer;

@override
void initState() {
Expand All @@ -24,19 +27,28 @@ class _HomeState extends State<Home> {
}

Future<void> fetchData() async {
final data = await channelsProvider.fetchM3UFile();
setState(() {
channels = data;
filteredChannels = data;
_isLoading = false;
});
try {
final data = await channelsProvider.fetchM3UFile();
setState(() {
channels = data;
filteredChannels = data;
_isLoading = false;
});
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('There was a problem finding the data')));
}
}

void filterChannels(query) {
final data = channelsProvider.filterChannels(query);
setState(() {
filteredChannels = data;
_isLoading = false;
void filterChannels(String query) async {
if (_debounceTimer != null) {
_debounceTimer!.cancel();
}
_debounceTimer = Timer(const Duration(milliseconds: 500), () async {
final filteredData = channelsProvider.filterChannels(query);
setState(() {
filteredChannels = filteredData;
});
});
}

Expand Down
7 changes: 5 additions & 2 deletions lib/screens/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ class _PlayerState extends State<Player> {
: _channelNotFound
? const Text('Channel not available now',
style: TextStyle(fontSize: 24.0))
: Chewie(
controller: chewieController,
: SizedBox(
height: MediaQuery.of(context).size.height * 0.5,
child: Chewie(
controller: chewieController,
),
),
),
);
Expand Down
38 changes: 7 additions & 31 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.7"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "04be76c4a4bb50f14904e64749237e541e7c7bcf7ec0b196907322ab5d2fc739"
url: "https://pub.dev"
source: hosted
version: "9.0.16"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: b06739349ec2477e943055aea30172c5c7000225f79dad4702e2ec0eda79a6ff
url: "https://pub.dev"
source: hosted
version: "1.0.5"
lints:
dependency: transitive
description:
Expand All @@ -196,18 +180,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.10.0"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -373,14 +357,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.3"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
wakelock_plus:
dependency: transitive
description:
Expand All @@ -401,10 +377,10 @@ packages:
dependency: transitive
description:
name: web
sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.4.0"
version: "0.3.0"
win32:
dependency: transitive
description:
Expand All @@ -422,5 +398,5 @@ packages:
source: hosted
version: "6.5.0"
sdks:
dart: ">=3.3.0-148.0.dev <4.0.0"
dart: ">=3.2.1 <4.0.0"
flutter: ">=3.16.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=3.3.0-148.0.dev <4.0.0'
sdk: '>=3.2.1 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down

0 comments on commit eb357a9

Please sign in to comment.