curso_routes_transition_jfgq 0.0.3 curso_routes_transition_jfgq: ^0.0.3 copied to clipboard
class lesson exercise.
example/main.dart
import 'package:curso_routes_transition_jfgq/curso_routes_transition_jfgq.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
//*304
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
debugShowCheckedModeBanner: false,
initialRoute: 'page1',
routes: {
'page1': (_) => Page1(),
'page2': (_) => Page2(),
},
);
}
}
class Page1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Page 1'),
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.blue,
body: Center(
child: MaterialButton(
child: const Text('Go to page2'),
color: Colors.white,
onPressed: () {
RouteTransitions(
duracion: const Duration(milliseconds: 2000),
child: Page2(),
context: context,
animation: AnimationType.normal,
replacement: false, //*307
);
},
),
),
);
}
}
//*304
class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Page 2'),
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.amber,
body: const Center(
child: Text('Page 2'),
),
);
}
}