Flutter Colors.fromRGBを使って色をRGBで指定するサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文
//red, green, blueには、「0~255」の値を指定
//opacityには、透明度を「0~ 1」で指定(0に近づくほど透明、1に近づくほど不透明)
Color.fromRGBO(red, green, blue, opacity)

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: Container(
width: 200,
height: 200,
color: Color.fromRGBO(50, 100, 34, 0.5),
),
),
),
);
}
@override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: Container( width: 200, height: 200, color: Color.fromRGBO(50, 100, 34, 0.5), ), ), ), ); }
@override
Widget build(BuildContext context) {
  return SafeArea(
    child: Scaffold(
      body: Center(
        child: Container(
          width: 200,
          height: 200,
          color: Color.fromRGBO(50, 100, 34, 0.5),
        ),
      ),
    ),
  );
}

 

IT

Posted by arkgame