github_colour 1.0.0 github_colour: ^1.0.0 copied to clipboard
Receive ozh's GitHub colour to Flutter's colour implementation with caching and fallback.
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 Color
object.
Usage #
You can either initalized GitHubColour
before runApp(Widget)
:
void main() async {
await GitHubColour.getInstance();
runApp(const YourApp());
}
then uses getExistedInstance()
inside the Widget
:
class YourAppWidget extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(backgroundColor: GitHubColour.getExistedInstance().find("Go"))
);
}
or wrapped into FutureBuilder
directly in State
's initState
(not recommended uses getInstance()
directly in FutureBuilder
):
class _YourAnotherAppWidgetState extends State<YourAnotherAppWidget> {
late final Future<GitHubColour> _ghc;
@override
void initState() {
super.initState();
_ghc = GitHubColour.getInstance();
}
@override
Widget build(BuildContext context) => FutureBuilder<GitHubColour>(
future: _ghc,
builder: (context, snapshot) {
// Implement whatever you want
}
);
}
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 as shared_preference
(for Web, which is LocalStorage
).
Note for American English developers #
It's provide alias class GitHubColor
for who uses "color" mostly.
Screenshots #
License #
BSD-3