Skip to main content

How to use RGBA Color Code on Text in Flutter

RGBA color code makes with 4 different color properties Red, Green, Blue and Alpha. These values are starting from 0 to 255. Almost every known color can be make via these 4 code combinations. In flutter there are a inbuild Color function Color.fromARGB(A, R, G, B) in flutter to set use RGBA color code on text in flutter. We will be using this function in our code.

How to use RGBA Color Code on Text in Flutter:

1. Defining text widget with Color.fromARGB() function pass on Color.
Text(
        'ARGB Text Color',
        style: TextStyle(color: Color.fromARGB(255, 51, 105, 30)),
      )
2. Complete source code for main.dart file:
import 'package:flutter/material.dart';

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

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
          body: Center(
              child: Text(
        'ARGB Text Color',
        style: TextStyle(color: Color.fromARGB(255, 51, 105, 30)),
      ))),
    );
  }
}
Screenshot of App:
How to use RGBA Color Code on Text in Flutter

Comments