Skip to content

Instantly share code, notes, and snippets.

@jamesshah
Created August 9, 2020 05:58
Show Gist options
  • Save jamesshah/8fbbee656343852a52aebec9da7dc984 to your computer and use it in GitHub Desktop.
Save jamesshah/8fbbee656343852a52aebec9da7dc984 to your computer and use it in GitHub Desktop.
MCWC Practical 6
final String mcwc = "MCWC";
final String ins = "INS";
final String dmbi = "DMBI";
String book;
final List<String> mcwcList = [
'Wireless Communications & Networks by Pearson',
'Mobile ComputingTechnology,Applications and service creation by TMH',
'Android Application Development Black Book by dreamtech press',
'Wireless and mobile networks by WILEY',
'Mobile Computing Theory and Practice-Kumkum Garg-Pearson'
];
final List<String> insList = [
'Cryptography And Network Security by Pearson',
'Information Security Principles and Practice By Willy India Edition',
'Cryptography & Network Security, McGrawHill',
'Cryptography and Network Security, TMH',
'Cryptography and Security, Wiley-India'
];
final List<String> dmbiList = [
'Data Mining Concepts and Techniques, Morgan Kaufmann',
'Data mining: Concepts, models, methods and algorithms, John Wiley &Sons Inc',
'Data Warehousing Fundamentals, John Willey',
'Data Mining: Introductory and Advanced Topics, Pearson Education',
'Data Mining for Business Intelligence, Wiley India'
];
import 'package:flutter/material.dart';
import 'bookList.dart';
void main() {
runApp(MaterialApp(
home: Home(),
debugShowCheckedModeBanner: false,
));
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
final textController = TextEditingController();
String name;
String subject;
String bookName;
String _char = mcwc;
List<String> getBooksFromSub(_char) {
switch (_char) {
case "MCWC":
return mcwcList;
break;
case "INS":
return insList;
break;
case "DMBI":
return dmbiList;
break;
default:
print("Enter valid sub");
break;
}
}
@override
void dispose() {
textController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Practical 6"),
centerTitle: true,
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: textController,
decoration: InputDecoration(hintText: "Enter your name"),
),
SizedBox(
height: 20,
),
Text("Select Subject"),
SizedBox(
height: 20,
),
ListTile(
title: Text(mcwc),
leading: Radio(
value: mcwc,
groupValue: _char,
onChanged: (value) => setState(() => _char = value),
),
),
ListTile(
title: Text(ins),
leading: Radio(
value: ins,
groupValue: _char,
onChanged: (value) => setState(() => _char = value),
),
),
ListTile(
title: Text(dmbi),
leading: Radio(
value: dmbi,
groupValue: _char,
onChanged: (value) => setState(() => _char = value),
),
),
SizedBox(
height: 20,
),
DropdownButton<String>(
isExpanded: true,
itemHeight: null,
hint: Text("Select Book"),
value: bookName,
iconSize: 24,
onChanged: (String val) {
setState(() {
bookName = val;
});
},
items: getBooksFromSub(_char).map((String name) {
return DropdownMenuItem(
child: Text(name),
value: name,
onTap: () => book = name,
);
}).toList(),
),
SizedBox(
height: 20,
),
Center(
child: RaisedButton(
child: Text("Submit"),
onPressed: () {
_showMyDialog();
}),
)
],
),
),
),
);
}
Future<void> _showMyDialog() async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('Your Data'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(
'Name: ${textController.text}',
style: TextStyle(
fontWeight: FontWeight.bold
)
),
SizedBox(height: 5,),
Text(
'Subject: $_char',
style: TextStyle(
fontWeight: FontWeight.bold
)
),
SizedBox(height: 5,),
Text(
'Book: $bookName',
style: TextStyle(
fontWeight: FontWeight.bold
)
)
],
),
),
actions: <Widget>[
FlatButton(
child: Text('Okay'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment