Skip to content

Instantly share code, notes, and snippets.

@thetrav
Created February 11, 2020 01:06
Show Gist options
  • Save thetrav/ab8b6df21189e8855d8a1f71d96083f2 to your computer and use it in GitHub Desktop.
Save thetrav/ab8b6df21189e8855d8a1f71d96083f2 to your computer and use it in GitHub Desktop.
Test flutter routing
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.15.3-pre.37, on Microsoft Windows [Version 10.0.18362.592], locale en-AU)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
[√] Chrome - develop for the web
[√] Android Studio (version 3.5)
[!] IntelliJ IDEA Community Edition (version 2019.3)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.42.0)
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (2 available)
! Doctor found issues in 3 categories.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Route Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
routes: {
"/": (_) => Home()
},
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute(builder: (_) => Detail(), settings: settings);
},
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text("Home")),
body: Center(child: RaisedButton(
child: Text('Go Detail'),
onPressed: () => Navigator.pushNamed(context, "Detail")
))
);
}
class Detail extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text("Detail")),
body: Center(child: RaisedButton(
child: Text('Go Home'),
onPressed: () => Navigator.pop(context)
))
);
}
name: route_test
description: Test named routes
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment