intro_slider 4.2.0 icon indicating copy to clipboard operation
intro_slider: ^4.2.0 copied to clipboard

Flutter Intro Slider is a flutter plugin that helps you make a cool intro for your app

FLUTTER INTRO SLIDER

Flutter Intro Slider is a flutter plugin that helps you make a cool intro for your app. Create intro has never been easier and faster

Table of Contents #


Installing #

Add to pubspec.yaml file

dependencies:
  intro_slider: ^4.2.0

Import

import 'package:intro_slider/intro_slider.dart';

Demo #

default custom 1 custom 2


Code example #


Default config #

default config image

Code example (click to expand)
class IntroScreenDefaultState extends State<IntroScreenDefault> {
  List<ContentConfig> listContentConfig = [];

  @override
  void initState() {
    super.initState();

    listContentConfig.add(
      const ContentConfig(
        title: "ERASER",
        description:
            "Allow miles wound place the leave had. To sitting subject no improve studied limited",
        pathImage: "images/photo_eraser.png",
        backgroundColor: Color(0xfff5a623),
      ),
    );
    listContentConfig.add(
      const ContentConfig(
        title: "PENCIL",
        description:
            "Ye indulgence unreserved connection alteration appearance",
        pathImage: "images/photo_pencil.png",
        backgroundColor: Color(0xff203152),
      ),
    );
    listContentConfig.add(
      const ContentConfig(
        title: "RULER",
        description:
            "Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of",
        pathImage: "images/photo_ruler.png",
        backgroundColor: Color(0xff9932CC),
      ),
    );
  }

  void onDonePress() {
    log("End of slides");
  }

  @override
  Widget build(BuildContext context) {
    return IntroSlider(
      key: UniqueKey(),
      listContentConfig: listContentConfig,
      onDonePress: onDonePress,
    );
  }
}

Custom config #

custom config image

Code example (click to expand)
class IntroScreenCustomConfigState extends State<IntroScreenCustomConfig> {
  List<ContentConfig> listContentConfig = [];
  Color activeColor = const Color(0xff0BEEF9);
  Color inactiveColor = const Color(0xff03838b);
  double sizeIndicator = 20;

  @override
  void initState() {
    super.initState();

    listContentConfig.add(
      ContentConfig(
        title:
            "A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE A VERY LONG TITLE",
        maxLineTitle: 2,
        styleTitle: const TextStyle(
          color: Colors.white,
          fontSize: 30.0,
          fontWeight: FontWeight.bold,
          fontFamily: 'RobotoMono',
        ),
        description:
            "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,",
        styleDescription: const TextStyle(
          color: Colors.white,
          fontSize: 20.0,
          fontStyle: FontStyle.italic,
          fontFamily: 'Raleway',
        ),
        marginDescription: const EdgeInsets.only(
          left: 20.0,
          right: 20.0,
          top: 20.0,
          bottom: 70.0,
        ),
        centerWidget: const Text(
          "Replace this with a custom widget",
          style: TextStyle(color: Colors.white),
        ),
        backgroundNetworkImage: "https://picsum.photos/600/900",
        backgroundFilterOpacity: 0.5,
        backgroundFilterColor: Colors.redAccent,
        onCenterItemPress: () {},
      ),
    );
    listContentConfig.add(
      const ContentConfig(
        title: "CITY",
        styleTitle: TextStyle(
          color: Color(0xff7FFFD4),
          fontSize: 30.0,
          fontWeight: FontWeight.bold,
          fontFamily: 'RobotoMono',
        ),
        description:
            "Ye indulgence unreserved connection alteration appearance",
        styleDescription: TextStyle(
          color: Color(0xff7FFFD4),
          fontSize: 20.0,
          fontStyle: FontStyle.italic,
          fontFamily: 'Raleway',
        ),
        colorBegin: Color(0xff89D4CF),
        colorEnd: Color(0xff734AE8),
        directionColorBegin: Alignment.topRight,
        directionColorEnd: Alignment.bottomLeft,
      ),
    );
    listContentConfig.add(
      const ContentConfig(
        title: "BEACH",
        styleTitle: TextStyle(
          color: Color(0xffFFDAB9),
          fontSize: 30.0,
          fontWeight: FontWeight.bold,
          fontFamily: 'RobotoMono',
        ),
        description:
            "Much evil soon high in hope do view. Out may few northward believing attempted. Yet timed being songs marry one defer men our. Although finished blessing do of",
        styleDescription: TextStyle(
          color: Color(0xffFFDAB9),
          fontSize: 20.0,
          fontStyle: FontStyle.italic,
          fontFamily: 'Raleway',
        ),
        backgroundImage: "images/beach.jpeg",
        maxLineTextDescription: 3,
      ),
    );
  }

