Qries

Subscribe Us

Advertisement

intro slider

 intro slider|intro Screen:


Video:


Code:

import 'package:flutter/material.dart';
import 'package:intro_slider/dot_animation_enum.dart';
import 'package:intro_slider/intro_slider.dart';
import 'package:intro_slider/slide_object.dart';

//import 'package:intro_slider_example/home.dart';
void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: IntroScreen(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class IntroScreen extends StatefulWidget {
  IntroScreen({Key key}) : super(key: key);

  @override
  IntroScreenState createState() => new IntroScreenState();
}
class IntroScreenState extends State<IntroScreen> {
  List<Slide> slides = new List();

  Function goToTab;

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

    slides.add(
      new Slide(
        title: "maherban husen tech",
        styleTitle: TextStyle(
          color: Colors.red,
          fontSize: 30.0,
          fontWeight: FontWeight.bold,
        ),
        description:
        "We wiil tell you Flutter, Dart, UI, Widget, Packages ets in this channel.",
        styleDescription: TextStyle(
          fontStyle: FontStyle.italic,
          fontSize: 20,
        ),
        pathImage: "images/logo1.png",
      ),
    );
    slides.add(
      new Slide(
        title: "Profile UI",
        styleTitle: TextStyle(
          color: Colors.red,
          fontSize: 30.0,
          fontWeight: FontWeight.bold,
        ),
        description: "This video has a Profile UI.",
        styleDescription: TextStyle(
          fontStyle: FontStyle.italic,
          fontSize: 20,
        ),
        pathImage: "images/2a.jpg",
      ),
    );
    slides.add(
      new Slide(
        title: "Music UI",
        styleTitle: TextStyle(
          color: Colors.red,
          fontSize: 30.0,
          fontWeight: FontWeight.bold,
        ),
        description: "This video has a Music UI.",
        styleDescription: TextStyle(
          fontStyle: FontStyle.italic,
          fontSize: 20,
        ),
        pathImage: "images/3a.jpg",
      ),
    );
  }

  void onDonePress() {
    // Back to the first tab    this.goToTab(0);
  }

  void onTabChangeCompleted(index) {
    // Index of current tab is focused  }

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

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

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

  List<Widget> renderListCustomTabs() {
    List<Widget> tabs = new List();
    for (int i = 0; i < slides.length; i++) {
      Slide currentSlide = slides[i];
      tabs.add(Container(
        width: double.infinity,
        height: double.infinity,
        child: Container(
          margin: EdgeInsets.only(bottom: 60.0, top: 60.0),
          child: ListView(
            children: <Widget>[
              GestureDetector(
                  child: Image.asset(
                    currentSlide.pathImage,
                    width: 200.0,
                    height: 200.0,
                    fit: BoxFit.contain,
                  )),
              Container(
                child: Text(
                  currentSlide.title,
                  style: currentSlide.styleTitle,
                  textAlign: TextAlign.center,
                ),
                margin: EdgeInsets.only(top: 20.0),
              ),
              Container(
                child: Text(
                  currentSlide.description,
                  style: currentSlide.styleDescription,
                  textAlign: TextAlign.center,
                  maxLines: 5,
                  overflow: TextOverflow.ellipsis,
                ),
                margin: EdgeInsets.only(top: 20.0),
              ),
            ],
          ),
        ),
      ));
    }
    return tabs;
  }

  @override
  Widget build(BuildContext context) {
    return new IntroSlider(
      // List slides      slides: this.slides,

      // Skip button      renderSkipBtn: this.renderSkipBtn(),
      colorSkipBtn: Colors.red,
      highlightColorSkipBtn: Colors.blue,

      // Next button      renderNextBtn: this.renderNextBtn(),

      // Done button      renderDoneBtn: this.renderDoneBtn(),
      onDonePress: this.onDonePress,
      colorDoneBtn: Colors.red,
      highlightColorDoneBtn: Colors.green,

      // Dot indicator      colorDot: Colors.blueGrey,
      sizeDot: 13.0,
      typeDotAnimation: dotSliderAnimation.SIZE_TRANSITION,

      // Tabs      listCustomTabs: this.renderListCustomTabs(),
      backgroundColorAllSlides: Colors.white,
      refFuncGoToTab: (refFunc) {
        this.goToTab = refFunc;
      },

      // Show or hide status bar      shouldHideStatusBar: true,

      // On tab change completed      onTabChangeCompleted: this.onTabChangeCompleted,
    );
  }
}

Post a Comment

0 Comments