패키지, 저장소 및 앱 카테고리 검색

story 표지
패키지 상세v1.1.0

story

인스타그램 스토리와 유사한 UI로 풍부한 애니메이션과 사용자 정의 기능을 제공합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
9.4천
좋아요
348
Pub 점수
150

패키지 설치

flutter pub add story

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

이 스토리 패키지는 부드러운 애니메이션과 높은 사용자 정의 가능성을 갖춘 인스타그램 스토리와 유사한 UI를 제공합니다. 개발자가 사용자 정의 가능한 전환 효과, 타이머 및 콘텐츠 레이아웃을 갖춘 상호작용형 스와이프 가능한 스토리 카드를 만들 수 있도록 합니다. 동적 스토리텔링 경험을 필요로 하는 앱에 적합하며 모바일, 웹, 데스크톱 등 다양한 플랫폼을 지원합니다. 이 패키지는 플러터 위젯 시스템과의 간편한 통합을 위해 설계되었으며 외관과 동작 모두에 대해 광범위한 스타일링 옵션을 제공합니다.

사용 사례

  • 소셜 미디어 스타일의 스토리 피드 만들기
  • 인터랙티브 튜토리얼 또는 온보딩 흐름 구축
  • 제한된 시간 동안의 콘텐츠 업데이트 표시
  • 매력적인 마케팅 캠페인 기획
  • 사용자 프로필 스토리 하이라이트 구현

주요 기능

  • 풍부하고 애니메이션된 스토리 전환
  • 사용자 정의 가능한 스토리 카드 레이아웃
  • 다중 플랫폼에서의 스와이프 제스처 지원
  • 사용자 지정 가능한 기간 및 진행률 표시기
  • 확장 가능한 테마 및 스타일 옵션

적합한 대상

  • 소셜 기능을 구축하는 개발자
  • 시간 제한된 콘텐츠 전달이 필요한 앱
  • 애니메이션 UI 컴포넌트를 찾는 디자이너
  • 스토리처럼 생긴 인터페이스를 갖춘 크로스 플랫폼 애플리케이션

고려 사항

  • 이동 중 상태를 신중하게 다뤄야 합니다
  • 큰 스토리 세트와 함께 성능에 영향을 줄 수 있습니다
  • 제한된 내장 분석 또는 추적
  • 매우 긴 이야기에 최적화되지 않음
  • 고급 효과를 위해 외부 애니메이션 라이브러리에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

version likes popularity License: MIT all contributors

Instagram stories like UI with rich animations and customizability.

final 2

Usage

StoryPageView requires at least three arguments: itemBuilder, pageLength, and storyLength.

/// Minimum example to explain the usage.
return Scaffold(
  body: StoryPageView(
    itemBuilder: (context, pageIndex, storyIndex) {
      return Center(
        child: Text("Index of PageView: $pageIndex Index of story on each page: $storyIndex"),
      );
    },
    storyLength: (pageIndex) {
      return 3;
    },
    pageLength: 4,
  );
  • itemBuilder builds the content of each story and is called with the index of the pageView and the index of the story on the page.

  • storyLength decides the length of story for each page. The example above always returns 3, but it should depend on pageIndex.

  • pageLength is just the length of StoryPageView

The example above just shows 12 stories by 4 pages, which is not practical.

This one is the proper usage, extracted from example.

return Scaffold(
  body: StoryPageView(
    itemBuilder: (context, pageIndex, storyIndex) {
      final user = sampleUsers[pageIndex];
      final story = user.stories[storyIndex];
      return Stack(
        children: [
          Positioned.fill(
            child: Container(color: Colors.black),
          ),
          Positioned.fill(
            child: Image.network(
              story.imageUrl,
              fit: BoxFit.cover,
            ),
          ),
          Padding(
            padding: const EdgeInsets.only(top: 44, left: 8),
            child: Row(
              children: [
                Container(
                  height: 32,
                  width: 32,
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: NetworkImage(user.imageUrl),
                      fit: BoxFit.cover,
                    ),
                    shape: BoxShape.circle,
                  ),
                ),
                const SizedBox(
                  width: 8,
                ),
                Text(
                  user.userName,
                  style: TextStyle(
                    fontSize: 17,
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
        ],
      );
    },
    gestureItemBuilder: (context, pageIndex, storyIndex) {
      return Align(
        alignment: Alignment.topRight,
        child: Padding(
          padding: const EdgeInsets.only(top: 32),
          child: IconButton(
            padding: EdgeInsets.zero,
            color: Colors.white,
            icon: Icon(Icons.close),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
        ),
      );
    },
    pageLength: sampleUsers.length,
    storyLength: (int pageIndex) {
      return sampleUsers[pageIndex].stories.length;
    },
    onPageLimitReached: () {
      Navigator.pop(context);
    },
  ),
);
  • gestureItemBuilder builds widgets that need gesture actions

In this case, IconButton to close the page is in the callback.

You CANNOT place the gesture widgets in itemBuilder as they are covered and disabled by the default story gestures.

  • onPageLimitReached is called when the very last story is finished.

  • It is recommended to use data model with two layers. In this case, UserModel which has the list of StoryModel

/// Example Data Model
class UserModel {
  UserModel(this.stories, this.userName, this.imageUrl);

  final List<StoryModel> stories;
  final String userName;
  final String imageUrl;
}

class StoryModel {
  StoryModel(this.imageUrl);

  final String imageUrl;
}
StoryImage

If you show images in StoryPageView, use StoryImage. It can stop the indicator until the image is fully loaded.

StoryImage(
  /// key is required
  key: ValueKey(story.imageUrl),
  imageProvider: NetworkImage(
    story.imageUrl,
  ),
  fit: BoxFit.fitWidth,
)

Be sure to assign the unique key value for each image, otherwise the image loading will not be handled properly.

indicatorAnimationController

If you stop/start the animation of the story with your custom widgets, use indicatorAnimationController

class _StoryPageState extends State<StoryPage> {
  late ValueNotifier<IndicatorAnimationCommand> indicatorAnimationController;

  @override
  void initState() {
    super.initState();
    indicatorAnimationController = ValueNotifier<IndicatorAnimationCommand>(
        IndicatorAnimationCommand.resume);
  }

  @override
  void dispose() {
    indicatorAnimationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StoryPageView(
        indicatorAnimationController: indicatorAnimationController,
        ...,
      ),
    );
  }
}

Once the instance is passed to StoryPageView, you can stop handle the indicator by the methods below.


/// To pause the indicator
indicatorAnimationController.value = IndicatorAnimationCommand.pause;

/// To resume the indicator
indicatorAnimationController.value = IndicatorAnimationCommand.resume;

Contributors

Santa Takahashi
Santa Takahashi

💻
Isaias Mejia de los Santos
Isaias Mejia de los Santos

💻
Медик
Медик

💻
Alperen Soysal
Alperen Soysal

💻
AtixD
AtixD

💻
harshitFinmapp
harshitFinmapp

💻
dmitry-kotorov
dmitry-kotorov

💻
sachin kumar rajput
sachin kumar rajput

💻
Mohamed Othman
Mohamed Othman

💻

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트