  void onDonePress() {
    log("onDonePress caught");
  }

  void onNextPress() {
    log("onNextPress caught");
  }

  Widget renderNextBtn() {
    return const Icon(
      Icons.navigate_next,
      size: 25,
    );
  }

  Widget renderDoneBtn() {
    return const Icon(
      Icons.done,
      size: 25,
    );
  }

  Widget renderSkipBtn() {
    return const Icon(
      Icons.skip_next,
      size: 25,
    );
  }

  ButtonStyle myButtonStyle() {
    return ButtonStyle(
      shape: MaterialStateProperty.all<OutlinedBorder>(const StadiumBorder()),
      foregroundColor: MaterialStateProperty.all<Color>(activeColor),
      backgroundColor: MaterialStateProperty.all<Color>(inactiveColor),
    );
  }

  @override
  Widget build(BuildContext context) {
    return IntroSlider(
      key: UniqueKey(),
      // Content config
      listContentConfig: listContentConfig,
      backgroundColorAllTabs: Colors.grey,

      // Skip button
      renderSkipBtn: renderSkipBtn(),
      skipButtonStyle: myButtonStyle(),

      // Next button
      renderNextBtn: renderNextBtn(),
      onNextPress: onNextPress,
      nextButtonStyle: myButtonStyle(),

      // Done button
      renderDoneBtn: renderDoneBtn(),
      onDonePress: onDonePress,
      doneButtonStyle: myButtonStyle(),

      // Indicator
      indicatorConfig: IndicatorConfig(
        sizeIndicator: sizeIndicator,
        indicatorWidget: Container(
          width: sizeIndicator,
          height: 10,
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(4), color: inactiveColor),
        ),
        activeIndicatorWidget: Container(
          width: sizeIndicator,
          height: 10,
          decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(4), color: activeColor),
        ),
        spaceBetweenIndicator: 10,
        typeIndicatorAnimation: TypeIndicatorAnimation.sliding,
      ),

      // Navigation bar
      navigationBarConfig: NavigationBarConfig(
        navPosition: NavPosition.bottom,
        padding: EdgeInsets.only(
          top: MediaQuery.of(context).viewPadding.top > 0 ? 20 : 10,
          bottom: MediaQuery.of(context).viewPadding.bottom > 0 ? 20 : 10,
        ),
        backgroundColor: Colors.black.withOpacity(0.5),
      ),

      // Scroll behavior
      isAutoScroll: true,
      isLoopAutoScroll: true,
      curveScroll: Curves.bounceIn,
    );
  }
}

Custom layout #

custom config image

Code example (click to expand)
class IntroScreenCustomLayoutState extends State<IntroScreenCustomLayout> {
  late Function goToTab;

  Color primaryColor = const Color(0xffffcc5c);
  Color secondColor = const Color(0xff3da4ab);

  void onDonePress() {
    goToTab(0);
  }

  void onTabChangeCompleted(index) {
    log("onTabChangeCompleted, index: $index");
  }

  Widget renderNextBtn() {
    return Icon(
      Icons.navigate_next,
      color: primaryColor,
      size: 35.0,
    );
  }

  Widget renderDoneBtn() {
    return Icon(
      Icons.done,
      color: primaryColor,
    );
  }

  Widget renderSkipBtn() {
    return Icon(
      Icons.skip_next,
      color: primaryColor,
    );
  }

  ButtonStyle myButtonStyle() {
    return ButtonStyle(
      shape: MaterialStateProperty.all<OutlinedBorder>(const StadiumBorder()),
      backgroundColor:
          MaterialStateProperty.all<Color>(const Color(0x33ffcc5c)),
      overlayColor: MaterialStateProperty.all<Color>(const Color(0x33ffcc5c)),
    );
  }

