You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I faced an issue when taping skip button and let the app navigate to another page it will throw an exception with the following details:
AssertionError ('package:flutter/src/widgets/page_view.dart': Failed assertion: line 170 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.)
this issue is reproduceable and I shared an example bellow, another point is when I click next and go through all pages then click done, the exception will not occur.
YounisHamasur
changed the title
Bug: Problem with skip function before initializing all screens
Bug: Problem with skip function before initializing all pages
Sep 3, 2023
I faced an issue when taping skip button and let the app navigate to another page it will throw an exception with the following details:
AssertionError ('package:flutter/src/widgets/page_view.dart': Failed assertion: line 170 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.)
this issue is reproduceable and I shared an example bellow, another point is when I click next and go through all pages then click done, the exception will not occur.
-first page example:
`import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:introduction_screen/introduction_screen.dart';
import 'package:testgetx/pagetwo.dart';
import 'controller.dart';
class PageOne extends StatelessWidget {
PageOne({super.key});
final introKey = GlobalKey();
void _onIntroEnd(context) {
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (context) => PageTwo()));
}
@OverRide
Widget build(BuildContext context) {
var bodyStyle = TextStyle(fontSize: 12);
var pageDecoration = PageDecoration(
titleTextStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
),
bodyTextStyle: bodyStyle,
bodyPadding: EdgeInsets.all(0),
pageColor: Colors.white,
imagePadding: EdgeInsets.all(0),
fullScreen: true,
contentMargin: EdgeInsets.all(0));
}
PageViewModel introPageView(
imageName, PageDecoration pageDecoration, title, body, context) {
return PageViewModel(
title: title,
body: body,
image: null,
decoration: pageDecoration,
);
}
Widget _buildImage(String assetName, context, [double width = 350]) {
return Container(
padding: EdgeInsets.only(bottom: 20, left: 0, right: 0, top: 0),
child: Image.asset(
'assets/images/$assetName',
//height: MediaQuery.of(context).size.height / 1.2,
),
);
}
}
`
and this is just pagetwo
`import 'package:flutter/material.dart';
class PageTwo extends StatelessWidget {
const PageTwo({super.key});
@OverRide
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Column(
children: [
Center(
child: Text("pagetwo"),
),
],
));
}
}
`
The text was updated successfully, but these errors were encountered: