colours 0.0.2 colours: ^0.0.2 copied to clipboard
An extended version of Flutter Colors with more swatches and more flexibility to generate your own custom swatch.
import 'package:colours/colours.dart';
import 'package:flutter/material.dart';
MaterialColor gojekSwatch = Colours.swatch('00aa13');
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Colours Demo',
theme: ThemeData(
// This is the theme of your application.
// Apply colors from gojekSwatch
primarySwatch: gojekSwatch,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Colours.swatch Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
style: TextStyle(
color: gojekSwatch[700], // use color from gojekSwatch
),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
backgroundColor: gojekSwatch[900], // use color from gojekSwatch
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}