Route to a specific page of pageview widget from another dart file
import 'package:flutter/material.dart';
class AboutView extends StatefulWidget {
int selectedIndex;
AboutView(this.selectedIndex);
@override
State<AboutView> createState() => _AboutViewState();
}
class _AboutViewState extends State<AboutView> {
PageController? controller;
@override
void initState() {
// TODO: implement initState
super.initState();
controller = PageController(initialPage: widget.selectedIndex);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: PageView(
controller: controller,
scrollDirection: Axis.vertical,
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('Porter'),
SizedBox(
width: 60,
),
CircleAvatar(
backgroundColor: Colors.transparent,
backgroundImage:
AssetImage("assets/ShirtLogoBierNEWFrontMedium.png"),
),
],
),
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.white,
child: Center(
child: Text('IPA'),
),
),
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.white,
child: Center(
child: Text('Pale Ale'),
),
),
],
),
));
}
}