Search
 
SCRIPT & CODE EXAMPLE
 

DART

dart read file

import 'dart:convert';
import 'dart:io';

void main(List<String> args) async {
  var myFile = File('myFile');
  // asynchronous
  List<String> linesAsync = await myFile.readAsLines();
  // synchronous
  List<String> linesSync = myFile.readAsLinesSync();
  // stream
  Stream<String> linesStream = myFile.openRead()
  									 .transform(utf8.decoder)
                                     .transform(LineSplitter());
}
Comment

dart Read data from the file

Future<int> readCounter() async {
  try {
    final file = await _localFile;

    // Read the file
    final contents = await file.readAsString();

    return int.parse(contents);
  } catch (e) {
    // If encountering an error, return 0
    return 0;
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: round off in dart 
Dart :: compute flutter 
Dart :: create a validator in flutter 
Dart :: open popupbutton onclick in flutter 
Dart :: flutter main.dart 
Dart :: sign out from firebase flutter 
Dart :: flutter list tile 
Dart :: time difference flutter 
Dart :: flutter listtile selected 
Dart :: dart dictionary 
Dart :: transparent appbar flutter 
Dart :: bottomsheet shape flutter 
Dart :: flutter get number of days in month 
Dart :: Bad state: Stream has already been listened to 
Dart :: flutter text direction rtl 
Dart :: dart convert iterable to list 
Dart :: slice string dart syntax 
Dart :: flutter toast 
Dart :: how to print data types in dart 
Dart :: string to timeofday flutter 
Dart :: flutter pass onchanged callback in arguments 
Dart :: flutter dart imagepicker quality reduce resize 
Dart :: Add Underline Text in Flutter 
Dart :: dart enums 
Dart :: flutter custom error widget 
Dart :: flutter gray screen 
Dart :: change color icon tabbar flutter 
Dart :: dark mode in flutter packages 
Dart :: flutter how to get height and width of screen 
Dart :: flutter sembast delete a single record 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =