Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.55 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/rendering.dart';
  3. import 'ListPage.dart';
  4. import 'TextPage.dart';
  5. import 'RootPage.dart';
  6.  
  7. class Destination {
  8.   const Destination(this.title, this.icon, this.color);
  9.   final String title;
  10.   final IconData icon;
  11.   final MaterialColor color;
  12. }
  13.  
  14. const List<Destination> allDestinations = <Destination>[
  15.   Destination('Feed', Icons.home, Colors.blue),
  16.   Destination('Games', Icons.gamepad, Colors.blue),
  17.   Destination('World League', Icons.star, Colors.blue),
  18.   Destination('Your Leagues', Icons.star, Colors.blue),
  19.   Destination('Profile', Icons.person, Colors.blue),
  20. ];
  21.  
  22. class DestinationView extends StatefulWidget {
  23.   const DestinationView({ Key key, this.destination }) : super(key: key);
  24.  
  25.   final Destination destination;
  26.  
  27.   @override
  28.   _DestinationViewState createState() => _DestinationViewState();
  29. }
  30.  
  31. class _DestinationViewState extends State<DestinationView> {
  32.   @override
  33.   Widget build(BuildContext context) {
  34.     return Navigator(
  35.       onGenerateRoute: (RouteSettings settings) {
  36.         return MaterialPageRoute(
  37.           settings: settings,
  38.           builder: (BuildContext context) {
  39.             switch(settings.name) {
  40.               case '/':
  41.                 return RootPage(destination: widget.destination);
  42.               case '/list':
  43.                 return ListPage(destination: widget.destination);
  44.               case '/text':
  45.                 return TextPage(destination: widget.destination);
  46.             }
  47.           },
  48.         );
  49.       },
  50.     );
  51.   }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement