Find underused colors, overused magical numbers and the largest classes in any Flutter project.

Overview

Flutter Resource Ranker

It is easy to overuse colors, write magical numbers or long classes. This project has a script to help you detect these. This was inspired by a tweet from Emma Vanbrabant, where she ranked Android color resources. Seeing the usefulness, I decided replicating and expanding for Flutter. It can do the following:

GIF

What it can do

Detect color usage (either Color(...) or Color primary = ...):

  • See frequency of hardcoded colors. Consider using a variable for better maintainability and multi-theme support.
  • Detect colors used in few places. When Chrome was redesigned, the team discovered it had 95 shades of grey. They managed to reduce to 8. Material Design Theme supports 12 categories of color. Try to keep it simple(r).
  • See how detected colors contrast with black or white. It follows WACG recommendations and is useful to see if a heavily used color doesn't have enough contrast with black or white.

Detect class size (counts the number of ; inside each class):

  • Inspired by Detekt LongMethod. Useful to see who are the largest classes and if there is any that is an outlier (i.e. has many more lines of code than others).
  • In the future, this script could be configured for use in a CI system to fail/reject a commit or pull request that has a huge class.

Detect magical numbers (finds every number different than [-1,0,1,2] without a ; or , nearby):

  • Inspired by Detekt MagicNumber. Detect numbers that are not attributed to a variable or method call (as long as there is a , after the number). The script can be customised to be more or less strict.

Getting Started

The script was written in Kotlin and depends on JVM (for File access). If you need to install Kotlin for command line access, check here (brew install kotlin).

The script only scans .dart files.

USAGE:
$ ./resourceranker.kts <project directory> [OPTIONS]
$ kotlinc -script resourceranker.kts <project directory> [OPTIONS]

OPTIONS:
color       How many colors you are using and how many times
contrast    How many colors and how they compare to black and white
num         How many magical numbers you are using and how many times
class       How many lines each class has.
help        Show this text.
<int>       Max limit. If 0, shows all elements. Default is 10.

EXAMPLE:
$ ./resourceranker.kts documents/project color 10
$ ./resourceranker.kts ../ class 0
$ ./resourceranker.kts ../../ contrast 5
$ ./resourceranker.kts ./ num
$ ./resourceranker.kts desktop class color 0

GIF

Issue Tracking

Found a bug? Have an idea for an improvement? Would you like to add to CI or convert to other language? Feel free to add an issue.

License

Copyright 2020 Bernardo Ferrari.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You might also like...

Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps

Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps

Leverages libphonenumber to allow for asynchronous and synchronous formatting of phone numbers in Flutter apps. Includes a TextInputFormatter to allow real-time AsYouType formatting.

Nov 2, 2022

Numbers is simple game to improve problem solving skills and it is built in Flutter Framework

Numbers is simple game to improve problem solving skills and it is built in Flutter Framework

Numbers - Flutter Game Numbers is a simple game built in Flutter Framework and is purely based on numbers to improve problem solving skills. Screensho

Oct 21, 2022

A Mobile application developed with Flutter and Dart to do math operations with binary numbers.

A Mobile application developed with Flutter and Dart to do math operations with binary numbers.

Math operations with Binary Numbers Readme PT About this Project Mobile application developed with Flutter and Dart to do math operations as sum, subt

Nov 3, 2020

This is a dart package that converts words to numbers. It can be used in Flutter and normal Dart programs

Wordstonumbers.dart Wordstonumbers.dart is a simple dart package that converts a string of simple worded numbers into digits (e.g one hundred - 100).

Oct 17, 2022

A library for parsing and encoding IEEE-754 binary floating point numbers.

Dart IEEE754 library This library provides decoding and transforming IEEE754 floating point numbers in binary format, double format, or as exponent an

Dec 24, 2021

Attendancelist - App to add Students attendance based on roll numbers and calculate percentage.

attedance A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Jan 1, 2022

Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

Oct 2, 2022

Awesome Flutter Snippets is a collection snippets and shortcuts for commonly used Flutter functions and classes

Awesome Flutter Snippets Awesome Flutter Snippets is a collection of commonly used Flutter classes and methods. It increases your speed of development

Dec 9, 2022

A dart implementation of fixed precision numbers.

The Fixed package allows you to store and perform maths on numbers with a fixed scale (fixed no. of decimal places). All amounts are store as integers

Jun 4, 2022
Comments
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 37% 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /contrast.png | 112.96kb | 68.30kb | 39.54% | | /screenshot.png | 361.28kb | 228.14kb | 36.85% | | | | | | | Total : | 474.24kb | 296.44kb | 37.49% |


    📝docs | :octocat: repo | 🙋issues | 🏅swag | 🏪marketplace

    opened by imgbot[bot] 0
Owner
Bernardo Ferrari
Android native and Flutter developer. Computer Scientist.
Bernardo Ferrari
Color-Converter - A minimalist application made with flutter to convert hexadecimal colors to RGB colors and vise-versa.

Color Converter A minimalist application made with flutter to convert hexadecimal colors to RGB colors and vise-versa for Flutter Create Competition.

Poojan Pandya 2 Sep 16, 2020
Receiving ozh's github-colors repository with latest commit of colors.json to Flutter's Color object.

Apply GitHub's languages colours into Flutter's Color object. Receiving ozh's github-colors repository with latest commit of colors.json to Flutter's

Cyrus Chan 1 Jun 6, 2022
Find The Latest trending and upcoming movies and tv shows with MovieDB app. The app contains all info about movies and tv shows. find similar movies or shows, Browse all genres, video trailers, backdrops, logos, and posters.

MovieDB App Features. Dynamic Theming Search Functionality Onboarding-Screen Select favourite movie Home Screen Tranding movie Movies different catego

Ansh rathod 80 Dec 12, 2022
A JSON serialize class to convert 'to' and 'from' JSON format Enums, DateTime and any of your own classes.

A JSON serialize class to convert 'to' and 'from' JSON format Enums, DateTime and any of your own classes. Introduction Jsonize solves the problem of

null 2 Nov 17, 2022
Find-Kosan-Cimahi - Find Kosan Cimahi App With Flutter

Find Kosan Cimahi Masih Tahap Belajar Dart This project is a starting point for

null 1 Feb 17, 2022
In this repo you'll find how to responsive any screen whether it's for mobile, tablet and desktop

This repo is all about responsiveness of screen using flutter: By cloning and giving this repo a star you can get the concept of responsiveness of screen whether the screen is for mobile, tablet and desktop.

null 3 Aug 29, 2022
A weather app that allows the user to find out the live weather data of any city.

Clima ☁ My Goal My objective of completing this project was to learn about asynchronous programming in Dart, how to carry out time consuming tasks suc

Ginny (Khue) Dang 1 May 6, 2022
DoItEverywhere fitnessApp - DIE - A project created in flutter for the needs of classes

DIE - DoItEverywhere DIE is a project created in flutter for the needs of classe

Grzegorz Kucharski 0 Jan 31, 2022
Flutter project to find and discover events with Clean Architecture and Bloc from SeatGeek API.

Flutter project to find and discover events with Clean Architecture and Bloc from SeatGeek API.

Abel Dagnew 3 Dec 6, 2022