Monday, February 26, 2024
Sunday, February 18, 2024
Sunday, February 11, 2024
Tuesday, February 6, 2024
Mobil uygulamalar, Navigator, MaterialPageRoute örneği
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(
width: double.infinity,
),
const Text("Home Page Sayfası"),
const SizedBox(
height: 20,
),
ElevatedButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const Sayfa2()));
},
child: const Text("Sayfa2 ye git"),
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const Sayfa3()));
},
child: const Text("Sayfa3 ye git"),
),
],
),
);
}
}
class Sayfa2 extends StatelessWidget {
const Sayfa2({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Sayfa2"),
),
body: const Center(
child: Text("Burası Sayfa 2"),
),
);
}
}
class Sayfa3 extends StatelessWidget {
const Sayfa3({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(width: double.infinity),
const Text("Burası Sayfa 3"),
const SizedBox(
height: 30,
),
IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: const Icon(Icons.arrow_back),
)
],
),
);
}
}
Subscribe to:
Posts (Atom)