flutter theme color hex code example

Example 1: how to use hexadecimal color in flutter

Color myColor = Color(0xff123456) 

// where 123456 is your hex color code and
// 0xff is the opacity value and can be changed.

Example 2: color() in flutter

// Color() widget can be used in the following way:
//where 123456 is the hex color code without the '#'


Color myHexColor = Color(0xff123456)

Example 3: how to change background color in flutter theme

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        canvasColor: Colors.green,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('Changing background color using theme'),
        ),
        body: Container(
        	child: Center(
            	child: Text('Some widget goes here.')
            )
        ),
      ),
    );
  }
}

Example 4: how to give shade to the colors in flutter

ThemeData(primarySwatch: Colors.lime.shade700),

Tags:

Misc Example