diff --git a/CHANGELOG.md b/CHANGELOG.md index bb428a4..771a3d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index 9dbb167..f6af9e3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/example/main.dart b/example/main.dart index a581a5e..cbdda6d 100644 --- a/example/main.dart +++ b/example/main.dart @@ -61,7 +61,7 @@ class _MyHomePageState extends State { 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, @@ -75,9 +75,7 @@ class _MyHomePageState extends State { duration: Duration(seconds: 3), ); - setState(() { - - }); + setState(() {}); } @override diff --git a/lib/oktoast.dart b/lib/oktoast.dart index 1a350d5..86a8a35 100644 --- a/lib/oktoast.dart +++ b/lib/oktoast.dart @@ -1,3 +1,3 @@ library oktoast; -export 'src/toast.dart' show showToast,showToastWidget, OKToast, ToastPosition; +export 'src/toast.dart' show showToast, showToastWidget, OKToast, ToastPosition; diff --git a/lib/src/toast.dart b/lib/src/toast.dart index b76ffca..cebccdd 100644 --- a/lib/src/toast.dart +++ b/lib/src/toast.dart @@ -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, @@ -79,11 +79,21 @@ class _OKToastState extends State { 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, ); } @@ -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 { @@ -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); } diff --git a/pubspec.yaml b/pubspec.yaml index 6ff0232..a3a60a1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/OpenFlutter/flutter_oktoast email: cjl_spy@163.com