body method
Defines the actual body code. path
is passed relative to lib
, baseName
is the filename, and className
is the filename converted to Pascal case.
実際の本体コードを定義します。path
にlib
からの相対パス、baseName
にファイル名が渡され、className
にファイル名をパスカルケースに変換した値が渡されます。
Implementation
@override
String body(String baseName, String className) {
return """
`UniversalAppBar`は下記のように利用する。
## 概要
$excerpt
## 利用方法
```dart
UniversalAppBar(
leading: IconButton(
icon: const Icon(Icons.menu),
onPressed: () {
// TODO: Implement the menu action.
},
),
title: const Text("アプリタイトル"),
actions: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {
// TODO: Implement the settings action.
},
),
],
bottom: const PreferredSize(
preferredSize: Size.fromHeight(48),
child: TabBar(
tabs: [
Tab(text: "タブ1"),
Tab(text: "タブ2"),
],
),
),
);
```
## プロパティ
- `leading`: AppBarの左側に表示するウィジェットを設定する。
- `title`: AppBarのタイトルを設定する。
- `actions`: AppBarの右側に表示するウィジェットのリストを設定する。
- `bottom`: AppBarの下部に表示するウィジェットを設定する。
- `backgroundColor`: AppBarの背景色を設定する。
- `elevation`: AppBarの影の深さを設定する。
- `centerTitle`: タイトルを中央に配置するかどうかを設定する。
- `toolbarHeight`: AppBarの高さを設定する。
- `leadingWidth`: leadingウィジェットの幅を設定する。
- `automaticallyImplyLeading`: 自動的にleadingを追加するかどうかを設定する。
## 注意点
- `UniversalScaffold`と組み合わせて使用することで、自動的にSliverWidgetに変換される。
- デスクトップモードでは、`leading`と`actions`の配置が最適化される。
- モバイルモードでは、標準的なAppBarのレイアウトが適用される。
- `bottom`を設定する場合は、`PreferredSize`でラップする必要がある。
""";
}