How do I use hexadecimal color strings in Flutter?

Hexadecimal shading code otherwise called HEX shading code is one of the most well known shading strings. Hexadecimal is a 16 digit base number framework. In hexadecimal shading code tone characterizes in pair design. Each pair demonstrates Red, Green and Blue tone. So in this instructional exercise we would find out about How to utilize Hexadecimal HEX Color Code String in Flutter android iOS application to characterize foundation, text gadget tones.

Step by step instructions to characterize Hex shading code:

There is a fix design ripple offers us to characterize shading code in Hex arrangement. There is no compelling reason to utilize any kind of discussion. We would utilize the Color class to pass the hex tone in it. See the beneath model. We need to prefix 0xff at hex shading code. Here ff implies Opacity level to full. You can fine wonderful

Color(0xFF + Hex Color String)

or

Color(0xff + Hex Color String)

color: Color(0xFF42A5F5)

Substance in this venture How to utilize Hexadecimal HEX Color Code String in Flutter Android iOS application:

  1. Import material.dart bundle in your application’s main.dart record.
import 'package:flutter/material.dart';

2. Call our primary class MyApp utilizing runApp() work.

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

3. Making our principle class named as MyApp.

class MyApp extends StatelessWidget {

}

4. Make a Text gadget in Column gadget. We would set the Text shading utilizing Hex shading code.

Text('Hexadecimal Color Code', 
     style: TextStyle(fontSize : 28, color: Color(0xFF42A5F5))),

5.Complete source code for main.dart document:

import 'package:flutter/material.dart';
 
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            body: SafeArea(
                child: Center(
                  child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children:[

                   Text('Hexadecimal Color Code', 
                   style: TextStyle(fontSize : 28, color: Color(0xFF42A5F5))),

                  ],
                  )
                )
              )
            )
         );
  }
}

Screenshot:

How to use Hexadecimal HEX Color Code String in Flutter Dart

Leave a Comment