A beautiful, gradient-based balance checker application for DPDC (Dhaka Power Distribution Company) that allows users to check their electricity account balance by entering their customer ID.
Target Platforms: Mobile (Android/iOS), Web, Desktop (Windows/macOS/Linux) Design Style: Gradient/Colorful with vibrant aesthetics Key Features: Balance checking, Save customer IDs, Share/Export functionality
- Framework: Flutter (Dart)
- State Management: StatefulWidget (can upgrade to Provider/Riverpod if needed)
- HTTP Client:
httppackage - Local Storage:
shared_preferences - Sharing:
share_plus
Endpoint: https://amiapp.dpdc.org.bd/auth/login/generate-bearer
Method: POST
Headers:
- Content-Type: application/json;charset=UTF-8
- clientId: auth-ui
- clientSecret: 0yFsAl4nN9jX1GGkgOrvpUxDarf2DT40
- tenantCode: DPDC
Body: {}
Response: { "token": "..." }
Endpoint: https://amiapp.dpdc.org.bd/usage/usage-service
Method: POST
Headers:
- Content-Type: application/json;charset=UTF-8
- Authorization: Bearer {token}
- accessToken: {token}
- tenantCode: DPDC
Body: GraphQL Query
{
"query": "query{ postBalanceDetails(input :{\n customerNumber:\"{CUSTOMER_ID}\",tenantCode:\"DPDC\" \n } ) { accountId customerName customerClass mobileNumber emailId accountType balanceRemaining connectionStatus customerType minRecharge}}"
}
Response Fields:
- accountId
- customerName
- customerClass
- mobileNumber
- emailId
- accountType
- balanceRemaining (MAIN DISPLAY)
- connectionStatus
- customerType
- minRecharge
File: pubspec.yaml
Add dependencies:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
http: ^1.2.0
shared_preferences: ^2.2.2
share_plus: ^7.2.1Run: flutter pub get
File: lib/services/dpdc_api_service.dart
Responsibilities:
- Generate bearer token from DPDC auth endpoint
- Fetch balance details using the token
- Parse API responses
- Handle network errors and timeouts
- Return structured data or error messages
Key Methods:
Future<String> generateBearerToken()
Future<BalanceDetails> fetchBalanceDetails(String customerId)Error Handling:
- Network connectivity issues
- Invalid API responses
- Token generation failures
- Customer ID not found
- Server errors (500, 503, etc.)
File: lib/models/balance_details.dart
BalanceDetails Class:
class BalanceDetails {
final String accountId;
final String customerName;
final String customerClass;
final String? mobileNumber;
final String? emailId;
final String accountType;
final double balanceRemaining;
final String connectionStatus;
final String customerType;
final double? minRecharge;
// Constructor, fromJson, toJson methods
}File: lib/services/storage_service.dart
Responsibilities:
- Save customer IDs with optional labels
- Retrieve list of saved customer IDs
- Delete saved customer IDs
- Store search history (optional)
Key Methods:
Future<void> saveCustomerId(String id, {String? label})
Future<List<String>> getSavedCustomerIds()
Future<void> deleteCustomerId(String id)File: lib/screens/home_screen.dart
UI Components:
-
Gradient Background
- Use
LinearGradientorRadialGradient - Vibrant colors (e.g., blue to purple, orange to pink)
- Use
-
Header Section
- DPDC logo or title
- Subtitle: "Check Your Balance"
-
Input Section
- Text field for customer ID
- Input validation (numeric, length check)
- Clear button
-
Saved IDs Section (if any exist)
- Dropdown or list of previously saved IDs
- Quick select functionality
-
Action Button
- Large, prominent "Check Balance" button
- Gradient background matching theme
- Tap animation/ripple effect
-
Loading State
- Circular progress indicator
- Disable input during API call
- Loading message
Validation Rules:
- Customer ID must not be empty
- Must be numeric
- Reasonable length (8-12 digits)
User Flow:
Enter Customer ID → Validate → Show Loading → Generate Token → Fetch Balance → Navigate to Results
File: lib/screens/balance_screen.dart
UI Layout:
-
Header Section
- Gradient background
- Back button
- Success icon/checkmark
-
Balance Display (PRIMARY)
- LARGE font size (48-64pt)
- Bold weight
- Prominent placement at top
- Format: "৳ X,XXX.XX" or "BDT X,XXX.XX"
- Color: White or contrasting color on gradient
-
Customer Information Cards
- Card-based layout with subtle shadows
- Each card contains:
- Customer Name
- Account ID
- Customer Class
- Customer Type
- Connection Status (with color indicator)
- Mobile Number
- Email ID
- Minimum Recharge
-
Action Buttons
- Save Customer ID button (if not already saved)
- Opens dialog to add optional label
- Share button
- Uses
share_plusto share formatted text
- Uses
- Check Another button
- Navigate back to home screen
- Save Customer ID button (if not already saved)
Share Format:
DPDC Balance Details
-------------------
Customer: {name}
Account ID: {accountId}
Balance: ৳ {balance}
Connection Status: {status}
Checked on: {date/time}
File: lib/widgets/error_dialog.dart
Alert Dialog Components:
- Clear error icon
- Error title
- Descriptive error message
- Action buttons:
- "Retry" (attempt operation again)
- "Cancel" or "Close"
Error Scenarios:
-
Token Generation Failed
- Message: "Unable to connect to DPDC servers. Please try again."
-
Invalid Customer ID
- Message: "Customer ID not found. Please verify and try again."
-
Network Error
- Message: "No internet connection. Please check your network."
-
API Timeout
- Message: "Request timed out. Please try again."
-
Server Error
- Message: "Server error occurred. Please try again later."
Color Scheme:
- Primary gradient: Blue (#3B82F6) to Purple (#8B5CF6)
- Secondary gradient: Orange (#F97316) to Pink (#EC4899)
- Background: Gradient or solid white/light gray
- Text: White on dark gradients, dark on light backgrounds
- Accent: Green for success, Red for errors
Animations:
- Page transition: Slide or fade
- Button press: Scale animation
- Loading: Smooth circular progress
- Card appearance: Fade in with slight slide up
Typography:
- Title: Bold, 24-28pt
- Balance: Extra bold, 48-64pt
- Body: Regular, 14-16pt
- Labels: Medium, 12-14pt
Responsive Design:
- Mobile: Single column layout
- Tablet: Utilize extra space with larger cards
- Desktop: Centered content with max width
- Web: Add padding for large screens
lib/
├── main.dart # App entry point
├── models/
│ └── balance_details.dart # Data model
├── services/
│ ├── dpdc_api_service.dart # API integration
│ └── storage_service.dart # Local storage
├── screens/
│ ├── home_screen.dart # Customer ID input
│ └── balance_screen.dart # Results display
└── widgets/
└── error_dialog.dart # Reusable error dialog
Manual Testing:
- Test with provided customer ID:
31719842 - Test with invalid customer ID
- Test with empty input
- Test network error handling (airplane mode)
- Test save/load customer IDs
- Test share functionality
- Test on multiple platforms (web, mobile, desktop)
Edge Cases:
- Very long customer IDs
- Special characters in input
- Rapid repeated requests
- Token expiration
- Null/missing fields in API response
- Multi-language Support: Bengali translation
- Bill Payment: Integration with payment gateways
- Usage History: View consumption over time
- Notifications: Balance alerts
- Dark Mode: Theme toggle
- Biometric Auth: For saved accounts
- Offline Mode: Cache last checked balance
Current Implementation:
- Token is generated per request (good)
- Client credentials are in code (acceptable for public app)
- No sensitive user data stored locally
Recommendations:
- Do not store tokens long-term
- Clear sensitive data from memory after use
- Use HTTPS for all requests (already implemented by API)
- Validate all user inputs
Before Release:
- Test on real devices (Android/iOS)
- Test on different screen sizes
- Verify web deployment works
- Check app icons and splash screens
- Review and update app permissions
- Test on different network speeds
- Verify error messages are user-friendly
- Performance testing (cold start, API response time)
Platform-Specific:
- Android: Update
build.gradle, permissions, app name - iOS: Update
Info.plist, signing, app name - Web: Configure base URL, favicon, meta tags
- Desktop: Test executable builds
# Install dependencies
flutter pub get
# Run on web
flutter run -d chrome
# Run on mobile (with device connected)
flutter run
# Build for release
flutter build apk # Android
flutter build ios # iOS
flutter build web # Web
flutter build windows # Windows
flutter build macos # macOS
flutter build linux # Linux- Customer ID example:
31719842 - API requires both
AuthorizationandaccessTokenheaders with same token - Balance is returned as a number (likely in BDT)
- Connection status indicates active/inactive account
- Some fields may be null (mobileNumber, emailId)
Created: 2025-11-10 Last Updated: 2025-11-10 Version: 1.0