Bladeren bron

fix: some hint & pemanggilan context

Yulian 2 maanden geleden
bovenliggende
commit
8f3b422739

+ 4 - 4
lib/app_router.dart

@@ -55,7 +55,7 @@ class AppRouter extends RootStackRouter {
     AutoRouteGuard.simple((resolver, router) async{
       RouteMatch<dynamic> vRedirector = resolver.route;
       String? rawPid = '';
-      var pid;
+      String? pid = '';
       bool stb = false;
 
       if(vRedirector.params.isNotEmpty){
@@ -65,7 +65,7 @@ class AppRouter extends RootStackRouter {
       try {
         pid = Uri.decodeComponent(rawPid);
       } catch (e) {
-        print("err : $e");
+        debugPrint("err : $e");
         stb = true;
       }
 
@@ -82,7 +82,7 @@ class AppRouter extends RootStackRouter {
 
       if (U.getAccessCode() == null) {
         await _sharedPreferencesManager.putString(SharedPreferencesManager.keyBaseUrl, U.rewriteUrl(vRedirector.fragment));
-        await _sharedPreferencesManager.putString(SharedPreferencesManager.keyAccessCode, pid);
+        await _sharedPreferencesManager.putString(SharedPreferencesManager.keyAccessCode, pid!);
         await _sharedPreferencesManager.putString(SharedPreferencesManager.keySerialCode, 'P-$pid}');
         try {
           var ver = await U.reloadLicense();
@@ -105,7 +105,7 @@ class AppRouter extends RootStackRouter {
             var ver = await U.reloadLicense();
             await _sharedPreferencesManager.putInt(SharedPreferencesManager.version, ver['version']);
           } catch (e) {
-            print('Error get2: ${e.toString()}');
+            debugPrint('Error get2: ${e.toString()}');
             await _sharedPreferencesManager.clearKey(SharedPreferencesManager.keyBaseUrl);
             await _sharedPreferencesManager.clearKey(SharedPreferencesManager.keyAccessCode);
             await _sharedPreferencesManager.clearKey(SharedPreferencesManager.keySerialCode);

+ 5 - 5
lib/main.dart

@@ -67,7 +67,7 @@ void main() async{
 
     await setupLocator();
     SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
-    HttpOverrides.global = new MyHttpOverrides();
+    HttpOverrides.global = MyHttpOverrides();
     // WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
     // FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
     runApp(
@@ -91,7 +91,7 @@ void main() async{
         )
     );
   } catch (error, stacktrace) {
-    print('$error & $stacktrace');
+    debugPrint('$error & $stacktrace');
   }
 }
 
@@ -149,7 +149,7 @@ class NavigationService {
 
 @RoutePage()
 class HomeGuardPage extends StatefulWidget {
-  const HomeGuardPage({Key? key}) : super(key: key);
+  const HomeGuardPage({super.key});
 
   @override
   State<HomeGuardPage> createState() => _HomeGuardPageState();
@@ -196,7 +196,7 @@ class NotificationClass {
       // print(token);
       if (token != null) {
         _apiAuthProvider.postDataNoAuth('/api/notifications/received/$token/$mid').then((value) =>
-            print('Send confirm succes!')
+            debugPrint('Send confirm succes!')
         );
       }
 
@@ -307,7 +307,7 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
   FirebaseMessaging.instance.getToken().then((token) async {
     if (token != null) {
       http.post(Uri.https(U.decodeBase64Url(prefs.getString(SharedPreferencesManager.keyBaseUrl)!).split('//')[1], '$decAccCode/api/notifications/received/$token/$mid')).then((value) {
-        print("kirim confirm");
+        debugPrint("kirim confirm");
         prefs.setString(SharedPreferencesManager.lastMid, mid);
       });
     }

+ 10 - 19
lib/src/api/api_auth_provider.dart

@@ -3,7 +3,6 @@ import 'dart:convert';
 import 'dart:io';
 import 'package:dio/dio.dart';
 import 'package:flutter/cupertino.dart';
-import 'package:flutter/foundation.dart';
 import 'package:telnow_mobile_new/src/injector/injector.dart';
 import 'package:telnow_mobile_new/src/model/login/login_body.dart';
 import 'package:telnow_mobile_new/src/model/refreshtoken/refresh_token_body.dart';
@@ -21,7 +20,7 @@ const String host = '';
 // const String host = '192.168.100.18:8080';
 
 class ApiAuthProvider {
-  final Dio _dio = new Dio();
+  final Dio _dio = Dio();
   final SharedPreferencesManager _sharedPreferencesManager = locator<SharedPreferencesManager>();
 
   final String displayVersion = '4.0.17'; //versi aplikasi untuk di tampilkan
@@ -41,7 +40,7 @@ class ApiAuthProvider {
   final String clientSecret = '3JskYu5zxlXRDv6g';
   // final String clientIdWeb = 'web-apHca0ncOX';
   // final String clientSecretWeb = '1qeIwW8Wu9AF4DRF';
-  var isDebug;
+  bool isDebug = false;
 
   ApiAuthProvider() {
 //     print('ApiAuthProvider called');
@@ -76,15 +75,11 @@ class ApiAuthProvider {
       var strData = "";
       var i = 0;
       loginData.forEach((key, value) {
-        strData = strData +
-            (i == 0 ? '' : '&') +
-            key +
-            '=' +
-            Uri.encodeComponent(value);
+        strData = '$strData${i == 0 ? '' : '&'}$key=${Uri.encodeComponent(value)}';
         i++;
       });
       // print(strData);
-      final response = await _dio.post('/oauth/token?' + strData,
+      final response = await _dio.post('/oauth/token?$strData',
           options: Options(
             headers: {
               'Accept': 'application/json',
@@ -130,16 +125,12 @@ class ApiAuthProvider {
       var strData = "";
       var i = 0;
       refreshData.forEach((key, value) {
-        strData = strData +
-            (i == 0 ? '' : '&') +
-            key +
-            '=' +
-            Uri.encodeComponent(value);
+        strData = '$strData${i == 0 ? '' : '&'}$key=${Uri.encodeComponent(value)}';
         i++;
       });
       // print(strData);
       final response = await _dio.post(
-        '/oauth/token?' + strData,
+        '/oauth/token?$strData',
         options: Options(
           headers: {
             'Accept': 'application/json',
@@ -172,7 +163,7 @@ class ApiAuthProvider {
       );
       return json.decode(response.data!);
     } on DioException catch (error) {
-      print(error.response);
+      debugPrint(error.response.toString());
       if (error.response == null) {
         try {
           final result = await InternetAddress.lookup('google.com');
@@ -205,7 +196,7 @@ class ApiAuthProvider {
       }
       return Future.error(error);
     } catch (error) {
-      print(error.toString());
+      debugPrint(error.toString());
       handlingError(context, 1);
       return Future.error(error);
     }
@@ -314,7 +305,7 @@ class ApiAuthProvider {
       Response response = await _dio.postUri(Uri(path: path));
       return response.data;
     } on DioException catch (error) {
-     print(error.response);
+     debugPrint(error.response.toString());
       return null;
     }
   }
@@ -429,6 +420,6 @@ class ApiAuthProvider {
   }
 
   String getServiceAsset(String key){
-    return _dio.options.baseUrl+'/assets/lotties/$key';
+    return '${_dio.options.baseUrl}/assets/lotties/$key';
   }
 }

+ 1 - 1
lib/src/api/jwt_token.dart

@@ -72,7 +72,7 @@ class JwtToken{
 
     if(isTokenExist && token != ''){
       var jwt = parseJwtPayLoad(token);
-      var url = '/api/informants/'+jwt['userId'].toString();
+      var url = '/api/informants/${jwt['userId']}';
       Map<String, dynamic>? user;
 
       if(U.getInternetStatus()){

+ 7 - 3
lib/src/layouts/auth/change_code.dart

@@ -14,7 +14,7 @@ import 'package:http/http.dart' as http;
 
 @RoutePage()
 class ChangeCodePage extends StatefulWidget {
-  const ChangeCodePage({Key? key}) : super(key: key);
+  const ChangeCodePage({super.key});
 
   @override
   State<ChangeCodePage> createState() => _ChangeCodePageState();
@@ -31,7 +31,11 @@ class _ChangeCodePageState extends State<ChangeCodePage> {
   String imageUrl = '';
 
   getNewLicense(rawPid) async{
-    try{imageUrl = U.decodeBase64Url(U.getBaseUrl()!) + U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))+'/assets/background/tn';}catch(e){}
+    try{
+      imageUrl = '${U.decodeBase64Url(U.getBaseUrl()!)}${U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))}/assets/background/tn';
+    }catch(e){
+      debugPrint(e.toString());
+    }
     var pid = Uri.decodeComponent(rawPid);
     var response = await http.post(Uri.https(U.decodeBase64Url(U.getBaseUrl()!).split('//')[1], '${U.decodeBase64Url(pid)}/api/license'));
     var ver = json.decode(response.body);
@@ -178,7 +182,7 @@ class _ChangeCodePageState extends State<ChangeCodePage> {
                                     context.navigateToPath("/app/$rawPid/login");
                                   }
                                 } catch(e) {
-                                  print(e.toString());
+                                  debugPrint(e.toString());
                                   await _sharedPreferencesManager.clearKey(SharedPreferencesManager.keyAccessCode);
                                   await _sharedPreferencesManager.clearKey(SharedPreferencesManager.keySerialCode);
                                   await _sharedPreferencesManager.clearKey(SharedPreferencesManager.version);

+ 1 - 2
lib/src/layouts/auth/end_session.dart

@@ -1,4 +1,3 @@
-import 'package:auto_route/annotations.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:easy_localization/easy_localization.dart';
 import 'package:flutter/foundation.dart';
@@ -25,7 +24,7 @@ class _EndSessionPageState extends State<EndSessionPage> {
     final ApiAuthProvider apiAuthProvider = ApiAuthProvider();
 
     try {
-      imageUrl = apiAuthProvider.baseUrl + U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))+'/assets/background/tn';
+      imageUrl = '${apiAuthProvider.baseUrl}${U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))}/assets/background/tn';
       http.head(Uri.parse(imageUrl));
     }catch(e){
       // useAsset = true;

+ 30 - 20
lib/src/layouts/auth/login.dart

@@ -23,7 +23,7 @@ import 'package:telnow_mobile_new/src/model/token/token.dart';
 
 @RoutePage()
 class LoginPage extends StatefulWidget {
-  const LoginPage({Key? key}) : super(key: key);
+  const LoginPage({super.key});
 
   @override
   State<LoginPage> createState() => _LoginPageState();
@@ -47,7 +47,11 @@ class _LoginPageState extends State<LoginPage> {
 
   @override
   void initState() {
-    try{imageUrl = apiAuthProvider.baseUrl + U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))+'/assets/background/tn';}catch(e){}
+    try{
+      imageUrl = '${apiAuthProvider.baseUrl}${U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))}/assets/background/tn';
+    }catch(e){
+      debugPrint(e.toString());
+    }
     U.getServerVersion();
     getCompanyName();
     // TODO: implement initState
@@ -109,7 +113,7 @@ class _LoginPageState extends State<LoginPage> {
                       width: 160, height: 160,
                       decoration: BoxDecoration(
                         borderRadius: BorderRadius.all(Radius.circular(80)),
-                        image: DecorationImage(image: CachedNetworkImageProvider(companyLogo+'?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(companyLogo))), fit: BoxFit.cover)
+                        image: DecorationImage(image: CachedNetworkImageProvider('$companyLogo?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(companyLogo))), fit: BoxFit.cover)
                       ),
                     ):SizedBox(height: 115),
                     Expanded(
@@ -147,7 +151,7 @@ class _LoginPageState extends State<LoginPage> {
                           ),
                           companyName.isNotEmpty?Text(companyName, style: TextStyle(fontSize: 16, color: Colors.white), textAlign: TextAlign.center):Container(),
                           SizedBox(height: companyName.isNotEmpty?5:0),
-                          serialNumber.isNotEmpty?Text('serialNumber'.tr() + ' ' + serialNumber, style: TextStyle(color: Colors.white, fontSize: 14)):Container(),
+                          serialNumber.isNotEmpty?Text('${'serialNumber'.tr()} $serialNumber', style: TextStyle(color: Colors.white, fontSize: 14)):Container(),
                         ],
                       ),
                     ),
@@ -157,8 +161,8 @@ class _LoginPageState extends State<LoginPage> {
                       child: GestureDetector(
                         child: Text('policy'.tr(), style: TextStyle(color: Colors.white, fontSize: 14, decoration: TextDecoration.underline)),
                         onTap: () async {
-                          Uri _url = Uri.parse('https://telmessenger.com/privacy-police/telnow.html');
-                          await canLaunchUrl(_url) ? await launchUrl(_url) : print('Could not launch $_url');
+                          Uri url = Uri.parse('https://telmessenger.com/privacy-police/telnow.html');
+                          await canLaunchUrl(url) ? await launchUrl(url) : debugPrint('Could not launch $url');
                         },
                       ),
                     ),
@@ -307,7 +311,7 @@ class _LoginPageState extends State<LoginPage> {
     if(lang.indexOf(code) > 1){
       lg = lang.indexOf(code) - 1;
     }
-    var p;
+    Map<String, dynamic> p;
     if(U.newServerVersion(1754624839)){
       p = {
         'userId': tkn['user_name'].toString().replaceFirst('inf-', ""),
@@ -321,12 +325,14 @@ class _LoginPageState extends State<LoginPage> {
       };
     }
     try{
-      var res = await apiAuthProvider.patchData('/api/informants/' + tkn['userId'].toString(), p, context);
+      var res = await apiAuthProvider.patchData('/api/informants/${tkn['userId']}', p, context);
       if (res != null) {
         // print("res $res");
         // context.setLocale(Locale(code));
       }
-    }catch(e){}
+    }catch(e){
+      debugPrint(e.toString());
+    }
 
   }
 
@@ -339,7 +345,7 @@ class _LoginPageState extends State<LoginPage> {
 
       return jwt['forceChgPass'];
     } catch(e) {
-      print(e.toString());
+      debugPrint(e.toString());
     }
   }
 }
@@ -450,7 +456,7 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
   final ApiAuthRepository apiAuthRepository = ApiAuthRepository();
   final SharedPreferencesManager sharedPreferencesManager = locator<SharedPreferencesManager>();
 
-  var tokenData;
+  Map<String, dynamic> tokenData = {};
   String companyName = '';
   String serialNumber = '';
   String guestName = '';
@@ -458,11 +464,15 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
   String imageUrl = '';
 
   String newPassword = '';
-  String cfrmPassword = '';
+  String confirmPassword = '';
 
   @override
   void initState() {
-    try{imageUrl = apiAuthProvider.baseUrl + U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))+'/assets/background/tn';}catch(e){}
+    try{
+      imageUrl = '${apiAuthProvider.baseUrl}${U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))}/assets/background/tn';
+    }catch(e){
+      debugPrint(e.toString());
+    }
     getTokenData();
     getCompanyName();
     // TODO: implement initState
@@ -472,7 +482,7 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
   getTokenData() async {
     String accessToken = sharedPreferencesManager.getString(SharedPreferencesManager.keyAccessToken)!;
     var jwt = token.parseJwtPayLoad(accessToken);
-    var user = await apiAuthProvider.getData('/api/informants/'+jwt['userId'].toString(), null, context);
+    var user = await apiAuthProvider.getData('/api/informants/${jwt['userId']}', null, context);
     if(user!=null){
       setState((){
         tokenData = jwt;
@@ -579,7 +589,7 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
                         children: [
                           loginFieldTemplate(placeholder: 'newPassword'.tr(), value: newPassword, action: (val)=>newPassword = val, isPassword: true, submit: (val)=>loginAction()),
                           SizedBox(height: 12),
-                          loginFieldTemplate(placeholder: 'confirmPassword'.tr(), value: cfrmPassword, action: (val)=>cfrmPassword = val, isPassword: true, submit: (val)=>loginAction()),
+                          loginFieldTemplate(placeholder: 'confirmPassword'.tr(), value: confirmPassword, action: (val)=>confirmPassword = val, isPassword: true, submit: (val)=>loginAction()),
                           GestureDetector(
                             child: Container(
                               width: double.infinity,
@@ -607,7 +617,7 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
                     Container(
                       margin: const EdgeInsets.only(top: 145),
                       alignment: Alignment.bottomCenter,
-                      child: Text('version'.tr() + ' ' + ApiAuthProvider().displayVersion, style: TextStyle(color: Colors.white, fontSize: 14))
+                      child: Text('${'version'.tr()} ${ApiAuthProvider().displayVersion}', style: TextStyle(color: Colors.white, fontSize: 14))
                     ),
                   ],
                 ),
@@ -621,15 +631,15 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
 
   loginAction() async{
     if(!loading){
-      if(newPassword.isNotEmpty && cfrmPassword.isNotEmpty){
-        if(newPassword.trim() == cfrmPassword.trim()){
+      if(newPassword.isNotEmpty && confirmPassword.isNotEmpty){
+        if(newPassword.trim() == confirmPassword.trim()){
           setState(()=>loading = true);
           var data = {'oldPassword': widget.data['password'], 'password': newPassword.trim()};
 
           try {
             var res = await apiAuthProvider.patchData('/api/informants/${tokenData['userId']}/changePassword', data, context);
             if (res != null) {
-              String password = tokenData['related'] && tokenData['tenantCode'] != null && tokenData['tenantCode'] != '' ? tokenData['tenantCode'] + ' ' + data['password'] : data['password'];
+              String password = tokenData['related'] && tokenData['tenantCode'] != null && tokenData['tenantCode'] != '' ?  tokenData['tenantCode'] + ' ' + data['password'] : data['password'];
 
               LoginBody loginBody = LoginBody(widget.data['username']!, password, 'password');
               Token token = await apiAuthRepository.postLoginUser(loginBody);
@@ -654,7 +664,7 @@ class _ForceChgPassPageState extends State<ForceChgPassPage> {
               }
             }
           } catch(e) {
-            print(e.toString());
+            debugPrint(e.toString());
             setState(()=>loading = false);
           }
         }

+ 6 - 6
lib/src/layouts/auth/qr.dart

@@ -20,7 +20,7 @@ import 'package:http/http.dart' as http;
 
 @RoutePage()
 class NewQrPage extends StatefulWidget {
-  const NewQrPage({Key? key}) : super(key: key);
+  const NewQrPage({super.key});
 
   @override
   State<NewQrPage> createState() => _NewQrPageState();
@@ -43,7 +43,7 @@ class _NewQrPageState extends State<NewQrPage> {
   @override
   void initState() {
     try {
-      imageUrl = apiAuthProvider.baseUrl + U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))+'/assets/background/tn';
+      imageUrl = '${apiAuthProvider.baseUrl}${U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))}/assets/background/tn';
       http.head(Uri.parse(imageUrl));
     }catch(e){
       useAsset = true;
@@ -168,8 +168,8 @@ class _NewQrPageState extends State<NewQrPage> {
                     GestureDetector(
                       child: Text('policy'.tr(), style: TextStyle(color: Colors.white, fontSize: 14, decoration: TextDecoration.underline)),
                       onTap: () async {
-                        Uri _url = Uri.parse('https://telmessenger.com/privacy-police/telnow.html');
-                        await canLaunchUrl(_url) ? await launchUrl(_url) : print('Could not launch $_url');
+                        Uri url = Uri.parse('https://telmessenger.com/privacy-police/telnow.html');
+                        await canLaunchUrl(url) ? await launchUrl(url) : debugPrint('Could not launch $url');
                       },
                     ),
                     SizedBox(height: 5),
@@ -315,10 +315,10 @@ class _NewQrPageState extends State<NewQrPage> {
         context.navigateToPath("/app/${Uri.encodeComponent(splitPID[0])}/login");
       } else {
         context.router.removeLast();
-        context.navigateToPath("/app/${Uri.encodeComponent(splitPID[0])}/loginme"+pidString.split("/loginme").last);
+        context.navigateToPath("/app/${Uri.encodeComponent(splitPID[0])}/loginme${pidString.split("/loginme").last}");
       }
     } catch (e) {
-      print(e);
+      debugPrint(e.toString());
       if(mounted) showError(context, 'messageInvalidCode'.tr());
     }
   }

+ 21 - 22
lib/src/layouts/components/auto_login.dart

@@ -16,6 +16,8 @@ import 'package:telnow_mobile_new/src/utils/U.dart';
 
 @RoutePage()
 class AutoLoginPage extends StatefulWidget {
+  const AutoLoginPage({super.key});
+
   @override
   State<AutoLoginPage> createState() => _AutoLoginPageState();
 }
@@ -35,8 +37,8 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
   String progressMsg = 'initializing'.tr();
 
   String newPassword = '';
-  String cfrmPassword = '';
-  Map <String, String> Ddata = {};
+  String confirmPassword = '';
+  Map <String, String> dData = {};
 
   @override
   void initState() {
@@ -59,7 +61,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
           case 'prm':prmJson = U.decodeBase64Url(Uri.decodeComponent(v));
         }
       });
-      Ddata = {
+      dData = {
         "username": jsonDecode(prmJson)["username"],
         "password": jsonDecode(prmJson)["password"]
       };
@@ -67,7 +69,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
       getTokenData();
     } catch(e) {
       U.showDebugToast(e.toString());
-      print("invalid param: " + e.toString());
+      debugPrint("invalid param: $e");
       redirectToLoginPage = true;
       Future.delayed(Duration.zero, (){
         context.router.removeLast();
@@ -78,12 +80,9 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
 
   getTokenData({int n = 0}) async {
     JwtToken jwtToken = JwtToken();
-    // if (n > 2){
-    //
-    // }
     showLoading(context);
     try {
-      Token token = await apiAuthRepository.postLoginUser(LoginBody(Ddata["username"]!.trim(), Ddata["password"]!.trim(), "password"));
+      Token token = await apiAuthRepository.postLoginUser(LoginBody(dData["username"]!.trim(), dData["password"]!.trim(), "password"));
       if (token.error != null) {
         closeLoading(context);
         showError(context, token.error);
@@ -101,7 +100,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
       String accessToken = sharedPreferencesManager.getString(SharedPreferencesManager.keyAccessToken)!;
       var jwt = jwtToken.parseJwtPayLoad(accessToken);
       // print(jwt);
-      var user = await apiAuthProvider.getData('/api/informants/'+jwt['userId'].toString(), null, context);
+      var user = await apiAuthProvider.getData('/api/informants/${jwt['userId']}', null, context);
       if(user != null){
         closeLoading(context);
         setState((){
@@ -112,17 +111,17 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
       }
     } catch(e){
       closeLoading(context);
-      print(e.toString());
+      debugPrint(e.toString());
       U.showDebugToast(e.toString());
       getTokenData(n: n + 1);
     }
   }
 
   getCompanyName() async {
-    var lics = await U.getLicense();
-    if (lics != null && lics['companyName'] != null && mounted) {
+    var license = await U.getLicense();
+    if (license != null && license['companyName'] != null && mounted) {
       setState(() {
-        companyName = lics['companyName'];
+        companyName = license['companyName'];
       });
     }
   }
@@ -135,7 +134,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
         context.navigateToPath('/qr?new=true');
       });
     } catch(e) {
-      print(e.toString());
+      debugPrint(e.toString());
       U.showDebugToast(e.toString());
     }
   }
@@ -204,7 +203,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
                     ),
                     !invalidUserLogin ? Column(
                       children: [
-                        Text('welcome'.tr()+' $guestName', style: TextStyle(color: Colors.white, fontSize: 16), textAlign: TextAlign.center),
+                        Text('${'welcome'.tr()} $guestName', style: TextStyle(color: Colors.white, fontSize: 16), textAlign: TextAlign.center),
                         SizedBox(height: 16),
                         Text('createNewPassText'.tr(), style: TextStyle(color: Colors.white, fontSize: 16), textAlign: TextAlign.center),
                       ],
@@ -214,7 +213,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
                         SizedBox(height: 80),
                         loginFieldTemplate(placeholder: 'newPassword'.tr(), value: newPassword, action: (val)=>newPassword = val, isPassword: true, submit: (val)=>loginAction()),
                         SizedBox(height: 12),
-                        loginFieldTemplate(placeholder: 'confirmPassword'.tr(), value: cfrmPassword, action: (val)=>cfrmPassword = val, isPassword: true, submit: (val)=>loginAction()),
+                        loginFieldTemplate(placeholder: 'confirmPassword'.tr(), value: confirmPassword, action: (val)=>confirmPassword = val, isPassword: true, submit: (val)=>loginAction()),
                         GestureDetector(
                           child: Container(
                             width: double.infinity,
@@ -265,13 +264,13 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
 
   loginAction() async{
     if(!loading && tokenData != null){
-      if(newPassword.isNotEmpty && cfrmPassword.isNotEmpty){
-        if(newPassword.trim() == cfrmPassword.trim()){
+      if(newPassword.isNotEmpty && confirmPassword.isNotEmpty){
+        if(newPassword.trim() == confirmPassword.trim()){
           setState(() {
             loading = true;
             onProgress = true;
           });
-          var data = {'oldPassword': Ddata['password'], 'password': newPassword.trim()};
+          var data = {'oldPassword': dData['password'], 'password': newPassword.trim()};
 
           try {
             var res = await apiAuthProvider.patchData('/api/informants/${tokenData!['userId']}/changePassword', data, context);
@@ -279,7 +278,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
               // setState(() => progressMsg = "Initializing...");
               String password = tokenData!['related'] && tokenData!['tenantCode'] != null && tokenData!['tenantCode'] != '' ? tokenData!['tenantCode'] + ' ' + data['password'] : data['password'];
 
-              LoginBody loginBody = LoginBody(Ddata['username']!, password, 'password');
+              LoginBody loginBody = LoginBody(dData['username']!, password, 'password');
               Token token = await apiAuthRepository.postLoginUser(loginBody);
               if (token.error != null) {
                 setState(() => loading = false);
@@ -290,7 +289,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
                 var parsedToken = U.token.parseJwtPayLoad(token.accessToken!);
                 await sharedPreferencesManager.putString(SharedPreferencesManager.keyAccessToken, token.accessToken!);
                 await sharedPreferencesManager.putString(SharedPreferencesManager.keyRefreshToken, token.refreshToken!);
-                await sharedPreferencesManager.putString(SharedPreferencesManager.keyUsername, tokenData!['related'] ? parsedToken['user_name'].split("-").last : Ddata['username']);
+                await sharedPreferencesManager.putString(SharedPreferencesManager.keyUsername, tokenData!['related'] ? parsedToken['user_name'].split("-").last : dData['username']);
                 await sharedPreferencesManager.putBool(SharedPreferencesManager.keyIsLogin, true);
                 await sharedPreferencesManager.putString(SharedPreferencesManager.keyScoope, 'INSIDE');
                 await sharedPreferencesManager.putInt(SharedPreferencesManager.keyCountRefreshToken, 0);
@@ -304,7 +303,7 @@ class _AutoLoginPageState extends State<AutoLoginPage> {
               setState(() => loading = false);
             }
           } catch(e) {
-            print(e.toString());
+            debugPrint(e.toString());
             setState(() => loading = false);
           }
         }

+ 2 - 2
lib/src/layouts/components/camera.dart

@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
 
 class OpenCamera extends StatefulWidget {
   final List<CameraDescription>? cameras;
-  const OpenCamera({required this.cameras, Key? key}) : super(key: key);
+  const OpenCamera({required this.cameras, super.key});
 
   @override
   State<OpenCamera> createState() => _OpenCameraState();
@@ -59,7 +59,7 @@ class _OpenCameraState extends State<OpenCamera> {
   Widget build(BuildContext context) {
     return Scaffold(
         body: SafeArea(
-          child: Container(
+          child: SizedBox(
             width: double.infinity, height: double.infinity,
             child: Stack(children: [
               (_cameraController.value.isInitialized) ? CameraPreview(_cameraController) : Container(color: Colors.black, child: const Center(child: CircularProgressIndicator())),

+ 11 - 14
lib/src/layouts/components/error_page.dart

@@ -6,10 +6,10 @@ import 'package:telnow_mobile_new/src/utils/U.dart';
 
 @RoutePage()
 class ErrorPage extends StatefulWidget {
-  final code;
-  final errMsg;
+  final String code;
+  final String errMsg;
 
-  ErrorPage(this.code, this.errMsg);
+  const ErrorPage(this.code, this.errMsg, {super.key});
 
   @override
   _ErrorPageState createState() => _ErrorPageState();
@@ -22,17 +22,15 @@ class _ErrorPageState extends State<ErrorPage> {
 
   @override
   void initState() {
-    try{imageUrl = _apiAuthProvider.baseUrl + U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))+'/assets/background/tn';}catch(e){}
+    try{
+      imageUrl = '${_apiAuthProvider.baseUrl}${U.decodeBase64Url(Uri.decodeComponent(U.getAccessCode()!))}/assets/background/tn';
+    } catch(e) {
+      debugPrint(e.toString());
+    }
     // TODO: implement initState
     switch (widget.errMsg) {
       case "_strErrVer":
-        stringError = "invalidVersion".tr() +
-          ". " +
-          "sugestVersion".tr() + " " +
-          U.getVersion().toString() +
-          ". " +
-          "currentVersion".tr() + " " +
-          ApiAuthProvider().currentVersion.toString() + ".";
+        stringError = "${"invalidVersion".tr()}. ${"sugestVersion".tr()} ${U.getVersion()}. ${"currentVersion".tr()} ${ApiAuthProvider().currentVersion}.";
         break;
         default:
           stringError = widget.errMsg;
@@ -45,14 +43,13 @@ class _ErrorPageState extends State<ErrorPage> {
     return Scaffold(
       body: Stack(
         children: [
-          Container(
+          SizedBox(
             width: double.infinity, height: double.infinity,
             child: Image.network(imageUrl, fit: BoxFit.cover, width: double.infinity, height: double.infinity, errorBuilder: (context, error, stackTrace) {
               return Image.asset('assets/image/background/background.jpg', fit: BoxFit.cover, width: double.infinity, height: double.infinity);
             }),
           ),
           Container(
-            // decoration: BoxDecoration(color: Color(0xff0D497F).withValues(alpha: 0.85)),
             decoration: BoxDecoration(
                 gradient: LinearGradient(
                     begin: Alignment.topCenter, end: Alignment.bottomCenter,
@@ -69,7 +66,7 @@ class _ErrorPageState extends State<ErrorPage> {
                 Padding(
                   padding: EdgeInsets.only(bottom: 30),
                   child: Image(
-                    image: new AssetImage("assets/image/logo/logo.png"),
+                    image: AssetImage("assets/image/logo/logo.png"),
                     width: 100,
                   ),
                 ),

+ 2 - 2
lib/src/layouts/components/photo_chat.dart

@@ -14,7 +14,7 @@ import 'package:telnow_mobile_new/src/utils/U.dart';
 import 'package:image/image.dart' as img;
 
 class PhotoChat extends StatefulWidget {
-  final data;
+  final Map<String, dynamic> data;
   final ImageSource? media;
   final bool? isBroadcast;
   final Uint8List? image;
@@ -82,7 +82,7 @@ class PhotoChatState extends State<PhotoChat> {
         ),
       ),
       body: Center(
-        child: Container(
+        child: SizedBox(
           width: U.bodyWidth(context),
           child: Stack(
             children: [

+ 45 - 34
lib/src/layouts/components/template.dart

@@ -41,7 +41,7 @@ PreferredSizeWidget appBarTemplate({required BuildContext context, required Stri
   );
 }
 
-Widget buttonTemplate({double width = double.infinity, double height = 51, required String text, required action(), backgroundColor = primaryColor, textColor = Colors.white, borderColor = primaryColor}){
+Widget buttonTemplate({double width = double.infinity, double height = 51, required String text, required Function() action, backgroundColor = primaryColor, textColor = Colors.white, borderColor = primaryColor}){
   return SizedBox(
     width: width,
     height: height,
@@ -88,7 +88,7 @@ Widget textHorizontal(String title, String subtitle, {double size = 14, double o
               },
             ),
           ],
-        ):Text("$subtitle", style: TextStyle(color: textColor, fontSize: size), maxLines: 3, overflow: TextOverflow.ellipsis, textAlign: TextAlign.end,),
+        ):Text(subtitle, style: TextStyle(color: textColor, fontSize: size), maxLines: 3, overflow: TextOverflow.ellipsis, textAlign: TextAlign.end,),
       ),
     ],
   );
@@ -121,13 +121,13 @@ Widget categoryContainer({required BuildContext context, required String iconUrl
 
   return Container(
     padding: EdgeInsets.all(5),
-    child: Image(image: CachedNetworkImageProvider(iconUrl+'?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(iconUrl+'?bridge-cache=true'))), width: size, height: size),
     decoration: BoxDecoration(
         color: Colors.white,
         borderRadius: BorderRadius.all(Radius.circular(20)),
         border: Border.all(width: 0.2, color: Colors.black12),
         boxShadow: [BoxShadow(color: Colors.grey.withValues(alpha: 0.3), blurRadius: 2, offset: Offset(0, 2))]
     ),
+    child: Image(image: CachedNetworkImageProvider('$iconUrl?bridge-cache=true', cacheManager: CacheManager(CacheMan.config('$iconUrl?bridge-cache=true'))), width: size, height: size),
   );
 }
 
@@ -166,6 +166,11 @@ Widget requestTiles({required String image, required String title, required Stri
   return Container(
     margin: EdgeInsets.symmetric(vertical: vertical),
     padding: EdgeInsetsDirectional.only(end: border?16:0),
+    decoration: BoxDecoration(
+        color: Colors.white,
+        border: border?Border.all(color: textColor.withValues(alpha: 0.15)):null,
+        borderRadius: border?BorderRadius.all(Radius.circular(12)):null
+    ),
     child: Row(
       children: [
         imageTiles(imageUrl: image),
@@ -182,11 +187,6 @@ Widget requestTiles({required String image, required String title, required Stri
         )
       ],
     ),
-    decoration: BoxDecoration(
-        color: Colors.white,
-        border: border?Border.all(color: textColor.withValues(alpha: 0.15)):null,
-        borderRadius: border?BorderRadius.all(Radius.circular(12)):null
-    ),
   );
 }
 
@@ -203,7 +203,7 @@ Widget imageTiles({required String imageUrl, double width = 100, double height =
         color: textColor.withValues(alpha: 0.1),
         borderRadius: BorderRadius.all(Radius.circular(radius)),
         image: DecorationImage(
-          image: CachedNetworkImageProvider(imageUrl+'?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(imageUrl+'?bridge-cache=true'))),
+          image: CachedNetworkImageProvider('$imageUrl?bridge-cache=true', cacheManager: CacheManager(CacheMan.config('$imageUrl?bridge-cache=true'))),
           fit: BoxFit.cover,
         ),
       ),
@@ -211,15 +211,24 @@ Widget imageTiles({required String imageUrl, double width = 100, double height =
   ): Container(
     height: height,
     width: width,
-    child: Center(child: Text("noImage".tr(), style: TextStyle(fontStyle: FontStyle.italic, fontSize: width<100?10:14, color: Colors.black38), maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center,)),
     decoration: BoxDecoration(
         color: Colors.black12,
         borderRadius: BorderRadius.all(Radius.circular(12.0))
     ),
+    child: Center(child: Text("noImage".tr(), style: TextStyle(fontStyle: FontStyle.italic, fontSize: width<100?10:14, color: Colors.black38), maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center,)),
   );
 }
 
-Widget loginFieldTemplate({required String value, placeholder = '', required action(value), required submit(value), isPassword = false}){
+typedef FieldCallback = void Function(String value);
+Widget loginFieldTemplate(
+    {
+      required String value,
+      placeholder = '',
+      required FieldCallback action,
+      required FieldCallback submit,
+      isPassword = false
+    }
+){
   TextEditingController controller = TextEditingController()..text = value;
   bool hidePass = true;
   return SizedBox(
@@ -257,7 +266,7 @@ Widget loadingTemplate(VoidCallback setState){
     setState();
   });
   return Center(
-    child: Container(
+    child: SizedBox(
       height: 36,
       child: LoadingIndicator(
         indicatorType: Indicator.ballPulseRise,
@@ -272,7 +281,7 @@ Widget loadingTemplate(VoidCallback setState){
 
 Widget loadingTemplateNoVoid(){
   return Center(
-    child: Container(
+    child: SizedBox(
       height: 36,
       child: LoadingIndicator(
         indicatorType: Indicator.ballPulseRise,
@@ -325,22 +334,22 @@ Widget infoContainer(String text){
   return Container(
     width: double.infinity,
     padding: EdgeInsets.all(12),
-    child: Text(text, style: TextStyle(color: textColor), textAlign: TextAlign.center),
     decoration: BoxDecoration(
         color: secondaryColor.withValues(alpha: 0.1),
         border: Border.all(color: secondaryColor),
         borderRadius: BorderRadius.all(Radius.circular(12))
     ),
+    child: Text(text, style: TextStyle(color: textColor), textAlign: TextAlign.center),
   );
 }
 
 class PhotoPreview extends StatelessWidget {
-  final title;
+  final String title;
   final imageUrl;
   final bool isUrl;
   final bool isNetwork;
 
-  PhotoPreview(this.title, this.imageUrl, this.isUrl, {this.isNetwork = false});
+  const PhotoPreview(this.title, this.imageUrl, this.isUrl, {super.key, this.isNetwork = false});
 
   @override
   Widget build(BuildContext context) {
@@ -357,7 +366,7 @@ class PhotoPreview extends StatelessWidget {
           onTap: () => Navigator.of(context).pop(),
         ),
       ),
-      body: Container(
+      body: SizedBox(
           width: MediaQuery.of(context).size.width,
           height: MediaQuery.of(context).size.height,
           child: PhotoView(
@@ -385,12 +394,12 @@ class PhotoPreviewGallery extends StatelessWidget {
         title: Text(title, style: TextStyle(fontSize: 18)),
         backgroundColor: Colors.black.withValues(alpha: 0.4),
         titleSpacing: 0,
-        leading: new IconButton(
-          icon: new Icon(Icons.arrow_back_rounded),
+        leading: IconButton(
+          icon: Icon(Icons.arrow_back_rounded),
           onPressed: () => Navigator.of(context).pop(),
         ),
       ),
-      body: Container(
+      body: SizedBox(
           width: MediaQuery.of(context).size.width,
           height: MediaQuery.of(context).size.height,
           child: PhotoViewGallery.builder(
@@ -399,7 +408,7 @@ class PhotoPreviewGallery extends StatelessWidget {
             builder: (context, index) {
               var uuid = Uuid().v1().replaceAll('-', '');
               return PhotoViewGalleryPageOptions(
-                imageProvider: (isUrl?NetworkImage(imageList[index][column]+'?uuid='+uuid):imageList[index] is File?FileImage(imageList[index]):MemoryImage(imageList[index])) as ImageProvider<Object>?,
+                imageProvider: (isUrl ? NetworkImage('${imageList[index][column]}?uuid=$uuid') : imageList[index] is File ? FileImage(imageList[index]) : MemoryImage(imageList[index])) as ImageProvider<Object>?,
                 maxScale: 5.0, minScale: 0.3,
               );
             },
@@ -412,7 +421,7 @@ class PhotoPreviewGallery extends StatelessWidget {
 //------------------------------------------------------------------------------
 
 class MyClipper extends CustomClipper<Path> {
-  final isNip;
+  final bool isNip;
 
   MyClipper(this.isNip);
 
@@ -443,7 +452,7 @@ class MyClipper extends CustomClipper<Path> {
 }
 
 class YourClipper extends CustomClipper<Path> {
-  final isNip;
+  final bool isNip;
 
   YourClipper(this.isNip);
 
@@ -524,7 +533,7 @@ void showError(BuildContext context, message) {
     flushbarPosition: FlushbarPosition.BOTTOM,
     margin: EdgeInsets.all(8),
     borderRadius: BorderRadius.all(Radius.circular(8)),
-  )..show(context);
+  ).show(context);
 }
 
 void showSuccess(context, message) {
@@ -539,7 +548,7 @@ void showSuccess(context, message) {
     flushbarPosition: FlushbarPosition.BOTTOM,
     margin: EdgeInsets.all(8),
     borderRadius: BorderRadius.all(Radius.circular(8)),
-  )..show(context);
+  ).show(context);
 }
 
 String convertDate(date, String locale) {
@@ -554,9 +563,9 @@ String convertDate(date, String locale) {
 
   final aDate = DateTime(dateToCheck.year, dateToCheck.month, dateToCheck.day);
   if (aDate == today) {
-    return 'today'.tr()+' '+DateFormat('HH:mm', locale).format(DateTime.parse(date));
+    return '${'today'.tr()} ${DateFormat('HH:mm', locale).format(DateTime.parse(date))}';
   } else if (aDate == yesterday) {
-    return 'yesterday'.tr()+' '+DateFormat('HH:mm', locale).format(DateTime.parse(date));
+    return '${'yesterday'.tr()} ${DateFormat('HH:mm', locale).format(DateTime.parse(date))}';
   } else {
     return DateFormat('dd MMM HH:mm', locale).format(DateTime.parse(date));
   }
@@ -567,7 +576,7 @@ String convertDate(date, String locale) {
 class RefreshPage extends StatelessWidget {
   final VoidCallback onRefresh;
 
-  RefreshPage(this.onRefresh);
+  const RefreshPage(this.onRefresh, {super.key});
 
   @override
   Widget build(BuildContext context) {
@@ -594,6 +603,8 @@ final JwtToken token = JwtToken();
 final SharedPreferencesManager _sharedPreferencesManager = locator<SharedPreferencesManager>();
 
 class NoDataPage extends StatelessWidget {
+  const NoDataPage({super.key});
+
   @override
   Widget build(BuildContext context) {
     return Center(
@@ -672,7 +683,7 @@ handlingError(context, type) {
                   width: 200,
                   padding: const EdgeInsets.fromLTRB(15, 0, 15, 10),
                   child: Image(
-                      image: AssetImage('assets/image/error/' + data[type]['image']!))),
+                      image: AssetImage('assets/image/error/${data[type]['image']!}'))),
               Padding(
                 padding: const EdgeInsets.fromLTRB(15, 0, 15, 10),
                 child: Text(data[type]['title']!,
@@ -700,7 +711,7 @@ handlingError(context, type) {
                               RoundedRectangleBorder(
                                 borderRadius: BorderRadius.circular(5),
                               ))),
-                      child: new Text('logout'.tr().toUpperCase(),
+                      child: Text('logout'.tr().toUpperCase(),
                           style: TextStyle(color: Colors.white),
                           textAlign: TextAlign.center),
                       onPressed: () {
@@ -739,7 +750,7 @@ handlingError(context, type) {
                       },
                     )),
               )
-                  : Container(height: 1, width: 1)
+                  : SizedBox(height: 1, width: 1)
             ],
           ),
         );
@@ -754,7 +765,7 @@ class NoImageFound extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    return Container(
+    return SizedBox(
       width: MediaQuery.of(context).size.width - 150,
       height: MediaQuery.of(context).size.height / 4,
       child: Stack(
@@ -771,12 +782,12 @@ class NoImageFound extends StatelessWidget {
                 child: show
                     ? Container(
                   padding: const EdgeInsets.all(10),
-                  child: Text('notFoundImg'.tr(),
-                      style: TextStyle(fontSize: 12)),
                   decoration: BoxDecoration(
                       color: Colors.white24,
                       borderRadius:
                       BorderRadius.all(Radius.circular(50))),
+                  child: Text('notFoundImg'.tr(),
+                      style: TextStyle(fontSize: 12)),
                 )
                     : Center(
                   child: CircularProgressIndicator(),

+ 3 - 2
lib/src/layouts/functions/account.dart

@@ -15,7 +15,8 @@ class AccountFunction{
   final ApiAuthProvider apiAuthProvider = ApiAuthProvider();
   final NotificationClass notification = NotificationClass();
   final JwtToken token = JwtToken();
-  SharedPreferencesManager _sharedPreferencesManager = SharedPreferencesManager();
+  final SharedPreferencesManager _sharedPreferencesManager = SharedPreferencesManager();
+
   getUser(BuildContext context) async {
     var res = await token.getUserData(context);
     if (res != null) {
@@ -38,7 +39,7 @@ class AccountFunction{
       locale = code;
     }
     try{
-      var p;
+      Map<String, dynamic> p;
       if(await U.isCompatibleWith(VersionKey.multiBahasa)){
         p = {'userId': user['userId'], 'language': 'ID', '_language': code.toUpperCase()};
       } else {

+ 7 - 9
lib/src/layouts/mobile/history_detail.dart

@@ -482,15 +482,13 @@ class _MobHistoryDetailPageState extends State<MobHistoryDetailPage> {
               mainAxisAlignment: MainAxisAlignment.spaceBetween,
               children: [
                 Text('state'.tr(), style: TextStyle(fontSize: 14, color: textColor)),
-                Container(
-                  child: Row(
-                    mainAxisAlignment: MainAxisAlignment.end,
-                    children: [
-                      Image(image: AssetImage('assets/image/general/Watch.png'), width: 20, height: 20),
-                      SizedBox(width: 5),
-                      Text('hold'.tr(), style: TextStyle(fontSize: 14, color: primaryColor)),
-                    ],
-                  ),
+                Row(
+                  mainAxisAlignment: MainAxisAlignment.end,
+                  children: [
+                    Image(image: AssetImage('assets/image/general/Watch.png'), width: 20, height: 20),
+                    SizedBox(width: 5),
+                    Text('hold'.tr(), style: TextStyle(fontSize: 14, color: primaryColor)),
+                  ],
                 )
               ],
             ),

+ 5 - 5
lib/src/layouts/mobile/history_detail_pending.dart

@@ -59,7 +59,7 @@ class _MobHistoryDetailPendingPageState extends State<MobHistoryDetailPendingPag
                             SizedBox(height: 16),
                             divider(opacity: 0.05),
                             SizedBox(height: 16),
-                            attachment_new(widget.data['imageList']),
+                            attachmentNew(widget.data['imageList']),
                             SizedBox(height: 16),
                             textVertical('note'.tr(), widget.data['note'] != '' ? widget.data['note'] : '-'),
                             SizedBox(height: 24),
@@ -136,15 +136,15 @@ class _MobHistoryDetailPendingPageState extends State<MobHistoryDetailPendingPag
     );
   }
 
-  Widget attachment_new(List images){
+  Widget attachmentNew(List images){
     var imageWidth = ((U.bodyWidth(context)-32)/5)-5;
 
     List imageList = [];
-    images.forEach((element) {
+    for (var element in images) {
       imageList.add(base64Decode(element));
-    });
+    }
 
-    return imageList.length > 0 ? Column(
+    return imageList.isNotEmpty ? Column(
       crossAxisAlignment: CrossAxisAlignment.start,
       children: [
         Text('image'.tr(), style: TextStyle(color: textColor)),

+ 21 - 19
lib/src/layouts/mobile/history_forum.dart

@@ -39,7 +39,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
 
   String? idChat;
   String? imagePath;
-  TextEditingController controllerPesan = new TextEditingController();
+  TextEditingController controllerMessage = TextEditingController();
   ScrollController scrollController = ScrollController();
   List messageData = [];
   List deletedMessage = [];
@@ -75,7 +75,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
 
 
   getData() async {
-    idChat = U.decodeBase64Url(_sharedPreferencesManager.getString(SharedPreferencesManager.keyAccessCode)!) + '-' + widget.data['ticketNo'];
+    idChat = '${U.decodeBase64Url(_sharedPreferencesManager.getString(SharedPreferencesManager.keyAccessCode)!)}-${widget.data['ticketNo']}';
     if (!kIsWeb) imagePath = await token.getPath() + '/TelNow/Images/';
     var res = await token.getUserData(context);
     if (res != null) {
@@ -95,7 +95,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
     if (!isLoad && !stopLoad) {
       setState(() => isLoad = true);
       setAsRead(widget.data['ticketNo']);
-      var mymess = await apiAuthProvider.getData('/api/messages/search/myMessages/' + idChat!, {'isPaged': 'true', 'page': page.toString(), 'size': '20'}, context);
+      var mymess = await apiAuthProvider.getData('/api/messages/search/myMessages/${idChat!}', {'isPaged': 'true', 'page': page.toString(), 'size': '20'}, context);
       if (mymess.containsKey('_embedded')) {
         List data = mymess['_embedded']['myMessages'];
         for (int i = 0; i < data.length; i++) {
@@ -145,7 +145,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
           var translate = await translator.translate(element['msg'] ?? '', to: loc);
           element['translate'] = translate.text;
         }catch(e){
-          print("Error translate: ${e.toString()}");
+          debugPrint("Error translate: ${e.toString()}");
         }
       }
     });
@@ -175,7 +175,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                   var translate = await translator.translate(data['msg']??'', to: locale);
                   data['translate'] = translate.text;
                 }catch(e){
-                  print("Error translate: ${e.toString()}");
+                  debugPrint("Error translate: ${e.toString()}");
                 }
               }
               bool alreadyExists = messageData.any((element) => element['uniqueId'] == data['uniqueId']);
@@ -185,7 +185,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
             }
             downloadImage(data);
           } else if (result.type == DocumentChangeType.modified && isAfterLoad) {
-            if (messageData.where((element) => element['uniqueId'] == data!['uniqueId']).length > 0) {
+            if (messageData.where((element) => element['uniqueId'] == data!['uniqueId']).isNotEmpty) {
               int index = messageData.indexWhere((element) => element['uniqueId'] == data!['uniqueId']);
               messageData[index]['read'] = data!['read'];
               messageData[index]['readStatus'] = data['readStatus'];
@@ -194,7 +194,9 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
           if(mounted) setState(() {});
         });
       });
-    }catch(e){}
+    }catch(e){
+      debugPrint(e.toString());
+    }
 
     if(mounted) {
       setState(() {
@@ -230,7 +232,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
   sendMessage(data) async {
     setState(() {
       isSend = false;
-      controllerPesan.clear();
+      controllerMessage.clear();
       messageData.add({
         'msg': data['text'],
         'datetime': DateTime.now().toString(),
@@ -286,7 +288,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
   @override
   Widget build(BuildContext context) {
     WidgetsBinding.instance.addPostFrameCallback((_) {
-      if (messageData.length > 0) {
+      if (messageData.isNotEmpty) {
         if (scrollController.position.maxScrollExtent > 0 && !isReverse) {
           setState(() => isReverse = true);
         }
@@ -321,7 +323,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
             child: Container(
               alignment: Alignment.topCenter,
               width: U.bodyWidth(context),
-              child: messageData.length == 0 && !isAfterLoad ? loadingTemplateNoVoid() : SingleChildScrollView(
+              child: messageData.isEmpty && !isAfterLoad ? loadingTemplateNoVoid() : SingleChildScrollView(
                 controller: scrollController,
                 reverse: isReverse,
                 padding: EdgeInsets.fromLTRB(10, 10, 10, 7),
@@ -413,7 +415,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                                         }
                                       },
                                       onLongPress: (link) {
-                                        Clipboard.setData(new ClipboardData(text: link)).then((value){
+                                        Clipboard.setData(ClipboardData(text: link)).then((value){
                                           showSuccess('link_copied'.tr(), context);
                                         });
                                       },
@@ -444,11 +446,11 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                           var expander = Expanded(
                               flex: 8,
                               child: Column(
+                                crossAxisAlignment: isMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
                                 children: [
                                   bubleChat(widget, timeBubble, isNip, isMe),
                                   SizedBox(height: 5),
                                 ],
-                                crossAxisAlignment: isMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
                               )
                           );
 
@@ -492,7 +494,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                     child: SizedBox(
                       width: double.infinity,
                       child: TextField(
-                        controller: controllerPesan,
+                        controller: controllerMessage,
                         maxLength: 256,
                         style: const TextStyle(fontSize: 14, color: Colors.black),
                         keyboardType: TextInputType.multiline,
@@ -500,7 +502,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                         maxLines: 5,
                         decoration: InputDecoration(
                             counterText: '',
-                            hintText: 'writeMessage'.tr()+'..',
+                            hintText: '${'writeMessage'.tr()}..',
                             hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
                             filled: true,
                             fillColor: backgroundColor,
@@ -515,7 +517,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                                   "userId": username,
                                   "recipientId": "#forum",
                                   "senderType": "INFORMANT",
-                                  "text": controllerPesan.text.trim(),
+                                  "text": controllerMessage.text.trim(),
                                   "chatId": idChat,
                                   "images": null
                                 };
@@ -611,21 +613,21 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
                   GestureDetector(
                     child: Container(
                       padding: EdgeInsets.all(12),
-                      child: Image.asset('assets/image/icon/Send.png', width: 25, height: 25),
                       decoration: BoxDecoration(
                           color: primaryColor,
                           borderRadius: BorderRadius.all(Radius.circular(50))
                       ),
+                      child: Image.asset('assets/image/icon/Send.png', width: 25, height: 25),
                     ),
                     onTap: (){
-                      if(controllerPesan.text.isNotEmpty){
+                      if(controllerMessage.text.isNotEmpty){
                         var uuid = Uuid().v1().replaceAll('-', '');
                         var data = {
                           "uniqueId": uuid,
                           "userId": username,
                           "recipientId": "#forum",
                           "senderType": "INFORMANT",
-                          "text": controllerPesan.text.trim(),
+                          "text": controllerMessage.text.trim(),
                           "chatId": idChat,
                           "images": null
                         };
@@ -661,7 +663,7 @@ class _MobHistoryForumPageState extends State<MobHistoryForumPage> {
         });
       }
     } catch (e) {
-      print(e.toString());
+      debugPrint(e.toString());
     }
   }
 

+ 4 - 4
lib/src/layouts/mobile/history_rating.dart

@@ -17,7 +17,7 @@ class _MobHistoryRatingPageState extends State<MobHistoryRatingPage> {
   String description = '';
   String ratingAspect = '';
   List aspectList = [];
-  TextEditingController controllerOptOther = new TextEditingController();
+  TextEditingController controllerOptOther = TextEditingController();
 
   var rating = [
     {'key': 1, 'image': "assets/image/icon/very_dissatisfied.png", 'label': 'disatisfied'.tr()},
@@ -29,7 +29,7 @@ class _MobHistoryRatingPageState extends State<MobHistoryRatingPage> {
 
   getAspectList(){
     String locale = context.locale.toString();
-    List optionList = widget.data['_ratingAspect'+locale[0].toUpperCase()+locale[1]] != null && widget.data['_ratingAspect'+locale[0].toUpperCase()+locale[1]].trim() != '' ? widget.data['_ratingAspect'+locale[0].toUpperCase()+locale[1]].split(';') : [];
+    List optionList = widget.data['_ratingAspect${locale[0].toUpperCase()}${locale[1]}'] != null && widget.data['_ratingAspect${locale[0].toUpperCase()}${locale[1]}'].trim() != '' ? widget.data['_ratingAspect${locale[0].toUpperCase()}${locale[1]}'].split(';') : [];
     if(optionList.isNotEmpty){
       optionList.add('OTHER_OPTION');
     }
@@ -109,7 +109,7 @@ class _MobHistoryRatingPageState extends State<MobHistoryRatingPage> {
                       child: Column(
                         crossAxisAlignment: CrossAxisAlignment.start,
                         children: [
-                          Text('whatMakesYou'.tr()+' '+description+'?', style: TextStyle(fontSize: 16)),
+                          Text('${'whatMakesYou'.tr()} $description?', style: TextStyle(fontSize: 16)),
                           SizedBox(height: 12),
                           Wrap(
                             runSpacing: 10, spacing: 10,
@@ -117,12 +117,12 @@ class _MobHistoryRatingPageState extends State<MobHistoryRatingPage> {
                               return GestureDetector(
                                 child: Container(
                                   padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10),
-                                  child: Text(aspectList[i]=='OTHER_OPTION'?'letMeWrite'.tr():aspectList[i], style: TextStyle(color: textColor)),
                                   decoration: BoxDecoration(
                                     color: aspectList[i] == ratingAspect ? primaryColor.withValues(alpha: 0.3) : Colors.white,
                                     border: Border.all(color: aspectList[i] == ratingAspect ? primaryColor : textColor),
                                     borderRadius: BorderRadius.all(Radius.circular(50))
                                   ),
+                                  child: Text(aspectList[i]=='OTHER_OPTION'?'letMeWrite'.tr():aspectList[i], style: TextStyle(color: textColor)),
                                 ),
                                 onTap: (){
                                   setState(() {

+ 17 - 17
lib/src/layouts/mobile/menu_account.dart

@@ -108,9 +108,9 @@ class _MobAccountPageState extends State<MobAccountPage> {
                       child: Row(
                         children: [
                           CircleAvatar(
-                            child: Text(Provider.of<UserModule>(context).user()['name'][0].toString().toUpperCase(), style: TextStyle(color: Colors.white)),
                             backgroundColor: primaryColor,
                             radius: 25,
+                            child: Text(Provider.of<UserModule>(context).user()['name'][0].toString().toUpperCase(), style: TextStyle(color: Colors.white)),
                           ),
                           SizedBox(width: 16),
                           Expanded(child: Text(Provider.of<UserModule>(context).user()['name'], style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: textColor), maxLines: 2, overflow: TextOverflow.ellipsis))
@@ -147,27 +147,27 @@ class _MobAccountPageState extends State<MobAccountPage> {
                               Text(dnd?'active_dnd'.tr():'inactive_dnd'.tr(), style: TextStyle(color: textColor, fontSize: 14)),
                               SizedBox(width: 5),
                               GestureDetector(
+                                onTap: Provider.of<UserModule>(context).user()['checkedIn']?(){
+                                  dialogConfirm(context: context, title: 'set_dnd_status'.tr(), text: dnd?'msg_change_inactive'.tr():'msg_change_active'.tr(), actionYes: ()async{
+                                    bool res = await accFunc.setDndStatus(context, dnd);
+                                    if(res){
+                                      setState(() => dnd = !dnd);
+                                    }
+                                  });
+                                }:null,
                                 child: Container(
                                   decoration: BoxDecoration(border: Border.all(color: Provider.of<UserModule>(context).user()['checkedIn']?primaryColor:Colors.black38, width: 1.5), borderRadius: BorderRadius.all(Radius.circular(50))),
                                   child: Row(
                                     children: [
                                       !dnd?Container(
                                         width: 20, height: 20, decoration: BoxDecoration(color: Provider.of<UserModule>(context).user()['checkedIn']?primaryColor:Colors.black38, borderRadius: BorderRadius.all(Radius.circular(20))),
-                                      ):Container(width: 20, height: 20),
+                                      ):SizedBox(width: 20, height: 20),
                                       dnd?Container(
                                         width: 20, height: 20, decoration: BoxDecoration(color: Provider.of<UserModule>(context).user()['checkedIn']?primaryColor:Colors.black38, borderRadius: BorderRadius.all(Radius.circular(20))),
-                                      ):Container(width: 20, height: 20),
+                                      ):SizedBox(width: 20, height: 20),
                                     ],
                                   ),
                                 ),
-                                onTap: Provider.of<UserModule>(context).user()['checkedIn']?(){
-                                  dialogConfirm(context: context, title: 'set_dnd_status'.tr(), text: dnd?'msg_change_inactive'.tr():'msg_change_active'.tr(), actionYes: ()async{
-                                    bool res = await accFunc.setDndStatus(context, dnd);
-                                    if(res){
-                                      setState(() => dnd = !dnd);
-                                    }
-                                  });
-                                }:null,
                               ),
                             ],
                           )
@@ -193,10 +193,10 @@ class _MobAccountPageState extends State<MobAccountPage> {
                                     children: [
                                       !serDis?Container(
                                         width: 20, height: 20, decoration: BoxDecoration(color: primaryColor, borderRadius: BorderRadius.all(Radius.circular(20))),
-                                      ):Container(width: 20, height: 20),
+                                      ):SizedBox(width: 20, height: 20),
                                       serDis?Container(
                                         width: 20, height: 20, decoration: BoxDecoration(color: primaryColor, borderRadius: BorderRadius.all(Radius.circular(20))),
-                                      ):Container(width: 20, height: 20),
+                                      ):SizedBox(width: 20, height: 20),
                                     ],
                                   ),
                                 ),
@@ -262,10 +262,10 @@ class _MobAccountPageState extends State<MobAccountPage> {
                                       children: [
                                         !autoTranslate?Container(
                                           width: 20, height: 20, decoration: BoxDecoration(color: Colors.black38, borderRadius: BorderRadius.all(Radius.circular(20))),
-                                        ):Container(width: 20, height: 20),
+                                        ):SizedBox(width: 20, height: 20),
                                         autoTranslate?Container(
                                           width: 20, height: 20, decoration: BoxDecoration(color: primaryColor, borderRadius: BorderRadius.all(Radius.circular(20))),
-                                        ):Container(width: 20, height: 20),
+                                        ):SizedBox(width: 20, height: 20),
                                       ],
                                     ),
                                   ),
@@ -364,7 +364,7 @@ class _MobAccountPageState extends State<MobAccountPage> {
                       onTap: (){
                         var size = MediaQuery.of(context).size.width - (MediaQuery.of(context).size.width/3);
                         var pid = U.getPidFromUrl(context.router.currentUrl);
-                        var qr_data = 'https://telnow.telmessenger.com/#/app/${pid}%23${U.getBaseUrl()}';
+                        var qrData = 'https://telnow.telmessenger.com/#/app/$pid%23${U.getBaseUrl()}';
                         showDialog(
                           context: context,
                           builder: (BuildContext context) {
@@ -378,7 +378,7 @@ class _MobAccountPageState extends State<MobAccountPage> {
                                     width: size,
                                     height: size,
                                     child: QrImageView(
-                                      data: qr_data,
+                                      data: qrData,
                                       version: QrVersions.auto,
                                       gapless: true,
                                     ),

+ 2 - 2
lib/src/layouts/mobile/menu_history.dart

@@ -36,7 +36,7 @@ class _MobHistoryPageState extends State<MobHistoryPage> with TickerProviderStat
   @override
   void initState() {
     Provider.of<HistoryModule>(context, listen: false).reset();
-    _animationController = new AnimationController(vsync: this, duration: Duration(seconds: 1));
+    _animationController = AnimationController(vsync: this, duration: Duration(seconds: 1));
     _animationController.repeat(reverse: true);
     
     WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -55,7 +55,7 @@ class _MobHistoryPageState extends State<MobHistoryPage> with TickerProviderStat
   @override
   Widget build(BuildContext context) {
     eventBus.on().listen((event){
-      print(event.toString());
+      debugPrint(event.toString());
     });
     return Provider.of<UserModule>(context).resetData() ? RefreshPage(() {
       Provider.of<UserModule>(context, listen: false).setResetData(false);

File diff suppressed because it is too large
+ 30 - 30
lib/src/layouts/mobile/menu_home.dart


+ 7 - 6
lib/src/layouts/mobile/message_chat.dart

@@ -184,6 +184,7 @@ class _MobMessageChatPageState extends State<MobMessageChatPage> {
   }
 
   deleteCollection() {
+    debugPrint("popped");
     FirebaseFirestore.instance.collection("tmMessages").doc('messages').collection(idChat!).get().then((value) {
       for (DocumentSnapshot ds in value.docs) {
         ds.reference.delete();
@@ -233,7 +234,7 @@ class _MobMessageChatPageState extends State<MobMessageChatPage> {
   Widget build(BuildContext context) {
     var bodyWidth = U.bodyWidth(context);
     WidgetsBinding.instance.addPostFrameCallback((_) {
-      if (messageData.length > 0) {
+      if (messageData.isNotEmpty) {
         if (scrollController.position.maxScrollExtent > 0 && !isReverse) {
           setState(() => isReverse = true);
         }
@@ -244,11 +245,11 @@ class _MobMessageChatPageState extends State<MobMessageChatPage> {
       }
     });
 
-    return WillPopScope(
-      onWillPop: () async {
+    return PopScope(
+      onPopInvoked: (didPop) async {
         deleteCollection();
         Navigator.of(context).pop();
-        return true;
+        // return true;
       },
       child: Scaffold(
         backgroundColor: Colors.white,
@@ -258,10 +259,10 @@ class _MobMessageChatPageState extends State<MobMessageChatPage> {
           children: [
             divider(),
             U.getInternetStatus()?Expanded(
-              child: Container(width: bodyWidth,
+              child: SizedBox(width: bodyWidth,
                 child:LayoutBuilder(
                     builder: (context,constraint) {
-                      return messageData.length == 0 && !isAfterLoad ? loadingTemplateNoVoid() : Column(
+                      return messageData.isEmpty && !isAfterLoad ? loadingTemplateNoVoid() : Column(
                         children: [
                           Expanded(
                             child: SingleChildScrollView(