Skip to content

Instantly share code, notes, and snippets.

@rubywai
Created May 9, 2023 06:40
Show Gist options
  • Select an option

  • Save rubywai/032d67c9418e8bb84195becb705fa661 to your computer and use it in GitHub Desktop.

Select an option

Save rubywai/032d67c9418e8bb84195becb705fa661 to your computer and use it in GitHub Desktop.
//debug release profile
//assets file binary network
//container
// Material , Cupertino
//Stateless .Stateful
//row column wrap container stack
//listview gridview
import 'package:flutter/material.dart';
//asset file network memory
void main() {
runApp( MaterialApp(debugShowCheckedModeBanner: false,
theme: ThemeData.light().copyWith(
inputDecorationTheme: const InputDecorationTheme(
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.blue)
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: Colors.green)
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.indigo)
)
)
),
home: Home()));
}
//List ListView.builder() ListView.separeate()
//gridview
class Home extends StatefulWidget {
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
final TextEditingController _nameController = TextEditingController();
final TextEditingController _phoneController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _addressController = TextEditingController();
bool _reading = false;
bool _football = false;
String _groupValue = '';
String _rdoMale = "Male";
String _rdoFemale = "Female";
bool _openForJob = false;
String _info = '';
//positioned
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Stack Lesson'),
),
body: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 40,vertical: 8),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: _nameController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.person),
labelText: 'Enter your name',
),
),
const SizedBox(height: 10,),
TextField(
controller: _phoneController,
decoration: const InputDecoration(
labelText: 'Enter you phone number',
prefixIcon: Icon(Icons.phone)
),
),
const SizedBox(height: 10,),
TextField(
obscureText: true,
controller: _passwordController,
decoration: const InputDecoration(
suffixIcon: Icon(Icons.visibility),
prefixIcon: Icon(Icons.lock),
labelText: 'Enter your password'
),
),
const SizedBox(height: 10,),
TextField(
controller: _addressController,
textAlign: TextAlign.center,
maxLines: 6,
minLines: 3,
decoration: const InputDecoration(
labelText: 'Enter your address',
prefixIcon: Icon(Icons.map_outlined)
),
),
CheckboxListTile(
title: const Text('Reading'),
value: _reading, onChanged: (bool? isCheck){
setState(() {
if(isCheck!=null) {
_reading = isCheck;
}
});
}),
CheckboxListTile(
checkColor: Colors.red,
controlAffinity: ListTileControlAffinity.platform,
activeColor: Colors.indigo,
title: const Text('Football'),
value: _football, onChanged: (bool? isCheck){
if(isCheck != null){
setState(() {
_football = isCheck;
});
}
}),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Male'),
Radio(
activeColor: Colors.indigo,
value: _rdoMale,
groupValue: _groupValue,
fillColor: MaterialStateProperty.resolveWith((states){
if(states.contains(MaterialState.selected)){
return Colors.indigo;
}
return Colors.yellow;
}),
onChanged: (value){
if(value != null)
{
setState(() {
_groupValue = value;
});
}
})
],),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Female'),
Radio(value: _rdoFemale,
groupValue: _groupValue,
onChanged: (value){
if(value != null)
{
setState(() {
_groupValue = value;
});
}
})
],),
SwitchListTile.adaptive(
activeColor: Colors.green,
inactiveThumbColor: Colors.red,
inactiveTrackColor: Colors.brown,
activeThumbImage: AssetImage('images/clock.png'),
title: Text('Open for Job'),
value: _openForJob,
onChanged: (isOpen){
setState(() {
_openForJob = isOpen;
});
}),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(_info,style: const TextStyle(fontSize: 20,color: Colors.black),),
),
OutlinedButton(onPressed: (){
setState(() {
_info = "Name is ${_nameController.text} \n Phone is ${_phoneController.text}\n"
"Password is ${_passwordController.text}\n"
"Address is ${_addressController.text}\n"
"${hobbies()}\n"
"Gender is $_groupValue\n"
"${_openForJob ? "Open for Job" : ""}";
});
}, child: const Text('Generate Profile'))
],
),
),
),
)
);
}
String hobbies(){
String h = "Hobbies are ";
if(_reading){
h = "$h Reading,";
}
if(_football){
h = "$h Football";
}
return h;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment