Flutter App1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

1. import 'package:flutter/cupertino.

dart';
2. import 'package:flutter/material.dart';
3.
4. void main() {
5. runApp(MyApp());
6. }
7.
8. //void main() => runApp(MyApp());
9. class MyApp extends StatefulWidget {
10. @override
11. _MyAppState createState() => _MyAppState();
12. }
13.
14. class _MyAppState extends State<MyApp> {
15. var questionIndex= 0;
16.
17. void answerQuestions() {
18. setState(() {
19. questionIndex=questionIndex +1;
20. });
21. }
22.
23. @override
24. Widget build(BuildContext context) {
25. var questions = [
26. 'What\'s fevourite color?',
27. 'WHat\'s your favourite animals?'
28. ];
29. return MaterialApp(
30. home: Scaffold(
31. appBar: AppBar(
32. title: Text('My First App'),
33. ),
34. body: Column(
35. children: [
36. Text(
37. questions[questionIndex],
38. ),
39. RaisedButton(
40. child: Text('Ans 1'),
41. onPressed:()=>print('Chosen3'),
42. ),
43. RaisedButton(
44. child: Text('Ans 2'),
45. onPressed: () => print('answerQuestions,'),
46. ),
47. RaisedButton(
48. child: Text('Ans 3'),
49. onPressed: () {
50. print('ANs 3 Choosen');
51. },
52. ),
53. ],
54. ),
55. ),
56. );
57. }
58. }

You might also like