Advertisement
shojeeb1943

Ans to the qsn to 2

Nov 29th, 2023
917
0
124 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 7.09 KB | None | 0 0
  1. main.dart file
  2.  
  3. import 'package:flutter/material.dart';
  4. import 'cgpa_display.dart';
  5. import 'login_page.dart';
  6. import 'registration_page.dart';
  7.  
  8. void main() {
  9.   runApp(CGPAApp());
  10. }
  11.  
  12. class CGPAApp extends StatelessWidget {
  13.   @override
  14.   Widget build(BuildContext context) {
  15.     return MaterialApp(
  16.       title: 'CGPA App',
  17.       theme: ThemeData(
  18.         primarySwatch: Colors.blue,
  19.       ),
  20.       initialRoute: '/',
  21.       routes: {
  22.         '/': (context) => HomePage(),
  23.         '/login': (context) => CGPADisplay(), // Directly navigate to CGPADisplay on login
  24.         '/registration': (context) => RegistrationPage(),
  25.         '/cgpaDisplay': (context) => CGPADisplay(),
  26.       },
  27.     );
  28.   }
  29. }
  30.  
  31. class HomePage extends StatelessWidget {
  32.   @override
  33.   Widget build(BuildContext context) {
  34.     return Scaffold(
  35.       appBar: AppBar(
  36.         title: Text('Home'),
  37.       ),
  38.       body: Center(
  39.         child: Column(
  40.           mainAxisAlignment: MainAxisAlignment.center,
  41.           children: <Widget>[
  42.             ElevatedButton(
  43.               onPressed: () {
  44.                 Navigator.pushNamed(context, '/login');
  45.               },
  46.               child: Text('Login'),
  47.             ),
  48.             ElevatedButton(
  49.               onPressed: () {
  50.                 Navigator.pushNamed(context, '/registration');
  51.               },
  52.               child: Text('Registration'),
  53.             ),
  54.           ],
  55.         ),
  56.       ),
  57.     );
  58.   }
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. login_page.dart page
  78.  
  79. import 'package:flutter/material.dart';
  80.  
  81. class LoginPage extends StatelessWidget {
  82.   @override
  83.   Widget build(BuildContext context) {
  84.     return Scaffold(
  85.       appBar: AppBar(
  86.         title: Text('Login'),
  87.       ),
  88.       body: Center(
  89.         child: Column(
  90.           mainAxisAlignment: MainAxisAlignment.center,
  91.           children: [
  92.             // Login form widgets
  93.           ],
  94.         ),
  95.       ),
  96.     );
  97.   }
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. registration_page.dart page
  106.  
  107.  
  108. import 'package:flutter/material.dart';
  109.  
  110. class RegistrationPage extends StatelessWidget {
  111.   @override
  112.   Widget build(BuildContext context) {
  113.     return Scaffold(
  114.       appBar: AppBar(
  115.         title: Text('Register'),
  116.       ),
  117.       body: Center(
  118.         child: Column(
  119.           mainAxisAlignment: MainAxisAlignment.center,
  120.           children: [
  121.             // Registration form widgets
  122.           ],
  123.         ),
  124.       ),
  125.     );
  126.   }
  127. }
  128.  
  129.  
  130.  
  131.  
  132. cgpa_display.dart page
  133.  
  134.  
  135. import 'package:flutter/material.dart';
  136.  
  137. class CGPADisplay extends StatelessWidget {
  138.   final List<double> cgpaList = [
  139.     3.55, 3.96, 3.50, 3.69, 3.68, 3.87, 3.52, 3.94, 3.45, 3.65, 3.87, 3.40
  140.   ];
  141.  
  142.   @override
  143.   Widget build(BuildContext context) {
  144.     return Scaffold(
  145.       appBar: AppBar(
  146.         title: Text('CGPA Display'),
  147.       ),
  148.       body: ListView.builder(
  149.         itemCount: cgpaList.length,
  150.         itemBuilder: (BuildContext context, int index) {
  151.           return ListTile(
  152.             title: Text('Semester ${index + 1}'),
  153.             subtitle: Text('CGPA: ${cgpaList[index]}'),
  154.           );
  155.         },
  156.       ),
  157.     );
  158.   }
  159. }
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. pubspec.yaml files
  167.  
  168. name: cgpa
  169. description: "A new Flutter project."
  170. # The following line prevents the package from being accidentally published to
  171. # pub.dev using `flutter pub publish`. This is preferred for private packages.
  172. publish_to: 'none' # Remove this line if you wish to publish to pub.dev
  173.  
  174. # The following defines the version and build number for your application.
  175. # A version number is three numbers separated by dots, like 1.2.43
  176. # followed by an optional build number separated by a +.
  177. # Both the version and the builder number may be overridden in flutter
  178. # build by specifying --build-name and --build-number, respectively.
  179. # In Android, build-name is used as versionName while build-number used as versionCode.
  180. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
  181. # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
  182. # Read more about iOS versioning at
  183. # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
  184. # In Windows, build-name is used as the major, minor, and patch parts
  185. # of the product and file versions while build-number is used as the build suffix.
  186. version: 1.0.0+1
  187.  
  188. environment:
  189.   sdk: '>=3.2.0 <4.0.0'
  190.  
  191. # Dependencies specify other packages that your package needs in order to work.
  192. # To automatically upgrade your package dependencies to the latest versions
  193. # consider running `flutter pub upgrade --major-versions`. Alternatively,
  194. # dependencies can be manually updated by changing the version numbers below to
  195. # the latest version available on pub.dev. To see which dependencies have newer
  196. # versions available, run `flutter pub outdated`.
  197. dependencies:
  198.   flutter:
  199.     sdk: flutter
  200.   flutter_bloc: ^8.0.0 # Replace with the version you need
  201.  
  202.  
  203.  
  204.   # The following adds the Cupertino Icons font to your application.
  205.   # Use with the CupertinoIcons class for iOS style icons.
  206.   cupertino_icons: ^1.0.2
  207.  
  208. dev_dependencies:
  209.   flutter_test:
  210.     sdk: flutter
  211.  
  212.   # The "flutter_lints" package below contains a set of recommended lints to
  213.   # encourage good coding practices. The lint set provided by the package is
  214.   # activated in the `analysis_options.yaml` file located at the root of your
  215.   # package. See that file for information about deactivating specific lint
  216.   # rules and activating additional ones.
  217.   flutter_lints: ^2.0.0
  218.  
  219. # For information on the generic Dart part of this file, see the
  220. # following page: https://dart.dev/tools/pub/pubspec
  221.  
  222. # The following section is specific to Flutter packages.
  223. flutter:
  224.  
  225.   # The following line ensures that the Material Icons font is
  226.   # included with your application, so that you can use the icons in
  227.   # the material Icons class.
  228.   uses-material-design: true
  229.  
  230.   # To add assets to your application, add an assets section, like this:
  231.   # assets:
  232.   #   - images/a_dot_burr.jpeg
  233.   #   - images/a_dot_ham.jpeg
  234.  
  235.   # An image asset can refer to one or more resolution-specific "variants", see
  236.   # https://flutter.dev/assets-and-images/#resolution-aware
  237.  
  238.   # For details regarding adding assets from package dependencies, see
  239.   # https://flutter.dev/assets-and-images/#from-packages
  240.  
  241.   # To add custom fonts to your application, add a fonts section here,
  242.   # in this "flutter" section. Each entry in this list should have a
  243.   # "family" key with the font family name, and a "fonts" key with a
  244.   # list giving the asset and other descriptors for the font. For
  245.   # example:
  246.   # fonts:
  247.   #   - family: Schyler
  248.   #     fonts:
  249.   #       - asset: fonts/Schyler-Regular.ttf
  250.   #       - asset: fonts/Schyler-Italic.ttf
  251.   #         style: italic
  252.   #   - family: Trajan Pro
  253.   #     fonts:
  254.   #       - asset: fonts/TrajanPro.ttf
  255.   #       - asset: fonts/TrajanPro_Bold.ttf
  256.   #         weight: 700
  257.   #
  258.   # For details regarding fonts from package dependencies,
  259.   # see https://flutter.dev/custom-fonts/#from-packages
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement