Skip to content

Commit c031e63

Browse files
author
Phil
committed
init
0 parents  commit c031e63

13 files changed

Lines changed: 306 additions & 0 deletions

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/
4+
5+
# Avoid committing pubspec.lock for library packages; see
6+
# https://dart.dev/guides/libraries/private-files#pubspeclock.
7+
pubspec.lock

.idea/libraries/Dart_SDK.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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+
- Initial version.

LICENSE

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

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Encoder
2+
3+
This Dart package provides utility functions for encoding and decoding strings and JSON objects into safe URL formats. It's useful for scenarios where you need to encode data to be included in a URL, or decode data received from a URL.
4+
5+
## Features
6+
7+
Encode and decode strings to and from a URL-safe Base64 format.
8+
Encode and decode JSON objects to and from a URL-safe Base64 format.
9+
Getting Started
10+
To use this package, add encoder as a dependency in your pubspec.yaml file.
11+
12+
## Usage
13+
14+
Here's a simple example of using the Encoder class to encode and decode a string:
15+
16+
```dart
17+
import 'package:encoder/encoder.dart';
18+
19+
void main() {
20+
const originalText = 'Hello World!';
21+
final encodedText = Encoder.encodeString(originalText);
22+
print('Encoded Text: $encodedText');
23+
24+
final decodedText = Encoder.decodeString(encodedText);
25+
print('Decoded Text: $decodedText');
26+
}
27+
```
28+
29+
And here's an example of encoding and decoding a JSON object:
30+
31+
```dart
32+
import 'package:encoder/encoder.dart';
33+
34+
void main() {
35+
const originalJson = {
36+
'name': 'John Doe',
37+
'age': 30,
38+
'email': 'john.doe@gmail.com',
39+
'active': true,
40+
'roles': ['user', 'admin'],
41+
'address': {
42+
'street': '123 Main St',
43+
'city': 'Springfield',
44+
'state': 'IL',
45+
'zip': '62701',
46+
},
47+
'children': [
48+
{'name': 'Jane Doe', 'age': 5},
49+
{'name': 'Alex Doe', 'age': 8},
50+
],
51+
};
52+
53+
final encodedJson = Encoder.encodeJson(originalJson);
54+
print('Encoded JSON: $encodedJson');
55+
56+
final decodedJson = Encoder.decodeJson(encodedJson);
57+
print('Decoded JSON: $decodedJson');
58+
}
59+
```
60+
61+
## Additional Information
62+
63+
For more information, please refer to the Encoder class in the source code. If you have any issues or suggestions, feel free to open an issue on the project's GitHub page. Contributions are also welcome.

analysis_options.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
13+
14+
include: package:lints/recommended.yaml
15+
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

example/encoder_example.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:encoder/encoder.dart';
2+
3+
void main() {
4+
// Encode String
5+
print(Encoder.encodeString('Hello, World!'));
6+
// Decode String
7+
print(Encoder.decodeString('SGVsbG8sIFdvcmxkIQ%3D%3D'));
8+
9+
// Encode JSON
10+
print(Encoder.encodeJson({'message': 'Hello, World!'}));
11+
// Decode JSON
12+
print(Encoder.decodeJson('eyJtZXNzYWdlIjoiSGVsbG8sIFdvcmxkISJ9'));
13+
}

lib/encoder.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library;
2+
3+
export 'src/encoder_base.dart';

0 commit comments

Comments
 (0)