11import 'package:bot_toast/bot_toast.dart' ;
2+ import 'package:flutter/foundation.dart' ;
23import 'package:flutter/material.dart' ;
34import 'package:flutter_architecture_template/core/components/widgets/svg_widget.dart' ;
45import 'package:flutter_architecture_template/core/constants/project_variables.dart' ;
56import 'package:flutter_architecture_template/core/extension/context_extension.dart' ;
6-
7+ import '../../../product/navigator/app_router.dart' ;
78import '../../constants/colors.dart' ;
89import '../../constants/project_items.dart' ;
10+ import '../main/main_init.dart' ;
911
1012enum ToastType { success, error, info, warning }
1113
@@ -14,43 +16,60 @@ String? _toastTitle;
1416Color ? _color;
1517Color ? _leftBorderColor;
1618
17- mixin ToastService < T extends StatefulWidget > on State < T > {
19+ mixin ToastService {
1820 void showToast ({required String label, ToastType ? toastType}) {
1921 _toastTypeControl (toastType);
2022 BotToast .showCustomNotification (
23+ align: kIsWeb ? Alignment .bottomRight : null ,
2124 toastBuilder: (_) => Padding (
22- padding: context.paddingHighHorizontal,
23- child: Card (
24- shape: RoundedRectangleBorder (
25- borderRadius: context.borderRadiusLow,
26- ),
27- color: _color,
28- child: IntrinsicHeight (
29- child: Row (
30- mainAxisSize: MainAxisSize .min,
31- children: [
32- _leftBorderContainer,
33- const SizedBox (width: 10 ),
34- _iconWidget,
35- const SizedBox (width: 5 ),
36- Expanded (
37- child: Padding (
38- padding: context.paddingLow,
39- child: Column (
40- crossAxisAlignment: CrossAxisAlignment .start,
41- children: [
42- _headerText,
43- _subText (label),
44- ],
25+ padding: getIt <AppRouter >()
26+ .root
27+ .navigatorKey
28+ .currentContext!
29+ .paddingMediumHorizontal,
30+ child: SizedBox (
31+ width: kIsWeb ? 350 : null ,
32+ child: Card (
33+ shape: RoundedRectangleBorder (
34+ borderRadius: getIt <AppRouter >()
35+ .root
36+ .navigatorKey
37+ .currentContext!
38+ .borderRadiusLow,
39+ ),
40+ color: _color,
41+ child: IntrinsicHeight (
42+ child: Row (
43+ mainAxisSize: MainAxisSize .min,
44+ children: [
45+ _leftBorderContainer,
46+ const SizedBox (width: 10 ),
47+ _iconWidget,
48+ const SizedBox (width: 5 ),
49+ Expanded (
50+ child: Padding (
51+ padding: getIt <AppRouter >()
52+ .root
53+ .navigatorKey
54+ .currentContext!
55+ .paddingLow,
56+ child: Column (
57+ crossAxisAlignment: CrossAxisAlignment .start,
58+ children: [
59+ _headerText,
60+ _subText (label),
61+ ],
62+ ),
4563 ),
46- ),
47- )
48- ] ,
64+ )
65+ ],
66+ ) ,
4967 ),
5068 ),
5169 ),
5270 ),
53- duration: context.highDuration);
71+ duration:
72+ getIt <AppRouter >().root.navigatorKey.currentContext! .highDuration);
5473 }
5574
5675 void _toastTypeControl (ToastType ? toastType) {
@@ -86,26 +105,41 @@ mixin ToastService<T extends StatefulWidget> on State<T> {
86105 height: ProjectVaribles .normalValue,
87106 width: ProjectVaribles .normalValue,
88107 child: SvgWidget (
89- svgPath: SvgPath .svgCheckPath,
108+ svgPath: _svgPath ?? SvgPath .svgCheckPath,
90109 size: ProjectVaribles .normalValue,
91110 ),
92111 );
93112
94113 Widget _subText (label) => Text (
95114 label,
96115 overflow: TextOverflow .clip,
97- style: context.textTheme.caption! .copyWith (fontWeight: FontWeight .w500),
116+ style: getIt <AppRouter >()
117+ .root
118+ .navigatorKey
119+ .currentContext!
120+ .textTheme
121+ .titleSmall!
122+ .copyWith (fontWeight: FontWeight .w500),
98123 );
99124
100125 Widget get _headerText => Text (
101126 '${_toastTitle !.toUpperCase ()}!' ,
102- style:
103- context.textTheme.bodySmall! .copyWith (fontWeight: FontWeight .bold),
127+ style: getIt <AppRouter >()
128+ .root
129+ .navigatorKey
130+ .currentContext!
131+ .textTheme
132+ .titleSmall!
133+ .copyWith (fontWeight: FontWeight .bold),
104134 );
105135
106136 Widget get _leftBorderContainer => Container (
107137 decoration: BoxDecoration (
108- borderRadius: context.borderRadiusLeftLow,
138+ borderRadius: getIt <AppRouter >()
139+ .root
140+ .navigatorKey
141+ .currentContext!
142+ .borderRadiusLeftLow,
109143 color: _leftBorderColor,
110144 ),
111145 height: double .infinity,
0 commit comments