Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'dart:ui';
  3.  
  4. import 'colleges.dart';
  5.  
  6. void main() => runApp(MyApp());
  7.  
  8. class MyApp extends StatelessWidget {
  9. // This widget is the root of your application.
  10. @override
  11. Widget build(BuildContext context) {
  12. return MaterialApp(
  13. title: 'Flutter Demo',
  14. theme: ThemeData(
  15. // This is the theme of your application.
  16. //
  17. // Try running your application with "flutter run". You'll see the
  18. // application has a blue toolbar. Then, without quitting the app, try
  19. // changing the primarySwatch below to Colors.green and then invoke
  20. // "hot reload" (press "r" in the console where you ran "flutter run",
  21. // or simply save your changes to "hot reload" in a Flutter IDE).
  22. // Notice that the counter didn't reset back to zero; the application
  23. // is not restarted.
  24. primarySwatch: Colors.blue,
  25. ),
  26. home: MyHomePage(title: 'Ishtiaq'),
  27. );
  28. }
  29. }
  30. // Ishtiaq Mahmud
  31. class MyHomePage extends StatefulWidget {
  32. MyHomePage({Key key, this.title}) : super(key: key);
  33.  
  34. // This widget is the home page of your application. It is stateful, meaning
  35. // that it has a State object (defined below) that contains fields that affect
  36. // how it looks.
  37.  
  38. // This class is the configuration for the state. It holds the values (in this
  39. // case the title) provided by the parent (in this case the App widget) and
  40. // used by the build method of the State. Fields in a Widget subclass are
  41. // always marked "final".
  42.  
  43. final String title;
  44.  
  45. @override
  46. _MyHomePageState createState() => _MyHomePageState();
  47. }
  48.  
  49. class _MyHomePageState extends State<MyHomePage> {
  50. int _counter = 0;
  51.  
  52. void _incrementCounter() {
  53. setState(() {
  54. // This call to setState tells the Flutter framework that something has
  55. // changed in this State, which causes it to rerun the build method below
  56. // so that the display can reflect the updated values. If we changed
  57. // _counter without calling setState(), then the build method would not be
  58. // called again, and so nothing would appear to happen.
  59. _counter++;
  60. });
  61. }
  62.  
  63. @override
  64. Widget build(BuildContext context) {
  65. // This method is rerun every time setState is called, for instance as done
  66. // by the _incrementCounter method above.
  67. //
  68. // The Flutter framework has been optimized to make rerunning build methods
  69. // fast, so that you can just rebuild anything that needs updating rather
  70. // than having to individually change instances of widgets.
  71. return Scaffold(
  72. appBar: AppBar(
  73. // Here we take the value from the MyHomePage object that was created by
  74. // the App.build method, and use it to set our appbar title.
  75. title: Text(widget.title),
  76. ),
  77. body: Center (child: Row(
  78. mainAxisAlignment: MainAxisAlignment.spaceAround,
  79. children: <Widget>[
  80. Column(
  81. mainAxisAlignment: MainAxisAlignment.spaceAround,
  82. children: <Widget>[
  83. CollegeButton(collegename:'WSU', collegewiget:Wsu(),),
  84. CollegeButton(collegename:'OU', collegewiget:Ou(),),
  85. CollegeButton(collegename:'OSU', collegewiget:Osu(),),
  86. CollegeButton(collegename:'KU', collegewiget:Ku(),),
  87. CollegeButton(collegename:'MIT', collegewiget:Mit(),),
  88. ],
  89. ),
  90. Column(
  91. mainAxisAlignment: MainAxisAlignment.spaceAround,
  92. children: <Widget>[
  93.  
  94. CollegeButton(collegename:'CUNY', collegewiget:Cuny(),),
  95. CollegeButton(collegename:'NYU', collegewiget:Nyu(),),
  96. CollegeButton(collegename:'OPSU', collegewiget:Opsu(),),
  97. CollegeButton(collegename:'RICE', collegewiget:Rice(),),
  98. CollegeButton(collegename:'BROWN', collegewiget:Brown(),),
  99. ],
  100. ),//
  101. Column(
  102. mainAxisAlignment: MainAxisAlignment.spaceAround,
  103. children: <Widget>[
  104.  
  105. CollegeButton(collegename:'ISU', collegewiget:Isu(),),
  106. CollegeButton(collegename:'DUKE', collegewiget:Duke(),),
  107. CollegeButton(collegename:'UTULSA', collegewiget:Utulsa(),),
  108. CollegeButton(collegename:'BC', collegewiget:Bc(),),
  109. CollegeButton(collegename:'SUNY', collegewiget:Suny(),),
  110. ],
  111. ),
  112. ],
  113. )),
  114. );
  115. }
  116. }
  117.  
  118. class CollegeButton extends StatelessWidget{
  119. final String collegename;
  120. final Widget collegewiget;
  121. final Color color;
  122. CollegeButton({this.collegename, this.collegewiget,
  123. this.color = Colors.blueGrey});
  124. // Ishtiaq Mahmud-----
  125. @override
  126. Widget build(BuildContext context) {
  127. // TODO: implement build
  128. return Container(padding: EdgeInsets.fromLTRB(1, 1, 1, 1),
  129. decoration: BoxDecoration(color: Colors.deepPurple),
  130. width: 100,
  131. height: 40,
  132. child: FlatButton(child: Text(collegename),
  133. onPressed: ()=> Navigator.push(context,
  134. MaterialPageRoute(
  135. builder: (BuildContext context) => collegewiget
  136. )), ),
  137. );
  138. }
  139.  
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement