duytq94 / flutter-intro-slider

Simple and configurable app introduction slider for Flutter
https://pub.dartlang.org/packages/intro_slider
MIT License
677 stars 141 forks source link

The name 'Slide' isn't a type so it can't be used as a type argument. #37

Closed richie-south closed 5 years ago

richie-south commented 5 years ago

Am i doing something wrong? I'm getting this error on all the Slide objects: The name 'Slide' isn't a type so it can't be used as a type argument. Try correcting the name to an existing type, or defining a type named 'Slide'.dart(non_type_as_type_argument)

This happened after i upgraded to the latest Flutter version :)

Screenshot 2019-08-05 at 15 57 41

Flutter version: Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.4 18E226, locale en-SE)

Full code

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

class Introduction extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return IntroductionState();
  }
}

class IntroductionState extends State<Introduction> {
  List<Slide> slides = List();

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

  void addScreens() {
    slides.add(
      Slide(
        title: 'title',
        description: 'description',
        backgroundColor: Colors.white,
        pathImage: 'assets/images/screen-one.png',
        styleTitle: TextStyle(
          color: Colors.black,
          fontSize: 30,
          fontWeight: FontWeight.bold
        ),
        styleDescription: TextStyle(
          color: Colors.black,
          fontSize: 18,
        ),
      ),
    );
    slides.add(
      Slide(
        title: 'title',
        description: 'description',
        backgroundColor: Colors.white,
        pathImage: 'assets/images/screen-two.png',
        styleTitle: TextStyle(
          color: Colors.black,
          fontSize: 30,
          fontWeight: FontWeight.bold
        ),
        styleDescription: TextStyle(
          color: Colors.black,
          fontSize: 18,
        ),
      ),
    );
    slides.add(
      Slide(
        title: 'title',
        description: 'description',
        backgroundColor: Colors.white,
        pathImage: 'assets/images/screen-three.png',
        widthImage: 100,
        heightImage: 100,
        styleTitle: TextStyle(
          color: Colors.black,
          fontSize: 30,
          fontWeight: FontWeight.bold
        ),
        styleDescription: TextStyle(
          color: Colors.black,
          fontSize: 18,
        ),
      ),
    );
  }

  void onDonePress() {
    Navigator.pop(context);
  }

  void onSkipPress() {
    Navigator.pop(context);
  }

  @override
  Widget build(BuildContext context) {
    return IntroSlider(
      slides: slides,
      colorActiveDot: Colors.black12,
      styleNameSkipBtn: TextStyle(
        color: Colors.black
      ),
      styleNameDoneBtn: TextStyle(
        color: Colors.black
      ),
      onDonePress: onDonePress,
      onSkipPress: onSkipPress
    );
  }
}

Hope some of this information helps :)

richie-south commented 5 years ago

I'm stupid... I just needed to import import 'package:intro_slider/slide_object.dart';

Closing this xD

duytq94 commented 5 years ago

Actually, I separate slide object to a class for clearer so maybe people update from old version will miss this import. Glad that your problem is solved 👍

apoorvpandey0 commented 4 years ago

No you are not, I found it helpful. Thanks!