I tried to use two packages carousel_indicator and flutter_onboarding_slider. But my issue is I need to implement indicator like in the image. The selected indicator is a bit big in width. Could anyone help with this?
3
To show indicators you will have to use another package.
Something like smooth_page_indicator
You can use any of the following packages:
Add in your pubspec.yaml File and import. You follow the guide for the usage.
You can rely on a 3rd party package such as smooth_page_indicator which was mentionned.
Based on the screenshot you’ve provided I’d say that the ExpandingDotsEffect is what you’re looking for.
ExpandingDotsEffect
class PageIndicator extends StatelessWidget { const PageIndicator({ super.key, required this.length, required this.controller, }); final int length; final PageController controller; @override Widget build(BuildContext context) { return SmoothPageIndicator( controller: controller, count: length, effect: const ExpandingDotsEffect( // Note that you'll have to change the following properties to match // your design. activeDotColor: Colors.orange, dotColor: Colors.blue, dotHeight: 8, dotWidth: 10, expansionFactor: 3, ), ); } }
import 'package:flutter/material.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; class OnboardingPage extends StatefulWidget { const OnboardingPage({super.key}); @override State<OnboardingPage> createState() => _OnboardingPageState(); } class _OnboardingPageState extends State<OnboardingPage> { final pageController = PageController(); @override void dispose() { pageController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final pages = List<Widget>.generate( 3, (index) { return CarouselTile( title: 'Title $index', subtitle: 'Subtitle $index', ); }, ); return Scaffold( backgroundColor: Colors.grey, body: Center( child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Carousel( controller: pageController, pages: pages, ), PageIndicator( length: pages.length, controller: pageController, ), ], ), ), ); } } class Carousel extends StatelessWidget { const Carousel({ super.key, required this.controller, required this.pages, }); final PageController controller; final List<Widget> pages; @override Widget build(BuildContext context) { return SizedBox( height: 200, child: PageView( controller: controller, children: pages, ), ); } } class CarouselTile extends StatelessWidget { const CarouselTile({ super.key, required this.title, required this.subtitle, }); final String title; final String subtitle; @override Widget build(BuildContext context) { return Column( children: [ Text( title, style: Theme.of(context).textTheme.headline5, ), const SizedBox(height: 16), Text( subtitle, style: Theme.of(context).textTheme.subtitle1, ), ], ); } } class PageIndicator extends StatelessWidget { const PageIndicator({ super.key, required this.length, required this.controller, }); final int length; final PageController controller; @override Widget build(BuildContext context) { return SmoothPageIndicator( controller: controller, count: length, effect: const ExpandingDotsEffect( // Note that you'll have to change the following properties to match // your design. activeDotColor: Colors.orange, dotColor: Colors.blue, dotHeight: 8, dotWidth: 10, expansionFactor: 3, ), ); } }
Click here to cancel reply.
3
Answers
To show indicators you will have to use another package.
Something like smooth_page_indicator
You can use any of the following packages:
Add in your pubspec.yaml File and import. You follow the guide for the usage.
You can rely on a 3rd party package such as smooth_page_indicator which was mentionned.
Based on the screenshot you’ve provided I’d say that the
ExpandingDotsEffect
is what you’re looking for.Sample
Screenshot
Full Code