https://github.com/rk0cc/github_colour_flutter
Receiving ozh's github-colors repository with latest commit of colors.json to Flutter's Color object.
https://github.com/rk0cc/github_colour_flutter
color colors colour colours dart flutter github github-colors github-colours package programming-language pub
Last synced: 27 days ago
JSON representation
Receiving ozh's github-colors repository with latest commit of colors.json to Flutter's Color object.
- Host: GitHub
- URL: https://github.com/rk0cc/github_colour_flutter
- Owner: rk0cc
- License: bsd-3-clause
- Created: 2022-05-04T11:34:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-30T07:51:16.000Z (over 1 year ago)
- Last Synced: 2025-01-17T01:08:50.563Z (about 1 year ago)
- Topics: color, colors, colour, colours, dart, flutter, github, github-colors, github-colours, package, programming-language, pub
- Language: C++
- Homepage: https://pub.dev/packages/github_colour
- Size: 21.4 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Apply GitHub's languages colours into Flutter's `Color` object.

[](https://github.com/sponsors/rk0cc)
Receiving [ozh's github-colors](https://github.com/ozh/github-colors) repository with latest commit of [`colors.json`](https://github.com/ozh/github-colors/blob/master/colors.json) to Flutter's `Color` object.
It also provide [web demo](https://osp.rk0cc.xyz/github_colour_flutter/) for the demo.
## Usage
You can either initalized `GitHubColour` before `runApp(Widget)` (Call it after `WidgetsFlutterBinding.ensureInitialized()` if want to get data from offline):
```dart
// With offline last resort
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await GitHubColour.initialize();
runApp(const YourApp());
}
// Without offline last resort
void main() async {
await GitHubColour.initialize(offlineLastResort: false);
runApp(const YourApp());
}
```
then uses `getExistedInstance()` inside the `Widget`:
```dart
class YourAppWidget extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
backgroundColor: GitHubColour.getExistedInstance()["Go"]
)
);
}
```
## Cache for connection failed
This package supported caching system as a backup when making request failed. It uses LZMA compress data and store as a file under temporary directory (for VM) or store under `sembast_web` (based on IndexedDB, `3.1.0` or before was using `shared_preference`).
If no cache available, when executing `GitHubColour.initialize()`, it will uses [local's `colors.json`](lib/colors.json) as last resort. However, this package will not synchronized when newer commit of `color.json` pushed since it minified that ensure the package can be downloaded as fast as possible.
## Note for American English developers
It's provide alias class `GitHubColor` for who uses "color" mostly.
## Screenshots





## License
BSD-3