dedent: ^0.0.2 copied to clipboard
Remove any common leading whitespace from every line in text.
Dedent - Remove any common leading whitespace from every line in text. Ported from Python.
dependencies: dedent: any
then run the usual
flutter pub get or just
pub get for a pure dart project.
It's quite handy to strip leading spaces from multi-line text. Flutter code often involves deeply nested indented code, so any multiline text will end up containing leading spaces or tabs - which may affect your layout!
FittedBox( child: Text(dedent(''' Not really possible to access another widget, or rather, another widget's state in order to change it. You really need to create a model and have the model change cause the change. ''')), )
dedent() removes any common leading whitespace from every line in
This can be used to make triple-quoted strings line up with the left
edge of the display, while still presenting them in the source code
in indented form.
var text = ''' def foo(): while 1: return foo '''; var _expect = ''' def foo(): while 1: return foo '''; expect(_expect, equals(dedent(text)));
dedent()is ported from the long standing and reliable Python
textwrap.dedentalgorithm, complete with the original unit tests, so you know its good. 👍
This project is a direct translation of the Python textwrap.dedent algorithm.
Tests are also ported from Python.
This section is only applicable if you want to fiddle with the dedent source code
When checking out from https://github.com/abulka/flutter-dedent ensure you specify
dedent as a
target so that the package directory is named
git clone firstname.lastname@example.org:abulka/flutter-dedent.git dedent
If you have checked out the
dedent project locally and prefer your other
Dart/Flutter projects to refer to
this local copy instead of to the official version of
pub.dev, simply adjust your
dependencies: dedent: path: ../dedent
which assumes a directory structure where you are referring to the local
dedent project from
a sibling project e.g. called
flutter_proj1 like this:
┌─────────────────────┐ │Development Directory│ ├─────────────────────┘ │ │ ┌──────────────────┐ ├─▶│ flutter_proj1 │ │ └──────────────────┘ │ │ ┌──────────────────┐ └─▶│ dedent │ └──────────────────┘
- Official dedent pub.dev page.
- Source code repository https://github.com/abulka/flutter-dedent.
- Official Python documentation
(note, only the
Textwrap.dedentdocumentation is relevant since the whole Textwrap package has not been ported.)
- Original Python dedent source code
Thanks to the Python community for this algorithm.