Created
April 28, 2019 00:29
-
-
Save OmarSalah26/a9327bb2725fa53b58895c51c026d4d4 to your computer and use it in GitHub Desktop.
flutter second sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
main() { | |
runApp(MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Home(), | |
)); | |
} | |
class Home extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() { | |
// TODO: implement createState | |
return new _HomeState(); | |
} | |
} | |
class _HomeState extends State<Home> { | |
String name = ''; | |
bool value1 = true; | |
bool value2 = false; | |
bool value3 = true; | |
bool value4 = false; | |
bool value5 = true; | |
void onChangeValue1(bool value) { | |
setState(() { | |
value1 = value; | |
}); | |
} | |
int al = 0; | |
void conut() { | |
setState(() { | |
al = al + 1; | |
}); | |
} | |
void onChangeValue2(bool value) { | |
setState(() { | |
value2 = value; | |
}); | |
} | |
void onChangeValue3(bool value) { | |
setState(() { | |
value3 = value; | |
}); | |
} | |
void onChangeValue4(bool value) { | |
setState(() { | |
value4 = value; | |
}); | |
} | |
void onChangeValue5(bool value) { | |
setState(() { | |
value5 = value; | |
}); | |
} | |
onChangeValue(String value) { | |
setState(() { | |
name = "on change $value"; | |
}); | |
} | |
onsubmitValue(String value) { | |
setState(() { | |
name = "on submit $value"; | |
}); | |
} | |
int a = 0; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('textandstateful_app'), | |
centerTitle: true, | |
), | |
body: Container( | |
padding: EdgeInsets.all(22.6), | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
TextField( | |
autocorrect: true, | |
autofocus: true, | |
keyboardType: TextInputType.text, | |
decoration: InputDecoration( | |
icon: Icon( | |
Icons.perm_identity, | |
size: 80, | |
), | |
hintText: 'hi', | |
labelText: 'welcome'), | |
onChanged: onChangeValue, | |
onSubmitted: onsubmitValue, | |
), | |
Text( | |
"$name ", | |
style: TextStyle(fontSize: 20), | |
), | |
Checkbox( | |
value: value1, | |
onChanged: onChangeValue1, | |
), | |
Checkbox(value: value2, onChanged: onChangeValue2), | |
CheckboxListTile( | |
value: value3, | |
onChanged: onChangeValue3, | |
title: Text('how are you'), | |
activeColor: Colors.deepPurpleAccent, | |
subtitle: Text('hi sub title how are you'), | |
secondary: Icon(Icons.airline_seat_individual_suite), | |
), | |
Switch( | |
value: value4, | |
onChanged: onChangeValue4, | |
activeTrackColor: Colors.black, | |
), | |
SwitchListTile( | |
value: value5, | |
onChanged: onChangeValue5, | |
title: Text('hi switch'), | |
secondary: Icon(Icons.score), | |
subtitle: Text('hi sub switch'), | |
activeColor: Colors.greenAccent, | |
), | |
Text('$al yaaaaa hpepy'), | |
], | |
), | |
), | |
drawer: Drawer( | |
child: Column( | |
children: <Widget>[ | |
Container( | |
color: Colors.greenAccent, | |
padding: EdgeInsets.all(30), | |
margin: EdgeInsets.only(top: 300), | |
child: TextField( | |
decoration: InputDecoration( | |
icon: Icon(Icons.airplanemode_active), | |
labelText: 'welcome'), | |
), | |
), | |
IconButton( | |
icon: Icon(Icons.score), | |
onPressed: () => debugPrint("welcome back"), | |
color: Colors.deepPurpleAccent, | |
), | |
FlatButton( | |
onPressed: conut, | |
child: Text('counter $al'), | |
color: Colors.amberAccent, | |
shape: CircleBorder(side: BorderSide(color: Colors.pink)), | |
), | |
FlatButton( | |
onPressed: () => Navigator.pop(context), | |
child: Icon(Icons.close, | |
color: Colors.redAccent, textDirection: TextDirection.ltr), | |
), | |
RaisedButton( | |
onPressed: () => print('welcome'), | |
child: Icon(Icons.add_shopping_cart), | |
textTheme: ButtonTextTheme.accent, | |
), | |
RaisedButton( | |
padding: EdgeInsets.all(100), | |
onPressed: conut, | |
child: Icon(Icons.add_shopping_cart), | |
textTheme: ButtonTextTheme.accent, | |
), | |
Text('$al yaaaaa hpepy'), | |
], | |
), | |
), | |
floatingActionButton: FloatingActionButton(onPressed:conut ,child: Icon(Icons.access_time),), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment