Commit 071defcd by Karthik Ponnam

7.0.3

parent 26f44d61
## [7.0.3]
- FToast now Fade when showing and hiding the toast
- Toast backgroud now supports transparency
- Bug fixes
## [7.0.2] ## [7.0.2]
- iOS Toast behind keyboard fixed. #203 - iOS Toast behind keyboard fixed. #203
......
...@@ -32,7 +32,7 @@ This one has limited features and no control over UI ...@@ -32,7 +32,7 @@ This one has limited features and no control over UI
```yaml ```yaml
# add this line to your dependencies # add this line to your dependencies
fluttertoast: ^7.0.2 fluttertoast: ^7.0.3
``` ```
```dart ```dart
...@@ -59,9 +59,9 @@ Fluttertoast.showToast( ...@@ -59,9 +59,9 @@ Fluttertoast.showToast(
| toastLength | Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) |Toast.LENGTH_SHORT | | toastLength | Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) |Toast.LENGTH_SHORT |
| gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM (Web Only supports top, bottom) | ToastGravity.BOTTOM | | gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM (Web Only supports top, bottom) | ToastGravity.BOTTOM |
| timeInSecForIosWeb | int (only for ios) | 1 | | timeInSecForIosWeb | int (only for ios) | 1 |
| backgroundColor | Colors.red |Colors.black | | backgroundColor | Colors.red |null |
| textcolor | Colors.white |Colors.white | | textcolor | Colors.white |null |
| fontSize | 16.0 (float) | 16.0 | | fontSize | 16.0 (float) | null |
| webShowClose | false (bool) | false | | webShowClose | false (bool) | false |
| webBgColor | String (hex Color) | linear-gradient(to right, #00b09b, #96c93d) | | webBgColor | String (hex Color) | linear-gradient(to right, #00b09b, #96c93d) |
| webPosition | String (`left`, `center` or `right`) | right | | webPosition | String (`left`, `center` or `right`) | right |
......
...@@ -49,7 +49,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler { ...@@ -49,7 +49,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
context.resources.getDrawable(R.drawable.corner) context.resources.getDrawable(R.drawable.corner)
} }
if(bgcolor != null && gradientDrawable != null) { if(bgcolor != null && gradientDrawable != null) {
gradientDrawable.setColorFilter(bgcolor.toInt(), PorterDuff.Mode.SRC_ATOP) gradientDrawable.setColorFilter(bgcolor.toInt(), PorterDuff.Mode.SRC)
} }
text.background = gradientDrawable text.background = gradientDrawable
if(textSize != null) { if(textSize != null) {
......
...@@ -7,42 +7,42 @@ packages: ...@@ -7,42 +7,42 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.2" version: "2.5.0-nullsafety"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0-nullsafety"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.1.0-nullsafety.2"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.3" version: "1.2.0-nullsafety"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.1.0-nullsafety"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.13" version: "1.15.0-nullsafety.2"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -56,7 +56,7 @@ packages: ...@@ -56,7 +56,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
...@@ -78,28 +78,28 @@ packages: ...@@ -78,28 +78,28 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "7.0.2" version: "7.0.3"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.8" version: "0.12.10-nullsafety"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.8" version: "1.3.0-nullsafety.2"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0-nullsafety"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -111,56 +111,56 @@ packages: ...@@ -111,56 +111,56 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0-nullsafety"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.5" version: "1.10.0-nullsafety"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0-nullsafety"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" version: "1.1.0-nullsafety"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.2.0-nullsafety"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.17" version: "0.2.19-nullsafety"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.0-nullsafety.2"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.1.0-nullsafety.2"
sdks: sdks:
dart: ">=2.9.0-14.0.dev <3.0.0" dart: ">=2.10.0-0.0.dev <2.10.0"
flutter: ">=1.10.0" flutter: ">=1.10.0"
...@@ -72,6 +72,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; ...@@ -72,6 +72,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSNumber *size = call.arguments[@"size"]; NSNumber *size = call.arguments[@"size"];
NSNumber *fontSize = call.arguments[@"fontSize"]; NSNumber *fontSize = call.arguments[@"fontSize"];
if(fontSize == nil) {
fontSize = 16.0;
}
CGFloat cgf = [fontSize doubleValue]; CGFloat cgf = [fontSize doubleValue];
int time = 1; int time = 1;
@try { @try {
......
...@@ -19,7 +19,7 @@ class Fluttertoast { ...@@ -19,7 +19,7 @@ class Fluttertoast {
{@required String msg, {@required String msg,
Toast toastLength, Toast toastLength,
int timeInSecForIosWeb = 1, int timeInSecForIosWeb = 1,
double fontSize = 16.0, double fontSize,
ToastGravity gravity, ToastGravity gravity,
Color backgroundColor, Color backgroundColor,
Color textColor, Color textColor,
...@@ -94,8 +94,10 @@ class FToast { ...@@ -94,8 +94,10 @@ class FToast {
Overlay.of(context).insert(_entry); Overlay.of(context).insert(_entry);
_timer = Timer(_toastEntry.duration, () { _timer = Timer(_toastEntry.duration, () {
Future.delayed(Duration(milliseconds: 360), () {
removeCustomToast(); removeCustomToast();
}); });
});
} }
removeCustomToast() { removeCustomToast() {
...@@ -119,18 +121,16 @@ class FToast { ...@@ -119,18 +121,16 @@ class FToast {
ToastGravity gravity, ToastGravity gravity,
}) { }) {
OverlayEntry newEntry = OverlayEntry(builder: (context) { OverlayEntry newEntry = OverlayEntry(builder: (context) {
return _getPostionWidgetBasedOnGravity(child, gravity); return _getPostionWidgetBasedOnGravity(child, gravity, toastDuration);
}); });
_overlayQueue.add(_ToastEntry(entry: newEntry, duration: toastDuration ?? Duration(seconds: 2))); _overlayQueue.add(_ToastEntry(entry: newEntry, duration: toastDuration ?? Duration(seconds: 2)));
if (_timer == null) _showOverlay(); if (_timer == null) _showOverlay();
} }
_getPostionWidgetBasedOnGravity(Widget child, ToastGravity gravity) { _getPostionWidgetBasedOnGravity(Widget child, ToastGravity gravity, Duration duration) {
Widget newChild = Center( Widget newChild = _ToastStateFul(
child: Material( child,
color: Colors.transparent, duration,
child: child,
),
); );
switch (gravity) { switch (gravity) {
case ToastGravity.TOP: case ToastGravity.TOP:
...@@ -170,3 +170,69 @@ class _ToastEntry { ...@@ -170,3 +170,69 @@ class _ToastEntry {
_ToastEntry({this.entry, this.duration}); _ToastEntry({this.entry, this.duration});
} }
class _ToastStateFul extends StatefulWidget {
_ToastStateFul(this.child, this.duration, {Key key}) : super(key: key);
final Widget child;
final Duration duration;
@override
ToastStateFulState createState() => ToastStateFulState();
}
class ToastStateFulState extends State<_ToastStateFul> with SingleTickerProviderStateMixin {
bool _visible = false;
showIt() {
_animationController.forward();
}
hideIt() {
_animationController.reverse();
}
AnimationController _animationController;
Animation _fadeAnimation;
@override
void initState() {
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 350),
);
_fadeAnimation = CurvedAnimation(parent: _animationController, curve: Curves.easeIn);
super.initState();
showIt();
Future.delayed(widget.duration, () {
hideIt();
});
}
@override
void deactivate() {
_animationController.stop();
super.deactivate();
}
@override
void dispose() {
_animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return FadeTransition(
opacity: _fadeAnimation,
child: Center(
child: Material(
color: Colors.transparent,
child: widget.child,
),
),
);
}
}
...@@ -65,9 +65,6 @@ class FluttertoastWebPlugin { ...@@ -65,9 +65,6 @@ class FluttertoastWebPlugin {
html.querySelector('head').children.addAll(tags); html.querySelector('head').children.addAll(tags);
await Future.wait(loading); await Future.wait(loading);
// addHtmlToast();
// addHtmlToast();
} }
addHtmlToast( addHtmlToast(
......
...@@ -7,14 +7,14 @@ packages: ...@@ -7,14 +7,14 @@ packages:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.1.0-nullsafety.2"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.13" version: "1.15.0-nullsafety.2"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
...@@ -31,7 +31,7 @@ packages: ...@@ -31,7 +31,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.8" version: "1.3.0-nullsafety.2"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -43,14 +43,14 @@ packages: ...@@ -43,14 +43,14 @@ packages:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.0-nullsafety.2"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.1.0-nullsafety.2"
sdks: sdks:
dart: ">=2.9.0-14.0.dev <3.0.0" dart: ">=2.10.0-0.0.dev <2.10.0"
flutter: ">=1.10.0" flutter: ">=1.10.0"
name: fluttertoast name: fluttertoast
description: Toast Library for Flutter, Easily create toast messages in single line of code description: Toast Library for Flutter, Easily create toast messages in single line of code
version: 7.0.2 version: 7.0.3
homepage: https://github.com/PonnamKarthik/FlutterToast homepage: https://github.com/PonnamKarthik/FlutterToast
issue_tracker: https://github.com/ponnamkarthik/FlutterToast/issues issue_tracker: https://github.com/ponnamkarthik/FlutterToast/issues
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment