import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Stack(
children: [
SafeArea(child:Page(),),
Column(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 0, vertical: 0),
child: Positioned(
child: AppBar(
leading: Icon(Icons.chevron_left),
title: Text("PageView Widget"),
backgroundColor: Colors.transparent,
elevation: 0,
),
)
),
],
)
],
)
),
);
}
}
class Page extends StatefulWidget {
PageState createState() => PageState();
}
class PageState extends State<Page>{
final controller = PageController(
initialPage: 0,
);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(child:
PageView(
controller: controller,
onPageChanged: (page)=>{ print(page.toString()) },
pageSnapping: true,
scrollDirection: Axis.vertical,
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/1.jpg'),
fit: BoxFit.cover,
),
),
child: Center(
child: Text(
'BajarangiSoft.com',
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/2.jpg'),
fit: BoxFit.cover,
),
),
child: Center(
child: Text(
'BajarangiSoft.com',
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/3.jpg'),
fit: BoxFit.cover,
),
),
child: Center(
child: Text(
'BajarangiSoft.com',
style: TextStyle(
color: Colors.white,
fontSize: 30,
),
),
),
),
],
),
)
);
}
}