v3.1.0snapping_page_scroll
스크롤 속도에 따라 지정된 수의 페이지를 스크롤한 후 가장 가까운 페이지로 스냅하는 PageView를 만들 수 있는 플러그인입니다.
33좋아요 6130일 다운로드160Pub 점수
AndroidiOSWebmacOSWindowsLinux
스냅 기능이 있는 스크롤 가능한 PageView
{"sdk":"flutter"}^1.0.4{"sdk":"flutter"}아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A plugin that acts similar to a PageView but either snaps to the closest page or scrolls multiple pages and then snaps, based on how fast the user scrolls.
If the user scrolls faster than a certain threshold, page snapping will be disabled until friction slows the velocity to below that threshold, leading to page snapping being enabled again.
If the user scrolls slower than the threshold, the widget will act like a regular PageView with pageSnapping: true.
To use this plugin, add snapping_page_scroll as a dependency in your pubspec.yaml file.
import 'package:flutter/material.dart';
import 'package:snapping_page_scroll/snapping_page_scroll.dart';
void main() => runApp(App());
class App extends StatelessWidget {
Widget customCard(String text) {
return Padding(
padding: const EdgeInsets.fromLTRB(20, 100, 20, 100),
child: Card(
child: Text(text),
),
);
}
final controller = PageController(
viewportFraction: 0.75,
);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.amber,
appBar: AppBar(),
body: SnappingPageScroll(
controller: controller,
children: <Widget>[
customCard('Card 1'),
customCard('Card 2'),
customCard('Card 3'),
customCard('Card 4'),
customCard('Card 5'),
customCard('Card 6'),
],
),
),
);
}
}