  List<Widget> generateListCustomTabs() {
    return List.generate(
      3,
      (index) => Container(
        color: Colors.black26,
        width: double.infinity,
        height: double.infinity,
        child: ListView(
          children: <Widget>[
            const SizedBox(height: 20),
            Center(
              child: DropdownButton<String>(
                value: index.toString(),
                icon: Icon(Icons.arrow_downward, color: secondColor, size: 20),
                elevation: 16,
                style: TextStyle(color: primaryColor),
                underline: Container(
                  height: 2,
                  color: secondColor,
                ),
                onChanged: (String? value) {},
                items: ["0", "1", "2"]
                    .map<DropdownMenuItem<String>>((String value) {
                  return DropdownMenuItem<String>(
                    value: value,
                    child: Text(value,
                        style: TextStyle(color: secondColor, fontSize: 20)),
                  );
                }).toList(),
              ),
            ),
            const SizedBox(height: 20),
            Image.network(
              "https://picsum.photos/${300 + index}",
              width: 300.0,
              height: 300.0,
            ),
            const SizedBox(height: 20),
            Container(
              margin: const EdgeInsets.symmetric(vertical: 20, horizontal: 16),
              child: Text(
                "Title at index $index",
                textAlign: TextAlign.center,
                style: TextStyle(
                  color: secondColor,
                  fontSize: 30.0,
                  fontWeight: FontWeight.bold,
                  fontFamily: 'RobotoMono',
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return IntroSlider(
      key: UniqueKey(),
      // Skip button
      renderSkipBtn: renderSkipBtn(),
      skipButtonStyle: myButtonStyle(),

      // Next button
      renderNextBtn: renderNextBtn(),
      nextButtonStyle: myButtonStyle(),

      // Done button
      renderDoneBtn: renderDoneBtn(),
      onDonePress: onDonePress,
      doneButtonStyle: myButtonStyle(),

      // Indicator
      indicatorConfig: const IndicatorConfig(
        colorIndicator: Color(0xffffcc5c),
        sizeIndicator: 13.0,
        typeIndicatorAnimation: TypeIndicatorAnimation.sizeTransition,
      ),

      // Custom tabs
      listCustomTabs: generateListCustomTabs(),
      backgroundColorAllTabs: Colors.white,
      refFuncGoToTab: (refFunc) {
        goToTab = refFunc;
      },

      // Behavior
      scrollPhysics: const BouncingScrollPhysics(),
      onTabChangeCompleted: onTabChangeCompleted,
    );
  }
}



IntroSlider parameter #

NameTypeDefaultDescription
Tab
keyKey?Assign key to IntroSlider widget
listContentConfigList<ContentConfig>?View detailsAn array of ContentConfig, require if listCustomTabs not defined
listCustomTabsList<Widget>?Require if listContentConfig not definedRender your own widget list tabs (meaning you can put your custom widget into the prebuilt frame)
refFuncGoToTabvoid Function(Function function)?Do nothingSend the reference of change tab's function, then we can move to any tab index programmatically
onTabChangeCompletedvoid Function(int index)?Do nothingCallback when tab change comleted, return the current tab's index
backgroundColorAllTabsColor?TransparentBackground color for all tabs (if backgroundColor not set in each tab)
Skip Button
renderSkipBtnWidget?Text("SKIP")Render your own widget SKIP button
skipButtonStyleButtonStyle?ButtonStyle()Style for SKIP button
onSkipPressvoid Function()?Go to last page + call your function if defineFire when press SKIP button
isShowSkipBtnbool?trueShow or hide SKIP button
skipButtonKeyKey?Assign key to SKIP button
Previous Button
renderPrevBtnWidget?Text("PREV")Render your own PREV button
prevButtonStyleButtonStyle?ButtonStyle()Style for PREV button
isShowPrevBtnbool?falseShow or hide PREV, have to set isShowSkipBtn to false at first if you want to show this button
prevButtonKeyKey?Assign key to PREV button
Done Button
renderDoneBtnWidget?Text("DONE")Render your own DONE button
doneButtonStyleButtonStyle?ButtonStyle()Style for DONE button
onDonePressvoid Function()?Do nothingFire when press DONE button
isShowDoneBtnbool?trueShow or hide DONE button
doneButtonKeyKey?Assign key to NEXT button
Next Button
renderNextBtnWidget?Text("NEXT")Render your own NEXT button
nextButtonStyleButtonStyle?ButtonStyle()Style for NEXT button
onNextPressvoid Function()?Go to next page + call your function if defineFire when press NEXT button
isShowNextBtnbool?trueShow or hide NEXT button
nextButtonKeyKey?Assign key to NEXT button
Indicator
indicatorConfigIndicatorConfig?View detailsCustom indicator
Navigation bar
navigationBarConfigNavigationBarConfig?View detailsCustom position navigation bar
Scroll behavior
isScrollablebool?trueWhether or not the slider is scrollable (or controlled only by buttons)
curveScrollCurve?Curves.easeSet transition animation curves (also effect to indicator when it's sliding)
scrollPhysicsScrollPhysics?ScrollPhysics()Determines the physics horizontal scroll for the slides
isAutoScrollbool?falseEnable auto scroll slides
isLoopAutoScrollbool?falseLoop transition by go to first slide when reach the end
isPauseAutoPlayOnTouchbool?trueAuto scroll will be paused if user touch to slide
autoScrollIntervalDuration?Duration(seconds: 4)Sets duration to determine the frequency of slides

ContentConfig parameter #

NameTypeDefaultDescription
Title
titleString?""Change text title at top
widgetTitleWidget?nullSet a custom widget as the title (ignore title if define both)
maxLineTitleint?1Change max number of lines title at top
styleTitleTextStyle?White color, bold and font size is 30.0Style for text title
textAlignTitleTextAlign?TextAlign.centerTextAlign for text title
textOverFlowTitleTextOverflow?TextOverflow.ellipsisTextOverflow for text title
marginTitleEdgeInsets?top: 70.0, bottom: 50.0Margin for text title
Image
pathImageString?""Path to your local image
widthImagedouble?250.0Width of image
heightImagedouble?250.0Height of image
foregroundImageFitBoxFit?BoxFit.containForeground image fit
Center widget
centerWidgetWidget?nullYour custom's widget
onCenterItemPressFunction()?Do nothingFire when press center image/widget
Description
descriptionString?""Change text description at bottom
widgetDescriptionWidget?nullSet a custom widget as the description (ignore description if define both)
maxLineTextDescriptionint?100Maximum line of text description
styleDescriptionTextStyle?White and font size is 18.0Style for text description
textAlignDescriptionTextAlign?TextAlign.centerTextAlign for text description
textOverFlowDescriptionTextOverflow?TextOverflow.ellipsisTextOverflow for text description
marginDescriptionEdgeInsets?left, right = 20.0, top, bottom = 50.0Margin for text description
Background Color
backgroundColorColor?Colors.amberAccentBackground tab color (if set, will ignore gradient properties below)
colorBeginColor?Colors.amberAccentGradient tab color begin
colorEndColor?Colors.amberAccentGradient tab color end
directionColorBeginAlignmentGeometry?Alignment.topLeftDirection color begin
directionColorEndAlignmentGeometry?Alignment.bottomRightDirection color end
Background Image
backgroundImageString?nullSet image for background (if set, will ignore all parameter at Background Color above)
backgroundNetworkImageString?nullSet image (from network) for background
backgroundImageFitBoxFit?BoxFit.coverBackground image fit
backgroundFilterColorColor?Colors.blackA color filter to apply to the image background before painting it
backgroundFilterOpacitydouble?0.5Opacity for backgroundFilterColor
backgroundBlendModeBlendMode?BlendMode.darkenBackground blend mode
Others
verticalScrollbarBehaviorenum ScrollbarBehavior?ScrollbarBehavior.HIDEAllow to specify how the vertical scrollbar should behave
(scroll enable when content length is greater than screen length)

IndicatorConfig parameter #

NameTypeDefaultDescription
isShowIndicatorbool?trueShow or hide indicator
colorIndicatorColor?Colors.black54Color indicator when passive, note: ignore if using custom indicator
colorActiveIndicatorColor?colorIndicatorColor indicator when active (focusing),
note: ignore if using custom indicator or TypeIndicatorAnimation.sizeTransition
sizeIndicatordouble?8.0Size of each indicator
spaceBetweenIndicatordouble?The same value of sizeIndicatorSpace between every indicator
typeIndicatorAnimationenum TypeIndicatorAnimation?TypeIndicatorAnimation.slidingType indicator animation
indicatorWidgetWidget?Default dotYour custom indicator widget
activeIndicatorWidgetWidget?Default dotYour custom active (focusing) indicator widget,
note: ignore if using TypeIndicatorAnimation.sizeTransition

NameTypeDefaultDescription
paddingEdgeInsetsEdgeInsets.symmetric(vertical: 10)Padding
navPositionNavPositionNavPosition.bottomMove navigation bar to top or bottom page
backgroundColorColorColors.transparentBackground color

Pull request and feedback are always appreciated #

924
likes
140
pub points
98%
popularity

Publisher

unverified uploader

Flutter Intro Slider is a flutter plugin that helps you make a cool intro for your app

Homepage

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on intro_slider