世界最大級のオンライン学習サービス「Udemy」のセール状況はこちら

【Flutter】AppBarの背景色を変更する

こんにちは、フラメルです。

今回はAppBarの背景色を変更する方法を紹介します。

目次

対処法

背景色変更後
背景色変更前

AppBarの背景色を変更するにはbackgroundColorを使用します。

下記コードではbackgroundColorColorsを使用して色を変更しています。

AppBar(
  title: Text('Flutter'),
  backgroundColor: Colors.purpleAccent,
),

サンプルコード

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter'),
          backgroundColor: Colors.purpleAccent,
        ),
      ),
    );
  }
}

以上です。

目次