简体   繁体   中英

How can i (for debug goals) write to files on the pc which i run the app in debug mode on in flutter?

So I'm currently making a webscraper app, and i have some weird responses which i want to examine. But of course it more than 7000 characters since it is an html so i can't simply just print() it. Is there any way to save Strings created runtime?

You can save to a .txt fairly easily and within the project for you to comb through. This link regarding reading and writing files should help

My suggestion would be to extract your HTTP/webscraping code into a plain Dart package, and then to make your Flutter app dependent on your new package.

A Dart package is a self-contained library in which you can provide the library code, together with test routines and examples of how to use it. The beauty of this is that you could write an example that exercised part of your library, perhaps grabbing the raw data - and it could write it to a file. Equally, you could use the Dart debugger to inspect variables. Note that you should download and install the Dart SDK to your PC - don't try to use the one bundled in the flutter installation. You'll find that you can test the bulk of your parsing logic without even using a mobile device or emulator.

Create the Dart package in a sibling folder of the Flutter app and refer to it in the app's pubspec.yaml with (assuming you called your package 'scraper'):

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  cupertino_icons: ^0.1.2
  scraper:
    path: ../scraper

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM