# 토스트 (Toast)

## 토스트 정보메시지 (info)

<figure><img src="/files/C1omUMd0pDtr8LHJUqG6" alt=""><figcaption></figcaption></figure>

텍스트로 구성된 가장 간단한 형태의 Toast 메시지로, 이를 사용하여 앱 내에서 간단한 정보를 사용자에게 전달할 수 있습니다.

```dart
flutterToast.info(message: '오늘 날씨는 흐림입니다.\n내일은 눈이 온다고 하네요.'); 
```

위 코드처럼 ***`flutterToast.info()`*** 함수를 호출하여 텍스트 메시지를 화면에 나타냅니다.

## 토스트 오류메시지 (error)

<figure><img src="/files/gFVhUGrUPwkUiBI1unCt" alt=""><figcaption></figcaption></figure>

앱 내에서 오류나 경고 메시지를 사용자에게 전달해야 할 때, 토스트 오류메시지를 사용할 수 있습니다.

```dart
flutterToast.error(message: '처리 중입니다.\n잠시 후 다시 시도해주세요.');
```

위 코드처럼 ***`flutterToast.error()`*** 함수를 호출하여 오류 메시지를 표시합니다.

## 토스트 상세보기 (detail)

<figure><img src="/files/sXH251ooRjfc9QSpVLCP" alt=""><figcaption></figcaption></figure>

더 많은 정보를 제공하거나 사용자를 다른 화면으로 이동시킬 때, 토스트 상세보기를 사용할 수 있습니다. 이 메시지에는 사용자 액션에 대한 응답을 포함할 수 있습니다.

```dart
flutterToast.detail(
      message: '이체가 완료되었습니다.\n상세보기 선택 시 페이지로 이동합니다.',
      action: '바로가기',
      toastDuration: Duration(milliseconds: 2000),
      gravity: ToastGravity.TOP,
      onPressed: () {
        // 사용자가 '바로가기'를 클릭하면 지정된 작업을 수행합니다.
        NetworkUtil.launchURL("https://flutter.dev");
      },
    );
```

위 코드처럼 ***`flutterToast.detail()`*** 함수를 호출하여 토스트 상세보기를 나타냅니다. 사용자가 '**바로가기**' 버튼을 누르면 해당 웹 페이지로 이동합니다.

## 토스트 닫기메시지 (close)

<figure><img src="/files/IulPVbQyBjKvTHDpLlXP" alt=""><figcaption></figcaption></figure>

앱에서 잠시 동안 사용자에게 메시지를 표시하고, 자동으로 닫히도록 하려면 토스트 닫기메시지를 사용할 수 있습니다. 이 메시지는 지정된 시간이 지나면 자동으로 사라집니다.

```dart
flutterToast.close(
      message: '처리 중입니다.\n잠시 후 다시 시도해주세요.',
      toastDuration: Duration(milliseconds: 2000),
      onDismissed: () {
        // 메시지가 닫힐 때 수행할 작업을 정의합니다.
        flutterToast.removeCustomToast();
      },
    );
```

위 코드처럼 ***`flutterToast.close()`*** 함수를 호출하면, 메시지를 표시하고 지정된 시간이 지나면 토스트 메시지가 자동으로 닫힙니다.

Flutter의 Toast 위젯을 사용하면 사용자에게 다양한 메시지와 정보를 전달할 수 있습니다. 이러한 간편하고 시각적으로 효과적인 메시지 전달 방식을 통해 사용자 경험을 개선하고 앱의 유용성을 향상시킬 수 있습니다.&#x20;

위에서 설명한 내용을 참고하여 Flutter 앱에서 Toast 위젯을 사용하여 다양한 메시지를 표시하는 방법을 익혀보세요. Toast 메시지는 사용자와의 상호작용을 향상시키고 중요한 정보를 전달하는 데 유용한 도구입니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.aliothx.net/start/uiux/ui-ux/toast.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
