Transition To New Page With Slide Left To Right
Complete Code For Transition To New Page With Slide Left To Right In Flutter
main.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: SlideTransPages(), ); } } class SlideTransPages extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.orange, title: Text("Slide To Pages Transitions")), body: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Text('Lorem Ipsum is simply dummy text of the printing ' 'and typesetting industry. ' 'Lorem Ipsum has been the industry ' 'standard dummy text ever since the 1500s, ' 'when an unknown printer took a galley of ' 'type and scrambled it to make a type specimen ' 'book. It has survived not only five centuries,' ' but also the leap into electronic typesetting,' ' remaining essentially unchanged.'), SizedBox(height: 20,), Center( child: RaisedButton( child: Text("Goto New Page"), textColor: Colors.white, color: Colors.pink, onPressed: () { Navigator.of(context).push( CupertinoPageRoute<Null>(builder: (BuildContext context) { return new FirstPage(); })); }, ), ), ], ), )); } } class FirstPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.orange, title: Text("Slide to Pages Transitions")), body: Center( child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: <Widget>[ RaisedButton( child: Text("Goto Another Page"), color: Colors.green, textColor: Colors.white, onPressed: () { Navigator.of(context).push( CupertinoPageRoute<Null>(builder: (BuildContext context) { return new SecondPage(); })); }, ), RaisedButton( child: Text("Goto Back"), color: Colors.indigo, textColor: Colors.white, onPressed: () { Navigator.of(context).pop(); }, ), ], ), )); } } class SecondPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.orange, title: Text("Slide to Pages Transitions")), body: Center( child: RaisedButton( child: Text("Goto Back"), color: Colors.red, textColor: Colors.white, onPressed: () { Navigator.of(context).pop(); }, ), )); } }