0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

設定画面をできるだけ楽に綺麗に作る方法(settings_ui)

Posted at

settings_ui_cover.png

こんにちわ。いせきです。アプリを作るのってよくないですか?と思っている今日この頃。作りながらワクワクする気持ちは好きなものを作っているみたいでとてもいいですね。

さあ今回は、設定画面をめっちゃ楽に作れる方法をご紹介します。
まずは、そのために使用するPackageをご紹介します。

# 使用するPackage
インストール方法は以下を参考にしてください(今回は割愛します。)

サンプルコード


import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:settings_ui/settings_ui.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const SettingScreen(),
    );
  }
}

class SettingScreen extends StatelessWidget {
  const SettingScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF2F2F7),
      appBar: AppBar(),
      body: SettingsList(
        lightTheme: const SettingsThemeData(
          settingsListBackground: Color(0xFFF2F2F7),
          settingsSectionBackground: Colors.white,
        ),
        sections: [
          SettingsSection(
            tiles: [
              SettingsTile.navigation(
                leading: const Icon(
                  Icons.star,
                  color: Colors.yellow,
                ),
                title: const Text('設定1'),
                onPressed: (context) {},
              ),
              SettingsTile.navigation(
                leading: const Icon(
                  Icons.mail,
                  color: Colors.lightBlue,
                ),
                title: const Text('設定2'),
                onPressed: (context) {},
              ),
              SettingsTile.navigation(
                leading: const Icon(
                  AntDesign.twitter,
                  color: Colors.blue,
                ),
                title: const Text('設定3'),
                onPressed: (context) {},
              ),
              SettingsTile.navigation(
                leading: const Icon(
                  Icons.local_police,
                  color: Colors.grey,
                ),
                title: const Text('設定4'),
                onPressed: (context) {},
              ),
              SettingsTile.navigation(
                leading: const Icon(
                  MaterialCommunityIcons.github,
                  color: Colors.black,
                ),
                title: const Text('設定5'),
                onPressed: (context) {},
              ),
              SettingsTile.navigation(
                leading: const Icon(
                  AntDesign.sharealt,
                  color: Colors.black,
                ),
                title: const Text('設定6'),
                onPressed: (context) {},
              ),
            ],
          ),
        ],
      ),
    );
  }
}


参考のアプリのUI

最後に

このPackageはとても簡単に、設定画面が作れるのでとてもいいですね!!
本来は自分で作った方が良さそうですが、軽いアプリや一旦骨組みを作りたいと思う方にはとてもおすすめだと思います!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?