kodlarım şu şekilde
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
/*import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';*/
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
/* final GlobalKey<ScaffoldState> _scaffoldkey = new GlobalKey<ScaffoldState>();
_showSnackBar(){
final snackBar = new SnackBar(
content: new Text('Silmek istiyotmusun'),
duration: new Duration(seconds: 2),
backgroundColor: Colors.red,
action: new SnackBarAction(label: 'evet', onPressed: null),
);
}*/
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'zikirmatik',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.green,
// This makes the visual density adapt to the platform that you run
// the app on. For desktop platforms, the controls will be smaller and
// closer together (more dense) than on mobile platforms.
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter ZİKİRMATİK'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
final snackBar =SnackBar(
content: Text("Bu Benim İlk Mesajım."),
backgroundColor: Colors.red,
action: SnackBarAction(
textColor: Colors.white,
label: "Test Butonu",
onPressed: (){
// Buraya Butona Tıklayınca Yapılacak Olaylar Yazılacak.
},
),
);
void _incrementCounter() {
setState(() {
_counter++;
});
}
void sifirla() {
setState(() {
/* Fluttertoast.showToast(
msg: "Sıfırlamak İstediğine Emin Misin ?!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 2,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 20.0,
);*/
_counter=0;
});
}
void _incrementCounter1() {
setState(() {
if(_counter>0)
_counter--;
});
}
@override
Widget build(BuildContext context) {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
Scaffold(
key:_scaffoldKey,
);
/*final snackBar =SnackBar(
content: Text("sıfırlamak istediğinden emin misin"),
backgroundColor: Colors.red,
action: SnackBarAction(
textColor: Colors.white,
label: 'evet',
onPressed: (){
sifirla();
},
),
);*/
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
centerTitle: true,
),
body:
Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children:
<Widget>[
Image(
image: NetworkImage('http://ilerleyen.com.tr/Content/img/ilerleyen-teknoloji-logo.png'), width: 200,height: 150, alignment:Alignment.topLeft,
/// istersem şu şekildede olabilir Image.network('source'),|| Image.asset('sorç') şeklinde
),
Text(
'Aşağıdaki butonlara tıkladığınızda zikirmatiğiniz çalışacaktır', style: TextStyle(fontSize: 22,fontWeight: FontWeight.bold, ) , textAlign: TextAlign.center,
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline2, textAlign: TextAlign.center,
),
RaisedButton(
onPressed: (){
final snackBar = SnackBar(
content: Text('Yay! A SnackBar!'),
action: SnackBarAction(
label: 'Undo',
onPressed: () {
// Some code to undo the change.
},
),
);
// Find the Scaffold in the widget tree and use
// it to show a SnackBar.
_scaffoldKey.currentState.showSnackBar(snackBar);
},
color: Colors.red,
child: Text('Sıfırla'),
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 35),
splashColor: Colors.green ,
),
],
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Zikiri Arttır',
child: Icon(Icons.thumb_up),
mini: false,
),
FloatingActionButton(
onPressed: _incrementCounter1,
splashColor: Colors.green,
tooltip: 'Zikiri Azalt',
child: Icon(Icons.thumb_down), focusColor: Colors.blueGrey,
mini: false,
backgroundColor: Colors.red,
),
]
)); }
}