Logging large strings from Flutter

前端 未结 8 1960
天涯浪人
天涯浪人 2020-12-17 07:50

I\'m trying to build a Flutter App and learning Dart in the process, but I\'m getting kind of frustrated when debugging. I have fetched a resource from an API and now I want

8条回答
  •  情深已故
    2020-12-17 08:13

    You can make your own print. Define this method

    void printWrapped(String text) {
      final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk
      pattern.allMatches(text).forEach((match) => print(match.group(0)));
    }
    

    Use it like

    printWrapped("Your very long string ...");
    

    Credit

提交回复
热议问题