31.80 Flutter Style Pubspec

20241118

We often end up listing many packages within the pubspec file so it is useful keeping some track of why a package is included as a dependency. To support this I recommend adding a comment for each dependency on the same line (so we can keep the packages sorted alphabetically). Align the beginning of the comments in the file to have a tabular look and avoid the otherwise cluttered look.

Encouraged

dependencies:
  flutter:
    sdk: flutter

  desktop_drop: ^0.4.4       # Drag and drop file functionality.
  file_picker: ^8.0.0+1      # Choosing a file from local storage.
  intl: ^0.19.0              # Formatting timestamps.
  markdown_tooltip: ^0.0.2   # Allow tool tips to be formatted.
  mime: ^1.0.5               # Detect input file type.
  package_info_plus: ^5.0.1  # Query the version number of the app.
  window_manager:  ^0.4.3    # Set the size of the desktop app window.

Discouraged

dependencies:
  flutter:
    sdk: flutter

  desktop_drop: ^0.4.4 # Drag and drop file functionality.
  file_picker: ^8.0.0+1 # Choosing a file from local storage.
  intl: ^0.19.0 # Formatting timestamps.
  markdown_tooltip: ^0.0.2 # Allow tool tips to be formatted.
  mime: ^1.0.5 # Detect input file type.
  package_info_plus: ^5.0.1 # Query the version number of the app.
  window_manager:  ^0.4.3 # Set the size of the desktop app window.

Another improvement might be to line up the version numbers so we get a very tabular style that is easier to read.



Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0