zoom_view 0.0.1 zoom_view: ^0.0.1 copied to clipboard
Widget that allows both zooming and scrolling a `ListView` or other `Scrollable`s
Widget that allows both zooming and scrolling a ListView
or other Scrollable
s
Features #
Scroll a ListView while it is zoomed in with fling velocity
Usage #
Using ListView #
import 'package:zoom_view/zoom_view.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
ScrollController controller = ScrollController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: ZoomListView(
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
controller: controller,
itemCount: 10000,
itemBuilder: (context, index) {
return Center(
child: Text("text $index")
);
}
),
),
)
);
}
}
note that the controller
argument most be set, and the the physics must be set to NeverScrollableScrollPhysics
Using some other scrolling list #
class ZoomViewExample extends StatefulWidget {
const ZoomViewExample({super.key});
@override
State<ZoomViewExample> createState() => _ZoomViewExampleState();
}
class _ZoomViewExampleState extends State<ZoomViewExample> {
ScrollController controller = ScrollController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: ZoomView(
controller: controller,
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
controller: controller,
itemCount: 10000,
itemBuilder: (context, index) {
return Center(
child: Text("text $index")
);
}
),
),
)
);
}
}
Note that here the controller is given both to the ZoomView and the list. Other Scrollables that use ScrollController should work as well. Make sure that NeverScrollableScrollPhysics ot some equivalent is set