Skip to content

Commit

Permalink
Migrated from uni_links to app_links package (#2710)
Browse files Browse the repository at this point in the history
* Migrated from uni_links to app_links package

* added stackTrace rules

* added TestWidgetsFlutterBinding.ensureInitialized()

* removed duplicate typo WidgetsFlutterBinding

* added minor changes

---------

Co-authored-by: Satyam Jha <[email protected]>
  • Loading branch information
may-tas and Satyam Jha authored Jan 23, 2025
1 parent 0bf048e commit a144878
Show file tree
Hide file tree
Showing 7 changed files with 714 additions and 281 deletions.
4 changes: 4 additions & 0 deletions lib/locator.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:app_links/app_links.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:get_it/get_it.dart';
import 'package:image_cropper/image_cropper.dart';
Expand Down Expand Up @@ -177,4 +178,7 @@ Future<void> setupLocator() async {
locator.registerFactory(() => DirectChatViewModel());
locator.registerFactory(() => AccessScreenViewModel());
locator.registerFactory(() => UserProfileService());

//AppLinks
locator.registerSingleton(AppLinks());
}
10 changes: 6 additions & 4 deletions lib/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:app_links/app_links.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:talawa/constants/routing_constants.dart';
Expand All @@ -8,7 +9,6 @@ import 'package:talawa/locator.dart';
import 'package:talawa/models/mainscreen_navigation_args.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/utils/app_localization.dart';
import 'package:uni_links/uni_links.dart';

/// This widget return the SplashScreen. Splash Screen is the first screen that we see when we run our application. It is also known as Launch Screen.
class SplashScreen extends StatefulWidget {
Expand Down Expand Up @@ -43,7 +43,9 @@ class _SplashScreenState extends State<SplashScreen> {
/// **returns**:
/// None
Future<void> _handleInitialUri() async {
_sub = uriLinkStream.listen(
final appLinks = locator<AppLinks>();

_sub = appLinks.uriLinkStream.listen(
(Uri? uri) {
// After creating a State object and before calling initState, the framework
// "mounts" the State object by associating it with a BuildContext.
Expand All @@ -60,8 +62,8 @@ class _SplashScreenState extends State<SplashScreen> {
},
);
try {
// Retrieving the initial URI from getInitialUri function.
final uri = await getInitialUri();
// Retrieving the initial URI from getInitialLink function.
final uri = await appLinks.getInitialLink();
if (!mounted) return;
setState(() => _initialUri = uri);
} on PlatformException {
Expand Down
66 changes: 41 additions & 25 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.11.3"
app_links:
dependency: "direct main"
description:
name: app_links
sha256: "433df2e61b10519407475d7f69e470789d23d593f28224c38ba1068597be7950"
url: "https://pub.dev"
source: hosted
version: "6.3.3"
app_links_linux:
dependency: transitive
description:
name: app_links_linux
sha256: f5f7173a78609f3dfd4c2ff2c95bd559ab43c80a87dc6a095921d96c05688c81
url: "https://pub.dev"
source: hosted
version: "1.0.3"
app_links_platform_interface:
dependency: "direct main"
description:
name: app_links_platform_interface
sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
app_links_web:
dependency: transitive
description:
name: app_links_web
sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555
url: "https://pub.dev"
source: hosted
version: "1.0.4"
args:
dependency: transitive
description:
Expand Down Expand Up @@ -693,6 +725,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.1"
gtk:
dependency: transitive
description:
name: gtk
sha256: e8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c
url: "https://pub.dev"
source: hosted
version: "2.1.0"
hive:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1403,7 +1443,7 @@ packages:
source: hosted
version: "2.5.0+2"
stack_trace:
dependency: transitive
dependency: "direct main"
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
Expand Down Expand Up @@ -1529,30 +1569,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
uni_links:
dependency: "direct main"
description:
name: uni_links
sha256: "051098acfc9e26a9fde03b487bef5d3d228ca8f67693480c6f33fd4fbb8e2b6e"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
uni_links_platform_interface:
dependency: "direct main"
description:
name: uni_links_platform_interface
sha256: "929cf1a71b59e3b7c2d8a2605a9cf7e0b125b13bc858e55083d88c62722d4507"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
uni_links_web:
dependency: transitive
description:
name: uni_links_web
sha256: "7539db908e25f67de2438e33cc1020b30ab94e66720b5677ba6763b25f6394df"
url: "https://pub.dev"
source: hosted
version: "0.1.0"
url_launcher:
dependency: "direct main"
description:
Expand Down
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ dependencies:
# analyzer_plugin:
################################

app_links: ^6.3.3
app_links_platform_interface: ^2.0.2
auto_size_text: ^3.0.0
cached_network_image: ^3.4.1
clock: ^1.1.1
Expand Down Expand Up @@ -68,12 +70,11 @@ dependencies:
shared_preferences: ^2.3.3
shimmer: ^3.0.0
social_share: ^2.2.1
stack_trace: ^1.11.1
syncfusion_flutter_calendar: ^27.2.5
syncfusion_flutter_datepicker: ^27.2.5
timelines: ^0.1.0
tutorial_coach_mark: ^1.2.12
uni_links: ^0.5.1
uni_links_platform_interface: ^1.0.0
url_launcher: ^6.3.1
vibration: ^2.0.1
video_player: ^2.9.2
Expand Down
4 changes: 4 additions & 0 deletions test/helpers/test_locator.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: talawa_api_doc
// ignore_for_file: talawa_good_doc_comments

import 'package:app_links/app_links.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:get_it/get_it.dart';
import 'package:image_cropper/image_cropper.dart';
Expand Down Expand Up @@ -149,4 +150,7 @@ void testSetupLocator() {
locator.registerFactory(() => DirectChatViewModel());
locator.registerFactory(() => SelectContactViewModel());
locator.registerFactory(() => UserProfileService());

//AppLinks
locator.registerSingleton(AppLinks());
}
Loading

0 comments on commit a144878

Please sign in to comment.