Created with <3 with dartpad.dev.
Created
August 4, 2022 08:54
-
-
Save jfahrenkrug/3862ceb9c5b74271b99363933e67bdee to your computer and use it in GitHub Desktop.
exquisite-rainbow-1517
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'EasyImageViewer Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: const MyPageView(), | |
); | |
} | |
} | |
class MyPageView extends StatefulWidget { | |
const MyPageView({Key? key}) : super(key: key); | |
@override | |
State<MyPageView> createState() => _MyPageViewState(); | |
} | |
class _MyPageViewState extends State<MyPageView> { | |
final PageController _pageController = PageController(); | |
DismissDirection _dismissDirection = DismissDirection.down; | |
@override | |
void dispose() { | |
_pageController.dispose(); | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp(home: Scaffold( | |
body: Dismissible( | |
direction: _dismissDirection, | |
resizeDuration: null, | |
onDismissed: (_) { | |
Navigator.of(context).pop(); | |
}, | |
key: const Key('dismissable_easy_image_viewer_dialog'), | |
child: PageView( | |
controller: _pageController, | |
children: <Widget>[ | |
Container( | |
color: Colors.red, | |
child: Center( | |
child: ElevatedButton( | |
onPressed: () { | |
if (_pageController.hasClients) { | |
_pageController.animateToPage( | |
1, | |
duration: const Duration(milliseconds: 400), | |
curve: Curves.easeInOut, | |
); | |
} | |
}, | |
child: const Text('Next'), | |
), | |
), | |
), | |
Container( | |
color: Colors.blue, | |
child: Center( | |
child: ElevatedButton( | |
onPressed: () { | |
setState(() { | |
_dismissDirection = DismissDirection.none; | |
}); | |
}, | |
child: const Text('Change Dismiss Direction'), | |
), | |
), | |
), | |
], | |
), | |
), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment