dart format

This commit is contained in:
2025-11-10 16:50:29 +05:30
parent d6f61ebb31
commit 8cfca113bf
28 changed files with 1995 additions and 1973 deletions

View File

@@ -151,15 +151,13 @@ class AuthService {
if (response.statusCode != 200) {
throw AuthException('Failed to proceed with T&C');
}
}
on DioException catch (e) {
} on DioException catch (e) {
if (kDebugMode) {
print(e.toString());
}
throw NetworkException('Network error during T&C Setup');
} catch (e) {
throw UnexpectedException(
'Unexpected error: ${e.toString()}');
throw UnexpectedException('Unexpected error: ${e.toString()}');
}
}
}

View File

@@ -36,7 +36,8 @@ class AppRoutes {
case login:
return MaterialPageRoute(builder: (_) => const LoginScreen());
case TncRequiredScreen.routeName: // Renamed class
return MaterialPageRoute(builder: (_) => const TncRequiredScreen()); // Renamed class
return MaterialPageRoute(
builder: (_) => const TncRequiredScreen()); // Renamed class
case mPin:
return MaterialPageRoute(
builder: (_) => const MPinScreen(

View File

@@ -25,7 +25,9 @@ class Beneficiary {
return Beneficiary(
accountNo: json['account_no'] ?? json['accountNo'] ?? '',
accountType: json['account_type'] ?? json['accountType'] ?? '',
createdAt: json['createdAt'] == null ? null : DateTime.tryParse(json['createdAt']),
createdAt: json['createdAt'] == null
? null
: DateTime.tryParse(json['createdAt']),
name: json['name'] ?? '',
ifscCode: json['ifsc_code'] ?? json['ifscCode'] ?? '',
bankName: json['bank_name'] ?? json['bankName'] ?? '',

View File

@@ -17,7 +17,8 @@ class AuthRepository {
AuthRepository(this._authService, this._userService, this._secureStorage);
Future<(List<User>, AuthToken)> login(String customerNo, String password) async {
Future<(List<User>, AuthToken)> login(
String customerNo, String password) async {
// Create credentials and call service
final credentials =
AuthCredentials(customerNo: customerNo, password: password);
@@ -64,7 +65,8 @@ class AuthRepository {
final authToken = AuthToken(
accessToken: accessToken,
expiresAt: DateTime.parse(expiryString),
tnc: tncString == 'true', // Parse 'true' string to true, otherwise false
tnc:
tncString == 'true', // Parse 'true' string to true, otherwise false
);
return authToken;
}

View File

@@ -61,8 +61,8 @@ Future<void> setupDependencies() async {
);
// Register controllers/cubits
getIt.registerFactory<AuthCubit>(
() => AuthCubit(getIt<AuthRepository>(), getIt<UserService>(), getIt<SecureStorage>()));
getIt.registerFactory<AuthCubit>(() => AuthCubit(
getIt<AuthRepository>(), getIt<UserService>(), getIt<SecureStorage>()));
}
Dio _createDioClient() {

View File

@@ -45,7 +45,8 @@ class AuthCubit extends Cubit<AuthState> {
Future<void> login(String customerNo, String password) async {
emit(AuthLoading());
try {
final (users, authToken) = await _authRepository.login(customerNo, password);
final (users, authToken) =
await _authRepository.login(customerNo, password);
if (authToken.tnc == false) {
emit(ShowTncDialog(authToken, users));
@@ -57,7 +58,6 @@ class AuthCubit extends Cubit<AuthState> {
}
}
Future<void> onTncDialogResult(
bool agreed, AuthToken authToken, List<User> users) async {
if (agreed) {
@@ -83,7 +83,6 @@ class AuthCubit extends Cubit<AuthState> {
}
}
Future<void> _checkMpinAndNavigate(List<User> users) async {
final mpin = await _secureStorage.read('mpin');
if (mpin == null) {
@@ -94,5 +93,4 @@ class AuthCubit extends Cubit<AuthState> {
emit(Authenticated(users));
}
}
}

View File

@@ -28,7 +28,8 @@ class AuthToken extends Equatable {
return AuthToken(
accessToken: token,
expiresAt: _decodeExpiryFromToken(token), // This method is still valid for JWT expiry
expiresAt: _decodeExpiryFromToken(
token), // This method is still valid for JWT expiry
tnc: tncMobileValue, // Use the correctly extracted value
);
}

View File

@@ -255,7 +255,8 @@ class LoginScreenState extends State<LoginScreen>
} else if (state is NavigateToTncRequiredScreen) {
Navigator.of(context).pushNamed(TncRequiredScreen.routeName);
} else if (state is NavigateToMpinSetupScreen) {
Navigator.of(context).push( // Use push, NOT pushReplacement
Navigator.of(context).push(
// Use push, NOT pushReplacement
MaterialPageRoute(
builder: (_) => MPinScreen(
mode: MPinMode.set,

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
class TncRequiredScreen extends StatelessWidget { // Renamed class
class TncRequiredScreen extends StatelessWidget {
// Renamed class
const TncRequiredScreen({Key? key}) : super(key: key);
static const routeName = '/tnc-required';

View File

@@ -269,7 +269,9 @@ class _DashboardScreenState extends State<DashboardScreen>
final users = state.users;
final currAccount = users[selectedAccountIndex];
final accountType = currAccount.accountType?.toLowerCase();
final isPaymentDisabled = accountType != 'sa' && accountType != 'sb' && accountType != 'ca';
final isPaymentDisabled = accountType != 'sa' &&
accountType != 'sb' &&
accountType != 'ca';
// firsttime load
if (!_txInitialized) {
_txInitialized = true;
@@ -509,8 +511,7 @@ class _DashboardScreenState extends State<DashboardScreen>
users[selectedAccountIndex]
.accountNo!,
remitterName:
users[selectedAccountIndex]
.name!,
users[selectedAccountIndex].name!,
// Pass the full list of accounts
accounts: users)));
}, disable: isPaymentDisabled),

View File

@@ -62,7 +62,8 @@
@override
Widget build(BuildContext context) {
if (_timeRemaining == Duration.zero) {
return const SizedBox.shrink(); // Or some other widget indicating it's enabled
return const SizedBox
.shrink(); // Or some other widget indicating it's enabled
}
return Column(

View File

@@ -58,6 +58,7 @@ void initState() {
_loadLimit(); // Call the new method
_amountController.addListener(_checkAmountLimit);
}
Future<void> _loadLimit() async {
setState(() {
_isLoadingLimit = true;
@@ -87,7 +88,8 @@ void _checkAmountLimit() {
if (isOverLimit) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
content: Text(
'Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
backgroundColor: Colors.red,
),
);
@@ -487,8 +489,7 @@ void _checkAmountLimit() {
},
),
const SizedBox(height: 8),
if (_isLoadingLimit)
const Text('Fetching daily limit...'),
if (_isLoadingLimit) const Text('Fetching daily limit...'),
if (!_isLoadingLimit && _limit != null)
Text(
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',

View File

@@ -73,7 +73,6 @@ class _FundTransferBeneficiaryScreenState
);
}
Widget _buildBeneficiaryList() {
if (_beneficiaries.isEmpty) {
return Center(
@@ -155,7 +154,6 @@ class _FundTransferBeneficiaryScreenState
);
}
@override
Widget build(BuildContext context) {
return Scaffold(

View File

@@ -57,8 +57,8 @@
leading: CircleAvatar(
radius: 24,
backgroundColor: Colors.transparent,
child:
getBankLogo('Kangra Central Co-operative Bank', context),
child: getBankLogo(
'Kangra Central Co-operative Bank', context),
),
title: Text(account.name ?? 'N/A'),
subtitle: Column(
@@ -67,8 +67,7 @@
Text(account.accountNo ?? 'N/A'),
Text(
_getFullAccountType(account.accountType),
style:
TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
),
],
),

View File

@@ -39,12 +39,12 @@ import 'package:kmobile/widgets/bank_logos.dart';
bool _isAmountOverLimit = false;
final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '');
@override
void initState() {
super.initState();
_loadLimit(); // Fetch the daily limit
_amountController.addListener(_checkAmountLimit); // Listen for amount changes
_amountController
.addListener(_checkAmountLimit); // Listen for amount changes
}
@override
@@ -119,8 +119,8 @@ import 'package:kmobile/widgets/bank_logos.dart';
Navigator.of(pinScreenContext).pushReplacement(
MaterialPageRoute(
builder: (_) =>
PaymentAnimationScreen(paymentResponse: paymentResponseFuture),
builder: (_) => PaymentAnimationScreen(
paymentResponse: paymentResponseFuture),
),
);
},
@@ -173,8 +173,8 @@ import 'package:kmobile/widgets/bank_logos.dart';
elevation: 0,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: ListTile(
leading:
getBankLogo('Kangra Central Co-operative Bank', context),
leading: getBankLogo(
'Kangra Central Co-operative Bank', context),
title: Text(widget.creditAccount.name ?? 'N/A'),
subtitle: Text(widget.creditAccount.accountNo ?? 'N/A'),
),
@@ -214,8 +214,7 @@ import 'package:kmobile/widgets/bank_logos.dart';
const SizedBox(height: 8),
// Daily Limit Display
if (_isLoadingLimit)
const Text('Fetching daily limit...'),
if (_isLoadingLimit) const Text('Fetching daily limit...'),
if (!_isLoadingLimit && _limit != null)
Text(
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',

View File

@@ -81,7 +81,8 @@ Future<void> _showAddOrEditLimitDialog() async {
if (value > 200000) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text("Limit To be Set must be less than 200000"),
content: const Text(
"Limit To be Set must be less than 200000"),
behavior: SnackBarBehavior.floating,
backgroundColor: theme.colorScheme.error,
),
@@ -110,7 +111,6 @@ Future<void> _showAddOrEditLimitDialog() async {
}
}
void _removeLimit() {
setState(() {
_currentLimit = null;
@@ -135,7 +135,8 @@ Future<void> _showAddOrEditLimitDialog() async {
final localizations = AppLocalizations.of(context);
final theme = Theme.of(context);
final formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '');
final remainingLimit = _currentLimit != null ? _currentLimit! - _spentAmount! : 0.0;
final remainingLimit =
_currentLimit != null ? _currentLimit! - _spentAmount! : 0.0;
return Scaffold(
appBar: AppBar(

View File

@@ -16,7 +16,6 @@ import 'package:kmobile/features/profile/preferences/preference_screen.dart';
import 'package:kmobile/api/services/auth_service.dart';
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
class ProfileScreen extends StatefulWidget {
final String mobileNumber;
const ProfileScreen({super.key, required this.mobileNumber});
@@ -210,7 +209,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
builder: (BuildContext context) {
return AlertDialog(
title: Text('TPIN Not Set'),
content: Text('You have not set a TPIN yet. Please set a TPIN to proceed.'),
content: Text(
'You have not set a TPIN yet. Please set a TPIN to proceed.'),
actions: <Widget>[
TextButton(
child: Text('Back'),
@@ -238,7 +238,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
// Case 2: TPIN is set
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ChangeTpinScreen(mobileNumber: widget.mobileNumber),
builder: (context) =>
ChangeTpinScreen(mobileNumber: widget.mobileNumber),
),
);
}

View File

@@ -36,7 +36,8 @@ class _ChangeTpinScreenState extends State<ChangeTpinScreen> {
});
try {
// 1. Get OTP for TPIN change.
await _changePasswordService.getOtpTpin(mobileNumber: widget.mobileNumber);
await _changePasswordService.getOtpTpin(
mobileNumber: widget.mobileNumber);
// 2. Navigate to the OTP screen on success.
if (mounted) {

View File

@@ -99,7 +99,8 @@ Future<void> _loadLimit() async {
if (isOverLimit) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
content: Text(
'Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
backgroundColor: Colors.red,
),
);
@@ -783,7 +784,8 @@ Future<void> _loadLimit() async {
border: const OutlineInputBorder(),
isDense: true,
filled: true,
fillColor: Theme.of(context).scaffoldBackgroundColor,
fillColor:
Theme.of(context).scaffoldBackgroundColor,
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.outline),
@@ -808,7 +810,8 @@ Future<void> _loadLimit() async {
border: const OutlineInputBorder(),
isDense: true,
filled: true,
fillColor: Theme.of(context).scaffoldBackgroundColor,
fillColor:
Theme.of(context).scaffoldBackgroundColor,
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.outline),
@@ -824,7 +827,8 @@ Future<void> _loadLimit() async {
textInputAction: TextInputAction.next,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context).amountRequired;
return AppLocalizations.of(context)
.amountRequired;
}
final amount = double.tryParse(value);
if (amount == null || amount <= 0) {
@@ -868,9 +872,12 @@ if (!_isLoadingLimit && _limit != null)
alignment: Alignment.center,
child: SwipeButton.expand(
thumb: Icon(Icons.arrow_forward,
color: _isAmountOverLimit ? Colors.grey : Theme.of(context).dialogBackgroundColor),
activeThumbColor: _isAmountOverLimit ? Colors.grey.shade700 :
Theme.of(context).colorScheme.primary,
color: _isAmountOverLimit
? Colors.grey
: Theme.of(context).dialogBackgroundColor),
activeThumbColor: _isAmountOverLimit
? Colors.grey.shade700
: Theme.of(context).colorScheme.primary,
activeTrackColor: _isAmountOverLimit
? Colors.grey.shade300
: Theme.of(context).colorScheme.secondary.withAlpha(100),

View File

@@ -74,7 +74,8 @@ void _checkAmountLimit() {
if (isOverLimit) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
content: Text(
'Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
backgroundColor: Colors.red,
),
);
@@ -184,7 +185,8 @@ void _checkAmountLimit() {
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary, width: 2),
color: Theme.of(context).colorScheme.primary,
width: 2),
),
),
controller: accountNumberController,
@@ -204,7 +206,8 @@ void _checkAmountLimit() {
TextFormField(
controller: confirmAccountNumberController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).confirmAccountNumber,
labelText:
AppLocalizations.of(context).confirmAccountNumber,
// prefixIcon: Icon(Icons.person),
border: const OutlineInputBorder(),
isDense: true,
@@ -216,7 +219,8 @@ void _checkAmountLimit() {
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary, width: 2),
color: Theme.of(context).colorScheme.primary,
width: 2),
),
),
keyboardType: TextInputType.number,
@@ -256,10 +260,11 @@ void _checkAmountLimit() {
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
child:
CircularProgressIndicator(strokeWidth: 2),
)
: Text(
AppLocalizations.of(context).validateBeneficiary),
: Text(AppLocalizations.of(context)
.validateBeneficiary),
),
),
),
@@ -302,7 +307,8 @@ void _checkAmountLimit() {
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary, width: 2),
color: Theme.of(context).colorScheme.primary,
width: 2),
),
),
value: _selectedAccountType,
@@ -343,12 +349,12 @@ void _checkAmountLimit() {
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary, width: 2),
color: Theme.of(context).colorScheme.primary,
width: 2),
),
),
),
const SizedBox(height: 25),
TextFormField(
decoration: InputDecoration(
labelText: AppLocalizations.of(context).amount,
@@ -362,7 +368,8 @@ void _checkAmountLimit() {
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).colorScheme.primary, width: 2),
color: Theme.of(context).colorScheme.primary,
width: 2),
),
),
controller: amountController,
@@ -380,8 +387,7 @@ void _checkAmountLimit() {
},
),
const SizedBox(height: 8),
if (_isLoadingLimit)
const Text('Fetching daily limit...'),
if (_isLoadingLimit) const Text('Fetching daily limit...'),
if (!_isLoadingLimit && _limit != null)
Text(
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',
@@ -392,9 +398,12 @@ if (!_isLoadingLimit && _limit != null)
alignment: Alignment.center,
child: SwipeButton.expand(
thumb: Icon(Icons.arrow_forward,
color: _isAmountOverLimit ? Colors.grey : Theme.of(context).dialogBackgroundColor),
activeThumbColor: _isAmountOverLimit ? Colors.grey.shade700 :
Theme.of(context).colorScheme.primary,
color: _isAmountOverLimit
? Colors.grey
: Theme.of(context).dialogBackgroundColor),
activeThumbColor: _isAmountOverLimit
? Colors.grey.shade700
: Theme.of(context).colorScheme.primary,
activeTrackColor: _isAmountOverLimit
? Colors.grey.shade300
: Theme.of(

View File

@@ -15,13 +15,13 @@ void main() async {
]);
// Check for device compromise
// final compromisedMessage = await SecurityService.deviceCompromisedMessage;
// if (compromisedMessage != null) {
// runApp(MaterialApp(
// home: SecurityErrorScreen(message: compromisedMessage),
// ));
// return;
// }
final compromisedMessage = await SecurityService.deviceCompromisedMessage;
if (compromisedMessage != null) {
runApp(MaterialApp(
home: SecurityErrorScreen(message: compromisedMessage),
));
return;
}
await setupDependencies();
runApp(const KMobile());
}