FLUTTER ECOSYSTEM

bataa07/animated_toast_list

이 패키지를 사용하는 사람은 더 자유로운 느낌을 받을 것입니다. 이 패키지가 일반적이기 때문에 원하는 토스트를 만들 수 있습니다.

animated_toast_list 프로젝트 이미지
Stars
3
Forks
2
최근 푸시(UTC)
2024. 3. 17.
프로젝트 상태
활성
Bat-Erdene GitHub avatar
GITHUB User

Bat-Erdene ↗

Developer of @unimedia

Unimedia Solutions LLCUlaanbaatar, Mongolia공식 웹사이트 ↗
언어C++CMakeDartHTMLSwiftCKotlinObjective-C

기술 주제

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Introduction

When using Flutter, did you ever want to show toast with the design you want? Also, did you want to list the toast and show it with the desired animation? Then you have found what you are looking for! This package is generic, so there will be no problem with your toast. This package supports all platforms.

Usage

To use this package, wrap any widget with ToastListOverlay, as in the example below. For more details, see the example.

Widget build(BuildContext context) {
    return ToastListOverlay<MyToastModel>(
      itemBuilder: (BuildContext context, MyToastModel item, int index,
          Animation<double> animation) {
        return ToastItem(
          animation: animation,
          item: item,
          onTap: () => context.hideToast(
              item,
              (context, animation) =>
                  _buildItem(context, item, index, animation)),
        );
      },
      child: MaterialApp(
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const MainScreen(),
        debugShowCheckedModeBanner: false,
      ),
    );
  }
Property Default value Description
child Required Widget Wrapped widget
position Alignment.topCenter Specifies where toast to be displayed.
reverse false Reverse the Toast list.
limit 5 Specify how much toast to display.
itemBuilder Required ToastListItemBuilder The Toast widget is defined here.
width 375 Specifies the width of the toast.
timeoutDuration 5 seconds Specifies how long toast will be displayed.

Now you can call the context.showToast method to display your toast. You can see more details in the example.

  context.showToast(MyToastModel(ToastType.success.name, ToastType.success));

Note: MyToastModel is an example model.

To close the Toast, call the context.hideToast method.

context.hideToast(
  item,
  (context, animation) => ToastItem(
    animation: animation,
    item: item,
  ),
);

Live demo

Example

The figure below shows when the toast exceeds the limit.
2022-06-11_01-25-41_AdobeExpress

The figure below shows how to remove the toast by clicking the close button.
2022-06-11_01-25-41_AdobeExpress (1)

In the figure below, you can see the toast without any problems even if you navigate to another screen.
2022-06-11_01-25-41_AdobeExpress (2)

The figure below shows the toast list reversed.
2022-06-11_01-39-18_AdobeExpress