0
Please someone tell me why the buttons that should go through the screens are not working right. I tested on an android emulator and on an android phone and nothing to correctly pass the view.
import 'package:flutter/material.dart';
import 'PageViewController.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter PageView Demonstratio',
theme: ThemeData(
primarySwatch: Colors.green,
),
home: HomeWidget(),
);
}
}
class HomeWidget extends StatefulWidget {
@override
_HomeWidgetState createState() => _HomeWidgetState();
}
class _HomeWidgetState extends State<HomeWidget> {
PageController controller;
@override
void initState() {
super.initState();
controller = PageController(initialPage: 0);
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
List<String> pages = ["BATATA", "CENOURA", "MAGERICÃO"];
return Scaffold(
appBar: AppBar(
actions: <Widget>[
IconButton(
icon: Icon(Icons.keyboard_arrow_left),
onPressed: () {
controller.previousPage(
curve: Curves.easeInOutBack,
duration: Duration(milliseconds: 300));
},
),
IconButton(
icon: Icon(Icons.home),
onPressed: () {
controller.jumpToPage(0);
},
),
IconButton(
icon: Icon(Icons.keyboard_arrow_right),
onPressed: () {
controller.nextPage(
curve: Curves.easeInOutBack,
duration: Duration(milliseconds: 300));
},
),
],
title: Text("Page View"),
),
body: PageView.builder(
controller: controller,
itemCount: pages.length,
itemBuilder: (BuildContext context, int index) {
print(index);
return Center(child: Text(pages[index]));
},
));
}
}
Now that I saw sorry, I removed my answer because it is simpler that I saw, it makes the following switch to animicao from Curves to Ease, for some reason that I have not yet discovered with this animation easeOutBack it does not Vanca.
– Chance
Yes, that’s what it was.
– MARCOS MACHADO
Thanks a lot, bro!
– MARCOS MACHADO
Must be a Flutter bug or something
– MARCOS MACHADO
but it’s interesting you put as an answer so I can close the question
– MARCOS MACHADO
You should answer the question yourself, it was something very simple. Just put what was the problem and ready answered
– Chance
@Justcase In case Marcos was right... You found the solution, so it would be interesting to put together an answer showing where the change is to be made giving a brief explanation.
– Matheus Ribeiro