Flutter Color()を使って色をRGBで指定するサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文
Color(0xffffffff)
Colorの引数にRGBを16進数で指定します。
RGBは、赤、緑、青、透明度(0〜100%)の順で指定します。

使用例

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: 150,
height: 150,
color: Color(0xff2980b9),
),
),
),
);
}
@override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: Container( width: 150, height: 150, color: Color(0xff2980b9), ), ), ), ); }
@override
Widget build(BuildContext context) {
  return SafeArea(
    child: Scaffold(
      body: Center(
        child: Container(
          width: 150,
          height: 150,
          color: Color(0xff2980b9),
        ),
      ),
    ),
  );
}

 

IT

Posted by arkgame