Skip to content

support page-level #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change log

## 2.0.1
oktoast support page level.

you can use oktoast wrap your Scaffold.

## 2.0.0
use BuildContext cache. then `showToast` not need context, you can use the `showToast` in anywhere.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ And you can completely customize the style of toast, because now you can use `sh

```yaml
dependencies:
oktoast: ^2.0.0
oktoast: ^2.0.1
```

2. import library in dart file
Expand Down
6 changes: 2 additions & 4 deletions example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Container(
width: 40.0,
height: 40.0,
color: Colors.grey.withOpacity(0.3),
color: Colors.grey.withOpacity(0.3),
child: Icon(
Icons.add,
size: 30.0,
Expand All @@ -75,9 +75,7 @@ class _MyHomePageState extends State<MyHomePage> {
duration: Duration(seconds: 3),
);

setState(() {

});
setState(() {});
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/oktoast.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library oktoast;

export 'src/toast.dart' show showToast,showToastWidget, OKToast, ToastPosition;
export 'src/toast.dart' show showToast, showToastWidget, OKToast, ToastPosition;
26 changes: 20 additions & 6 deletions lib/src/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class OKToast extends StatefulWidget {
const OKToast({
Key key,
@required this.child,
this.textStyle = const TextStyle(fontSize: 15.0),
this.textStyle,
this.radius = 10.0,
this.position = ToastPosition.center,
Color backgroundColor,
Expand Down Expand Up @@ -79,11 +79,21 @@ class _OKToastState extends State<OKToast> {
textDirection: TextDirection.ltr,
);

var typography = Typography(platform: TargetPlatform.android);
final TextTheme defaultTextTheme = typography.white;

TextStyle textStyle = widget.textStyle ??
defaultTextTheme.body1.copyWith(
fontSize: 15.0,
fontWeight: FontWeight.normal,
color: Colors.white,
);

return _ToastTheme(
child: w,
backgroundColor: widget.backgroundColor,
radius: widget.radius,
textStyle: widget.textStyle,
textStyle: textStyle,
position: widget.position,
);
}
Expand Down Expand Up @@ -205,11 +215,14 @@ class ToastPosition {

const ToastPosition({this.align = Alignment.center, this.offset = 0.0});

static const center = const ToastPosition(align: Alignment.center, offset: 0.0);
static const center =
const ToastPosition(align: Alignment.center, offset: 0.0);

static const bottom = const ToastPosition(align: Alignment.bottomCenter, offset: -30.0);
static const bottom =
const ToastPosition(align: Alignment.bottomCenter, offset: -30.0);

static const top = const ToastPosition(align: Alignment.topCenter, offset: 75.0);
static const top =
const ToastPosition(align: Alignment.topCenter, offset: 75.0);
}

class _ToastTheme extends InheritedWidget {
Expand All @@ -232,5 +245,6 @@ class _ToastTheme extends InheritedWidget {
Widget child,
}) : super(child: child);

static _ToastTheme of(BuildContext context) => context.inheritFromWidgetOfExactType(_ToastTheme);
static _ToastTheme of(BuildContext context) =>
context.inheritFromWidgetOfExactType(_ToastTheme);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: oktoast
description: A pure flutter toast library, easy to use. You can use this library to achieve the same effect as Android toast. Support custom style/widget.
version: 2.0.0
version: 2.0.1
author: Caijinglong<[email protected]>
homepage: https://github.com/OpenFlutter/flutter_oktoast
email: [email protected]
Expand Down