Skip to content

Commit

Permalink
Merge pull request #2 from HadesPTIT/release/2.0.0
Browse files Browse the repository at this point in the history
Migrate to null-safety
  • Loading branch information
HadesPTIT authored Oct 17, 2021
2 parents 01b9457 + df6e023 commit 9afac39
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 245 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*.ipr
*.iws
.idea/
.fvm
.vscode

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ Support generate short link with 2 type

* Converts a long url to a Bitlink.
* Converts a long url to a Bitlink and sets additional parameters.

## [2.0.0]

Migrate to null-safety
94 changes: 9 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,85 +11,10 @@ First, you need to register account and get token from [here](https://bitly.com/

### Example

```dart
import 'package:flutter/material.dart';
import 'package:flutter_url_shortener/flutter_url_shortener.dart';
> Converts a long url to a Bitlink and sets additional parameters.
void main() {
/// Setup token key before using
FShort.instance.setup(token: 'a5xxx7a59eb1115b2dfdd3f0caa76d8cc592257d');
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _shortenURL = '';
String _customURL = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'https://www.google.com.vn',
),
Container(
alignment: Alignment.center,
child: Text(_shortenURL),
height: 60,
),
FlatButton(
color: Colors.blue,
child: Text('Shorten a link'),
onPressed: () => _genShortenUrl,
),
Container(
alignment: Alignment.center,
child: Text(_customURL),
height: 60,
),
FlatButton(
color: Colors.blue,
child: Text('Create a Bitlink'),
onPressed: () => _createBitLink,
),
],
),
),
);
}
void _genShortenUrl() {
try {
~~~dart
try {
FShort.instance
.generateShortenURL(longUrl: 'https://www.google.com.vn/')
.then((value) {
Expand All @@ -102,10 +27,12 @@ class _MyHomePageState extends State<MyHomePage> {
} on Exception catch (e) {
// TODO
}
}
~~~

void _createBitLink() {
try {
> Converts a long url to a Bitlink.
~~~dart
try {
FShort.instance
.createBitLink(
params: BitlyParams(
Expand All @@ -132,7 +59,4 @@ class _MyHomePageState extends State<MyHomePage> {
} on Exception catch (e) {
// TODO
}
}
}
```
~~~
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*.ipr
*.iws
.idea/
.fvm
.vscode

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
Expand Down
14 changes: 7 additions & 7 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use

import 'package:flutter/material.dart';
import 'package:flutter_url_shortener/flutter_url_shortener.dart';

Expand All @@ -17,15 +19,13 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
home: MyHomePage(),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;
MyHomePage({Key? key}) : super(key: key);

@override
_MyHomePageState createState() => _MyHomePageState();
Expand All @@ -39,7 +39,7 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
title: Text('Flutter Demo Home Page'),
),
body: Center(
child: Column(
Expand Down Expand Up @@ -80,7 +80,7 @@ class _MyHomePageState extends State<MyHomePage> {
.generateShortenURL(longUrl: 'https://www.google.com.vn/')
.then((value) {
setState(() {
_shortenURL = value.link;
_shortenURL = value.link!;
});
});
} on BitlyException catch (_) {
Expand Down Expand Up @@ -110,7 +110,7 @@ class _MyHomePageState extends State<MyHomePage> {
))
.then((value) {
setState(() {
_customURL = value.link;
_customURL = value.link!;
});
});
} on BitlyException catch (_) {
Expand Down
42 changes: 21 additions & 21 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,56 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.0.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -73,28 +73,28 @@ packages:
path: "/Users/huongpt45/Documents/FlutterDev/PACKAGE/flutter_url_shortener"
relative: false
source: path
version: "1.0.0"
version: "2.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -106,55 +106,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.4.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.12.0 <3.0.0"
Loading

0 comments on commit 9afac39

Please sign in to comment.