Open berkeresvan opened 7 months ago
import 'package:flutter/material.dart';
class Sayfa1 extends StatelessWidget { const Sayfa1({super.key});
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text("Statless Widget"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [Text("merhaba")], ), )); } }
import 'package:flutter/material.dart'; import 'package:statlesswidget/sayfa1.dart';
void main() { runApp(const MyApp()); }
class MyApp extends StatelessWidget { const MyApp({super.key});
@override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: Sayfa1(), ); } }
class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title});
final String title;
@override State createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
int sayac = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
setState(() {
sayac = sayac + 1;
});
},
child: Text("Tıkla")),
Text("sonuç: $sayac")
],
),
));
}
}