Skip to content

Commit 5a3b5ee

Browse files
authored
chore: release url_launcher_service v.1.0.0 (#1)
2 parents c1113ff + 4843a24 commit 5a3b5ee

File tree

8 files changed

+147
-10
lines changed

8 files changed

+147
-10
lines changed

.github/workflows/main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ concurrency:
55
cancel-in-progress: true
66

77
on:
8+
push:
9+
branches:
10+
- main
811
pull_request:
912
branches:
1013
- main

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
* feat: initial release of `url_launcher_service` 🎉

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing to Url Launcher Service
2+
3+
First off, thanks for taking the time to contribute!
4+
5+
The following is a set of guidelines for contributing to the library and related packages. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
6+
7+
## Proposing a Change
8+
9+
We recommend filing an issue if you intend to change the public API or make any non-trivial changes to the implementation. It lets us reach an agreement on your proposal before you put significant effort into it.
10+
11+
If you’re only fixing a bug, it’s fine to submit a pull request right away, but we still recommend filing an issue detailing what you’re fixing. It is helpful if we don’t accept that specific fix but want to keep track of the issue.
12+
13+
## Creating a Pull Request
14+
15+
Before creating a pull request please:
16+
17+
1. Fork the repository and create your branch from `main`.
18+
1. Install all dependencies (`flutter packages get` or `pub get`).
19+
1. Squash your commits and ensure you have a meaningful commit message.
20+
1. If you’ve fixed a bug or added code that should be tested, add tests!
21+
Pull Requests without 100% test coverage will not be approved.
22+
1. Ensure the test suite passes.
23+
1. If you've changed the public API, make sure to update/add documentation.
24+
1. Format your code (`dart format .`).
25+
1. Analyze your code (`dart analyze --fatal-infos --fatal-warnings .`).
26+
1. Create the Pull Request.
27+
1. Verify that all status checks are passing.
28+
29+
While the prerequisites above must be satisfied before having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted.
30+
31+
## Getting in Touch
32+
33+
If you want to just ask a question or get feedback on an idea, you can post it as a GitHub issue.
34+
35+
## License
36+
37+
By contributing to animated_svg, you agree that your contributions will be licensed under its [license](LICENSE).

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023, BBK Development
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
# Url Launcher Service
1+
# <p align="center">Url Launcher Service</p>
22

3+
<div align="center">
4+
5+
[![url_launcher_service][build_status_badge]][workflow_link]
6+
![coverage][coverage_badge]
37
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
48
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
5-
[![License: MIT][license_badge]][license_link]
9+
[![License: BSD-3-Clause][license_badge]][license_link]
10+
11+
</div>
612

7-
A Very Good Project created by Very Good CLI.
13+
This service wraps the [url_launcher][url_launcher_link] and provides secure usage of the plugin by handling exceptions.
814

915
## Installation 💻
1016

@@ -15,6 +21,9 @@ Add `url_launcher_service` to your `pubspec.yaml`:
1521
```yaml
1622
dependencies:
1723
url_launcher_service:
24+
git:
25+
url: https://github.com/BBKDevelopment/Url-Launcher-Service.git
26+
ref: v1.0.0
1827
```
1928
2029
Install it:
@@ -57,10 +66,14 @@ genhtml coverage/lcov.info -o coverage/
5766
open coverage/index.html
5867
```
5968

69+
[url_launcher_link]: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher
70+
[workflow_link]: https://github.com/BBKDevelopment/Url-Launcher-Service/actions/workflows/main.yaml
71+
[build_status_badge]: https://github.com/BBKDevelopment/Url-Launcher-Service/actions/workflows/main.yaml/badge.svg
72+
[coverage_badge]: coverage_badge.svg
6073
[flutter_install_link]: https://docs.flutter.dev/get-started/install
6174
[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions
62-
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
63-
[license_link]: https://opensource.org/licenses/MIT
75+
[license_badge]: https://img.shields.io/badge/license-BSD%203%E2%80%93Clause-blue.svg
76+
[license_link]: https://opensource.org/licenses/bsd-3-clause
6477
[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only
6578
[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only
6679
[mason_link]: https://github.com/felangel/mason

lib/src/url_launcher_service.dart

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:developer';
22

3+
import 'package:flutter/foundation.dart';
34
import 'package:url_launcher/url_launcher.dart';
45

56
/// An exception thrown when the email could not be sent.
@@ -19,7 +20,21 @@ class UrlLaunchException implements Exception {}
1920
/// {@endtemplate}
2021
class UrlLauncherService {
2122
/// {@macro url_launcher_service}
22-
const UrlLauncherService();
23+
const UrlLauncherService() : _urlLauncherResponse = null;
24+
25+
/// A named constructor of the [UrlLauncherService] for testing purposes in
26+
/// which it is possible to predefine some variables.
27+
///
28+
/// ```dart
29+
/// final urlLauncherService = UrlLauncherService.test(
30+
/// urlLauncherResponse: true,
31+
/// );
32+
/// ```
33+
@visibleForTesting
34+
const UrlLauncherService.test({required bool urlLauncherResponse})
35+
: _urlLauncherResponse = urlLauncherResponse;
36+
37+
final bool? _urlLauncherResponse;
2338

2439
/// Sends an email to the given [emailUri].
2540
///
@@ -28,7 +43,7 @@ class UrlLauncherService {
2843
try {
2944
if (!emailUri.isScheme('mailto')) throw Exception();
3045

31-
final isSuccess = await launchUrl(emailUri);
46+
final isSuccess = _urlLauncherResponse ?? await launchUrl(emailUri);
3247

3348
if (!isSuccess) throw Exception();
3449
} catch (_) {
@@ -44,7 +59,7 @@ class UrlLauncherService {
4459
try {
4560
if (!url.isScheme('http') && !url.isScheme('https')) throw Exception();
4661

47-
final isSuccess = await launchUrl(url);
62+
final isSuccess = _urlLauncherResponse ?? await launchUrl(url);
4863

4964
if (!isSuccess) throw Exception();
5065
} catch (_) {

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: url_launcher_service
2-
description: A Very Good Project created by Very Good CLI.
3-
version: 0.1.0+1
2+
description: Url Launcher Service
3+
version: 1.0.0
44
publish_to: none
55

66
environment:

test/src/url_launcher_service_test.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,47 @@ import 'package:flutter_test/flutter_test.dart';
44
import 'package:url_launcher_service/url_launcher_service.dart';
55

66
void main() {
7+
late UrlLauncherService sut;
8+
79
group('UrlLauncherService', () {
810
test('can be instantiated', () {
911
expect(UrlLauncherService(), isNotNull);
1012
});
13+
14+
test('can send email', () async {
15+
sut = UrlLauncherService.test(urlLauncherResponse: true);
16+
17+
expect(
18+
() => sut.sendEmail(emailUri: Uri(scheme: 'mailto')),
19+
isA<void>(),
20+
);
21+
});
22+
23+
test('can throw SendEmailException when could not send email', () async {
24+
sut = UrlLauncherService.test(urlLauncherResponse: false);
25+
26+
expect(
27+
() => sut.sendEmail(emailUri: Uri(scheme: 'mailto')),
28+
throwsA(isA<SendEmailException>()),
29+
);
30+
});
31+
32+
test('can launch url', () async {
33+
sut = UrlLauncherService.test(urlLauncherResponse: true);
34+
35+
expect(
36+
() => sut.launch(url: Uri(scheme: 'https')),
37+
isA<void>(),
38+
);
39+
});
40+
41+
test('can throw UrlLaunchException when could not launch url', () async {
42+
sut = UrlLauncherService.test(urlLauncherResponse: false);
43+
44+
expect(
45+
() => sut.launch(url: Uri(scheme: 'https')),
46+
throwsA(isA<UrlLaunchException>()),
47+
);
48+
});
1149
});
1250
}

0 commit comments

Comments
 (0)