@@ -8,7 +8,7 @@ import 'package:http/http.dart' as http;
88import 'package:file_picker/file_picker.dart' ;
99import 'package:path_provider/path_provider.dart' ;
1010import 'package:share_plus/share_plus.dart' ;
11- import 'package:excel/excel.dart' ;
11+ import 'package:excel/excel.dart' as excel ;
1212
1313void main () {
1414 runApp (const InstagramUsernameChecker ());
@@ -53,7 +53,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
5353 File ? _pickedFile;
5454 File ? _jsonFile;
5555 String _inputFileName = "usernames" ; // Default name for text input
56-
56+
5757 // Configuration
5858 static const int _maxRetries = 10 ;
5959 static const int _initialDelay = 1 ;
@@ -112,10 +112,10 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
112112
113113 Future <void > _uploadFile () async {
114114 if (_pickedFile == null ) return ;
115-
115+
116116 final content = await _pickedFile! .readAsString ();
117117 List <String > usernames = [];
118-
118+
119119 if (_pickedFile! .path.endsWith ('.json' )) {
120120 final List <dynamic > data = jsonDecode (content);
121121 for (var entry in data) {
@@ -126,19 +126,19 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
126126 } else {
127127 usernames = content.split ('\n ' ).where ((line) => line.trim ().isNotEmpty).toList ();
128128 }
129-
129+
130130 _startProcessing (usernames);
131131 }
132132
133133 Future <void > _uploadText () async {
134134 final text = _textController.text;
135135 if (text.trim ().isEmpty) return ;
136-
136+
137137 // For text input, use default filename
138138 setState (() {
139139 _inputFileName = "usernames" ;
140140 });
141-
141+
142142 final usernames = text.split ('\n ' ).where ((line) => line.trim ().isNotEmpty).toList ();
143143 _startProcessing (usernames);
144144 }
@@ -158,36 +158,36 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
158158
159159 // Create a semaphore to limit concurrent requests
160160 final semaphore = Semaphore (_concurrentLimit);
161-
161+
162162 // Process all usernames
163163 final futures = usernames.map ((username) => _checkUsername (username, semaphore));
164164 final results = await Future .wait (futures);
165-
165+
166166 if (! _isCancelled) {
167167 setState (() {
168168 _isProcessing = false ;
169169 });
170-
170+
171171 // Save active accounts to file
172172 await _saveResults ();
173173 }
174174 }
175175
176176 Future <Map <String , dynamic >> _checkUsername (String username, Semaphore semaphore) async {
177177 if (_isCancelled) return {'status' : 'CANCELLED' , 'message' : 'Processing cancelled' };
178-
178+
179179 final url = Uri .parse ('https://i.instagram.com/api/v1/users/web_profile_info/?username=$username ' );
180180 int retryCount = 0 ;
181181 double delay = _initialDelay.toDouble ();
182-
182+
183183 while (retryCount < _maxRetries && ! _isCancelled) {
184184 await semaphore.acquire ();
185-
185+
186186 try {
187187 final response = await http.get (url, headers: _headers).timeout (const Duration (seconds: 30 ));
188-
188+
189189 semaphore.release ();
190-
190+
191191 if (response.statusCode == 404 ) {
192192 _updateCounts ('AVAILABLE' , username);
193193 return {'status' : 'AVAILABLE' , 'message' : '[AVAILABLE] $username ' };
@@ -214,19 +214,19 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
214214 await Future .delayed (Duration (seconds: delay.toInt ()));
215215 }
216216 }
217-
217+
218218 if (_isCancelled) return {'status' : 'CANCELLED' , 'message' : 'Processing cancelled' };
219-
219+
220220 _updateCounts ('ERROR' , username);
221221 return {'status' : 'ERROR' , 'message' : '[ERROR] $username - Max retries exceeded' };
222222 }
223223
224224 void _updateCounts (String status, String username) {
225225 if (_isCancelled) return ;
226-
226+
227227 setState (() {
228228 _processedCount++ ;
229-
229+
230230 switch (status) {
231231 case 'ACTIVE' :
232232 _activeCount++ ;
@@ -239,21 +239,21 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
239239 _errorCount++ ;
240240 break ;
241241 }
242-
242+
243243 _results.add ('[${status .toUpperCase ()}] $username ' );
244244 });
245245 }
246246
247247 Future <void > _saveResults () async {
248248 if (_activeAccounts.isEmpty) return ;
249-
249+
250250 final directory = await getApplicationDocumentsDirectory ();
251251 // File naming logic: final_{name}.json
252252 final fileName = "final_$_inputFileName .json" ;
253253 final file = File ('${directory .path }/$fileName ' );
254-
254+
255255 await file.writeAsString (jsonEncode (_activeAccounts));
256-
256+
257257 // Show success message
258258 ScaffoldMessenger .of (context).showSnackBar (
259259 SnackBar (
@@ -265,68 +265,68 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
265265
266266 Future <void > _downloadResults () async {
267267 if (_activeAccounts.isEmpty) return ;
268-
268+
269269 final directory = await getApplicationDocumentsDirectory ();
270270 // File naming logic: final_{name}.json
271271 final fileName = "final_$_inputFileName .json" ;
272272 final file = File ('${directory .path }/$fileName ' );
273-
273+
274274 await file.writeAsString (jsonEncode (_activeAccounts));
275-
275+
276276 // Share the file
277277 await Share .shareXFiles ([XFile (file.path)], text: 'Active Instagram Accounts' );
278278 }
279279
280280 Future <void > _convertJsonToExcel () async {
281281 if (_jsonFile == null ) return ;
282-
282+
283283 try {
284284 final content = await _jsonFile! .readAsString ();
285285 final List <dynamic > data = jsonDecode (content);
286-
286+
287287 // Create Excel workbook
288- final excel = Excel .createExcel ();
289- final sheetObject = excel ['Sheet1' ];
290-
288+ final excelFile = excel. Excel .createExcel ();
289+ final sheetObject = excelFile ['Sheet1' ];
290+
291291 // Add headers
292- sheetObject.cell (CellIndex .indexByString ('A1' )).value = 'Username' ;
293- sheetObject.cell (CellIndex .indexByString ('B1' )).value = 'Password' ;
294- sheetObject.cell (CellIndex .indexByString ('C1' )).value = 'Authcode' ;
295- sheetObject.cell (CellIndex .indexByString ('D1' )).value = 'Email' ;
296-
292+ sheetObject.cell (excel. CellIndex .indexByString ('A1' )).value = excel. TextCellValue ( 'Username' ) ;
293+ sheetObject.cell (excel. CellIndex .indexByString ('B1' )).value = excel. TextCellValue ( 'Password' ) ;
294+ sheetObject.cell (excel. CellIndex .indexByString ('C1' )).value = excel. TextCellValue ( 'Authcode' ) ;
295+ sheetObject.cell (excel. CellIndex .indexByString ('D1' )).value = excel. TextCellValue ( 'Email' ) ;
296+
297297 // Add data
298298 for (int i = 0 ; i < data.length; i++ ) {
299299 final item = data[i];
300300 final rowIndex = i + 2 ; // Start from row 2 (after headers)
301-
302- sheetObject.cell (CellIndex .indexByString ('A$rowIndex ' )).value = item['username' ]? .toString () ?? '' ;
303- sheetObject.cell (CellIndex .indexByString ('B$rowIndex ' )).value = item['password' ]? .toString () ?? '' ;
304- sheetObject.cell (CellIndex .indexByString ('C$rowIndex ' )).value = item['auth_code' ]? .toString () ?? '' ;
305- sheetObject.cell (CellIndex .indexByString ('D$rowIndex ' )).value = item['email' ]? .toString () ?? '' ;
301+
302+ sheetObject.cell (excel. CellIndex .indexByString ('A$rowIndex ' )).value = excel. TextCellValue ( item['username' ]? .toString () ?? '' ) ;
303+ sheetObject.cell (excel. CellIndex .indexByString ('B$rowIndex ' )).value = excel. TextCellValue ( item['password' ]? .toString () ?? '' ) ;
304+ sheetObject.cell (excel. CellIndex .indexByString ('C$rowIndex ' )).value = excel. TextCellValue ( item['auth_code' ]? .toString () ?? '' ) ;
305+ sheetObject.cell (excel. CellIndex .indexByString ('D$rowIndex ' )).value = excel. TextCellValue ( item['email' ]? .toString () ?? '' ) ;
306306 }
307-
307+
308308 // Save file
309309 final directory = await getApplicationDocumentsDirectory ();
310310 // File naming logic: {name}.xlsx (same name as input file but with .xlsx extension)
311311 String path = _jsonFile! .path;
312312 String baseName = path.split ('/' ).last.split ('.' ).first;
313313 final fileName = "$baseName .xlsx" ;
314314 final file = File ('${directory .path }/$fileName ' );
315-
315+
316316 // Write the file
317- final List <int >? bytes = excel .save ();
317+ final List <int >? bytes = excelFile .save ();
318318 if (bytes != null ) {
319319 await file.writeAsBytes (bytes);
320320 }
321-
321+
322322 // Show success message
323323 ScaffoldMessenger .of (context).showSnackBar (
324324 SnackBar (
325325 content: Text ('Excel file saved to ${file .path }' ),
326326 backgroundColor: Colors .green,
327327 ),
328328 );
329-
329+
330330 // Share the file
331331 await Share .shareXFiles ([XFile (file.path)], text: 'Converted Excel File' );
332332 } catch (e) {
@@ -564,7 +564,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
564564
565565 Widget _buildProgressSection () {
566566 if (! _isProcessing && _processedCount == 0 ) return const SizedBox ();
567-
567+
568568 return Card (
569569 elevation: 2 ,
570570 shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (12 )),
@@ -692,7 +692,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
692692
693693 Widget _buildResultsSection () {
694694 if (_results.isEmpty) return const SizedBox ();
695-
695+
696696 return Card (
697697 elevation: 2 ,
698698 shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (12 )),
@@ -719,15 +719,15 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
719719 itemBuilder: (context, index) {
720720 final result = _results[index];
721721 Color textColor = Colors .black;
722-
722+
723723 if (result.startsWith ('[ACTIVE]' )) {
724724 textColor = Colors .red[700 ]! ;
725725 } else if (result.startsWith ('[AVAILABLE]' )) {
726726 textColor = Colors .green[700 ]! ;
727727 } else if (result.startsWith ('[ERROR]' )) {
728728 textColor = Colors .yellow[700 ]! ;
729729 }
730-
730+
731731 return Padding (
732732 padding: const EdgeInsets .symmetric (vertical: 4.0 ),
733733 child: Text (
@@ -749,20 +749,20 @@ class Semaphore {
749749 final int maxConcurrent;
750750 int _current = 0 ;
751751 final List <Completer <void >> _waiters = [];
752-
752+
753753 Semaphore (this .maxConcurrent);
754-
754+
755755 Future <void > acquire () async {
756756 if (_current < maxConcurrent) {
757757 _current++ ;
758758 return ;
759759 }
760-
760+
761761 final completer = Completer <void >();
762762 _waiters.add (completer);
763763 await completer.future;
764764 }
765-
765+
766766 void release () {
767767 if (_waiters.isNotEmpty) {
768768 final completer = _waiters.removeAt (0 );
0 commit comments