Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created December 7, 2023 14:45
Show Gist options
  • Save prof3ssorSt3v3/375281bdfd1da8918f0da70d428362fb to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/375281bdfd1da8918f0da70d428362fb to your computer and use it in GitHub Desktop.
ColorScheme reference for Flutter
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: const ColorScheme(
primary: Colors.blueGrey, //FAB, CircleAvatar, button text,
//ripple effect, TextField label
onPrimary: Colors.white, //fab icon, circleavatar txt/icon
secondary: Colors.lime, //active link in nav bar
onSecondary: Colors.pink, //active icon in nav bar
tertiary: Colors.pink, //up to dev to use
onTertiary: Colors.white, //up to dev to use
surface: Colors.amber, //navigationBar, appBar, button, card
onSurface: Colors.green, //treat like default text and icon color
background: Colors.yellow, //MaterialApp background
onBackground: Colors.white, //text on MaterialApp
brightness: Brightness.light,
surfaceTint: Colors.deepOrange,
error: Colors.blue, //all text for textfield if error
onError: Colors.purple,
),
),
home: Scaffold(
appBar: AppBar(title: const Text('AppBar')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
const Text('Text in Column'),
const ListTile(title: Text('ListTile')),
const Card(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text('Card'),
)),
ElevatedButton(child: const Text('ElevatedButton'), onPressed: () {}),
const CircleAvatar(child: Text('CA')),
TextField(
decoration: InputDecoration(
labelText: 'Input Label',
errorText: 'Bad things happened',
),
autofocus: true,
)
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.edit),
),
bottomNavigationBar: NavigationBar(
destinations: [
const NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
const NavigationDestination(icon: Icon(Icons.gavel), label: 'Other'),
],
selectedIndex: 0,
onDestinationSelected: (int index) {
//nav
},
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment