pagination_flutter 0.0.1
pagination_flutter: ^0.0.1 copied to clipboard
A modular pagination component for flutter
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:pagination_flutter/pagination.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int selectedPage = 1;
setSelectedPage(int index) {
setState(() {
selectedPage = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Flutter Pagination"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Pagination(
numOfPages: 10,
selectedPage: selectedPage,
pagesVisible: 3,
onPageChanged: (page) {
setState(() {
selectedPage = page;
});
},
nextIcon: const Icon(
Icons.arrow_forward_ios,
color: Colors.blue,
size: 14,
),
previousIcon: const Icon(
Icons.arrow_back_ios,
color: Colors.blue,
size: 14,
),
activeTextStyle: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w700,
),
activeBtnStyle: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.blue),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(38),
),
),
),
inactiveBtnStyle: ButtonStyle(
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(38),
)),
),
inactiveTextStyle: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
),
),
],
),
),
);
}
}