Skip to content

Instantly share code, notes, and snippets.

@mmanflori
Created June 28, 2019 12:57
Show Gist options
  • Save mmanflori/27653948d9dd6a79fa14a6f51a31285d to your computer and use it in GitHub Desktop.
Save mmanflori/27653948d9dd6a79fa14a6f51a31285d to your computer and use it in GitHub Desktop.
Basic Routing
import 'package:flutter/material.dart';
class DritteSeite extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: MeinInhalt3(),
);
}
}
class MeinInhalt3 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: Text(
"Dritte Seite",
style: TextStyle(
fontSize:30.0,
)
),
),
RaisedButton(
child: Text("Zurück"),
onPressed: () {
Navigator.pop(context);
},
),
],
)
],
);
}
}
import 'package:container_videotut/zweite_seite.dart';
import 'package:flutter/material.dart';
class HomeSeite extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: MeinInhalt1(),
);
}
}
class MeinInhalt1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
color: Theme.of(context).primaryColorLight,
child: Text(
"Homepage",
style: TextStyle(
fontSize:30.0,
)
),
),
RaisedButton(
child: Text("Zweite Seite"),
onPressed: () {
Route route = MaterialPageRoute(builder: (context)=>ZweiteSeite());
Navigator.push(context, route);
},
),
RaisedButton(
child: Text("Dritte Seite"),
onPressed: () {
Navigator.pushNamed(context, "/DritteSeite");
},
),
RaisedButton(
child: Text("Vierte Seite"),
onPressed: () {
Navigator.pushNamed(context, "/VierteSeite");
},
),
],
)
],
);
}
}
import 'package:container_videotut/vierte_seite.dart';
import 'package:container_videotut/zweite_seite.dart';
import 'package:flutter/material.dart';
import 'dritte_seite.dart';
import 'home_seite.dart';
void main()=> runApp(MeineApp());
class MeineApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
routes: {
"/":(BuildContext context) => HomeSeite(),
"/DritteSeite":(BuildContext context) => DritteSeite(),
"/VierteSeite":(BuildContext context) => VierteSeite(),
},
);
}
}
import 'package:flutter/material.dart';
class VierteSeite extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: MeinInhalt4(),
);
}
}
class MeinInhalt4 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: Text(
"Vierte Seite",
style: TextStyle(
fontSize:30.0,
)
),
),
RaisedButton(
child: Text("Zurück"),
onPressed: () {
Navigator.pop(context);
},
),
],
),
],
);
}
}
import 'package:flutter/material.dart';
class ZweiteSeite extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: MeinInhalt2(),
);
}
}
class MeinInhalt2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: Text(
"Zweite Seite",
style: TextStyle(
fontSize:30.0,
)
),
),
RaisedButton(
child: Text("Zurück"),
onPressed: () {
Navigator.pop(context);
},
),
],
)
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment