MessageBox class
An informational message box widget with icon, label, and optional actions.
This widget creates a styled message container with an icon on the left, message content in the center, and optional action buttons on the right. Perfect for alerts, notifications, info boxes, warnings, and error messages.
Features:
- Icon + message + actions layout
- Customizable colors (main color and background)
- Default icon (Icons.info_outline) when not specified
- Automatic background color (10% opacity of main color)
- Optional action buttons
- Customizable border and border radius
- Adjustable padding and margin
Example:
MessageBox(
label: Text("This is an important message"),
icon: Icon(Icons.warning),
color: Colors.orange,
actions: [
TextButton(
onPressed: () {},
child: Text("Dismiss"),
),
],
)
メッセージを表示するためのボックス。
このウィジェットは、左側にアイコン、中央にメッセージコンテンツ、右側にオプションの アクションボタンを持つスタイル付きメッセージコンテナを作成します。 アラート、通知、情報ボックス、警告、エラーメッセージに最適です。
特徴:
- アイコン + メッセージ + アクションのレイアウト
- カスタマイズ可能な色(メインカラーと背景)
- 未指定時のデフォルトアイコン(Icons.info_outline)
- 自動背景色(メインカラーの10%不透明度)
- オプションのアクションボタン
- カスタマイズ可能なボーダーと角丸
- 調整可能なパディングとマージン
例:
MessageBox(
label: Text("これは重要なメッセージです"),
icon: Icon(Icons.warning),
color: Colors.orange,
actions: [
TextButton(
onPressed: () {},
child: Text("閉じる"),
),
],
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- MessageBox
Constructors
-
MessageBox({required Widget label, Key? key, Widget? icon, Widget? title, TextStyle? textStyle, Color? backgroundColor, BoxBorder? border, BorderRadiusGeometry? borderRadius, EdgeInsetsGeometry padding = const EdgeInsets.all(16), Color? color, EdgeInsetsGeometry? margin, List<
Widget> actions = const []}) -
An informational message box widget with icon, label, and optional actions.
const
Properties
-
actions
→ List<
Widget> -
List of message box actions.
final
- backgroundColor → Color?
-
Background color.
final
- border → BoxBorder?
-
Box borders.
final
- borderRadius → BorderRadiusGeometry?
-
Box rounded corners.
final
- color → Color?
-
Main color.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- icon → Widget?
-
A widget that can be placed in the icon section.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → Widget
-
A widget that can be placed in the message section.
final
- margin → EdgeInsetsGeometry?
-
Content Mergin.
final
- padding → EdgeInsetsGeometry
-
Content Padding.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- textStyle → TextStyle?
-
Message text style.
final
- title → Widget?
-
A widget that can be placed in the title section.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited