Skip to content

Instantly share code, notes, and snippets.

@phanirithvij
Last active December 16, 2019 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phanirithvij/3d6a66e5d72b06a5d81293346841a2bf to your computer and use it in GitHub Desktop.
Save phanirithvij/3d6a66e5d72b06a5d81293346841a2bf to your computer and use it in GitHub Desktop.
A pageview example
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: Scaffold(
body: PageviewDemo(),
)));
}
class PageviewDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
color: Colors.blue[200].withOpacity(0.3),
child: GestureDetector(
onTap: () => print("A tap on the logo"),
child: Center(
child: FlutterLogo(
size: 100,
colors: Colors.amber,
),
),
),
),
// IgnorePointer(
GestureDetector(
// Comment these five lines (28-32) and uncomment the IgnorePointer then tap on the logo
// The IgnorePointer prevents scrolling which is not intended
behavior: HitTestBehavior.translucent,
onTap: () => print("A Tap on the page view"),
child: PageView(
controller: PageController(viewportFraction: 0.8),
children: <Widget>[
Container(
color: Colors.grey[200].withOpacity(0.7),
),
Container(
color: Colors.red[200].withOpacity(0.7),
),
Container(
color: Colors.yellow[200].withOpacity(0.7),
),
],
),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment