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 """
# Label
## 概要
$excerpt
## 特徴
- テキストとアイコンの組み合わせが可能
- カスタマイズ可能な背景色とスタイリング
- アクションボタンの追加が可能
- 柔軟なパディングとアライメントの設定
- テーマに基づいたデフォルトスタイリング
## 基本的な使い方
### シンプルなラベル
```dart
Label(
"シンプルなラベル",
);
```
### アイコン付きラベル
```dart
Label(
"アイコン付きラベル",
leading: Icon(Icons.label),
);
```
### スタイル付きラベル
```dart
Label(
"スタイル付きラベル",
backgroundColor: Colors.blue.withOpacity(0.1),
color: Colors.blue,
padding: const EdgeInsets.all(8),
);
```
## カスタマイズ例
### アクション付きラベル
```dart
Label(
"アクション付きラベル",
leading: Icon(Icons.label),
actions: [
IconButton(
icon: Icon(Icons.edit),
onPressed: () {
// 編集アクション
},
),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {
// 削除アクション
},
),
],
);
```
### カスタムデコレーション
```dart
Label(
"カスタムデコレーション",
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey),
),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
);
```
### カスタムテキストスタイル
```dart
Label(
"カスタムテキストスタイル",
textStyle: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.indigo,
),
);
```
## 注意点
- `text`は必須パラメータ
- デフォルトのテキストスタイルは`Theme.of(context).textTheme.titleMedium`をベースに太字で設定
- `actions`を追加すると、アクション間に自動的に8.0のパディングが追加される
- `leading`(アイコン)とテキストの間のデフォルトスペースは16.0
- テキストの色とアイコンの色は`color`パラメータで統一的に設定可能
""";
}