Closed johnDivek closed 4 years ago
I think you set up wrong something, please check the code example or showing your config so I can check what you did.
import 'package:Aor/app/providers/language_provider.dart'; 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:provider/provider.dart';
class IntroScreen extends StatefulWidget { IntroScreen({Key key}) : super(key: key);
@override IntroScreenState createState() => new IntroScreenState(); }
class IntroScreenState extends State
Function goToTab;
@override void initState() { super.initState(); }
void onDonePress() { // Back to the first tab Navigator.pushReplacementNamed(context, '/signUp'); }
void onTabChangeCompleted(index) { // Index of current tab is focused }
Widget renderNextBtn() { return Icon( Icons.navigate_next, color: Colors.red, size: 35.0, ); }
Widget renderDoneBtn() { return Icon( Icons.done, color: Colors.red, ); }
Widget renderSkipBtn() { return Icon( Icons.skip_next, color: Colors.red, ); }
textStyle() { return TextStyle( color: Colors.white, fontSize: 20.0, fontStyle: FontStyle.normal, fontFamily: 'AlegreyaSansSC'); }
headTextStyle() { return TextStyle( color: Colors.white, fontSize: 30.0, fontStyle: FontStyle.normal, fontFamily: 'AlegreyaSansSC'); }
List
@override Widget build(BuildContext context) {
final languageModel = Provider.of<LanguageModel>(context);
slides.add(
new Slide(
title: languageModel.lang['intro1Title'],
styleTitle: headTextStyle(),
description: languageModel.lang['intro1Summary'],
styleDescription: textStyle(),
),
);
slides.add(
new Slide(
title: languageModel.lang['intro2Title'],
styleTitle: headTextStyle(),
description: languageModel.lang['intro2Summary'],
styleDescription: textStyle(),
),
);
slides.add(
new Slide(
title: languageModel.lang['intro3Title'],
styleTitle: headTextStyle(),
description: languageModel.lang['intro3Summary'],
styleDescription: textStyle(),
),
);
return new IntroSlider(
// List slides
slides: this.slides,
// Skip button
renderSkipBtn: this.renderSkipBtn(),
colorSkipBtn: Colors.black,
highlightColorSkipBtn: Colors.red,
// Next button
renderNextBtn: this.renderNextBtn(),
// Done button
renderDoneBtn: this.renderDoneBtn(),
onDonePress: this.onDonePress,
colorDoneBtn: Colors.black,
highlightColorDoneBtn: Colors.red,
// Dot indicator
colorDot: Colors.white,
sizeDot: 8.0,
typeDotAnimation: dotSliderAnimation.DOT_MOVEMENT,
colorActiveDot: Colors.red,
// Tabs
listCustomTabs: this.renderListCustomTabs(),
backgroundColorAllSlides: Colors.black,
refFuncGoToTab: (refFunc) {
this.goToTab = refFunc;
},
// Show or hide status bar
shouldHideStatusBar: true,
// On tab change completed
onTabChangeCompleted: this.onTabChangeCompleted,
);
} }
The issue weird only occurs when the loaded from my login screen but works good from splash screen
add how you navigate to Introscreen from login ...this seems to be an error with how you call your arrays
it occurs when you put the list in the build instead of the init. i want to use it in the build so i could use the S.of(context) any idea on how to use context in init method?
after_init 0.1.2 use this package it worked for me
════════ Exception Caught By widgets library ═══════════════════════════════════════════════════════ The following RangeError was thrown building IntroSlider(dirty, dependencies: [MediaQuery, _LocalizationsScope-[GlobalKey#5ac6e]], state: IntroSliderState#7ffc0(ticker inactive)): RangeError (index): Invalid value: Not in range 0..2, inclusive: 3 When the exception was thrown, this was the stack:
0 List.[] (dart:core-patch/growable_array.dart:145:60)
1 IntroSliderState.renderListDots (package:intro_slider/intro_slider.dart:1039:34)
2 IntroSliderState.renderBottom (package:intro_slider/intro_slider.dart:829:42)
3 IntroSliderState.build (package:intro_slider/intro_slider.dart:737:13)
4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4012:27)