Advertisement
Jaagdish47

MobileApp_ImplementDifferentWidgets

Nov 26th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.62 KB | Source Code | 0 0
  1. //2A main.dart
  2. import 'package:flutter/material.dart';
  3. class nextpage extends StatelessWidget {
  4. String name, email, phoneno;
  5. // Constructor to get the data from the previous page.
  6. nextpage({required this.name, required this.email, required this.phoneno});
  7. @override
  8. Widget build(BuildContext context) {
  9. // To listen to the changes in the textfield.
  10. TextEditingController _name = TextEditingController(text: name);
  11. TextEditingController _email = TextEditingController(text: email);
  12. TextEditingController _phoneno = TextEditingController(text: phoneno);
  13. return Scaffold(
  14. appBar: AppBar(
  15. title: Text('Next Page'),
  16. ),
  17. body: Center(
  18. child: Column(
  19. mainAxisAlignment: MainAxisAlignment.center,
  20. children: [
  21. Padding(
  22. padding: const EdgeInsets.all(25),
  23. child: TextField(
  24. // To set the appropriate controller to the text field.
  25. controller: _name,
  26. decoration: InputDecoration(
  27. border: OutlineInputBorder(),
  28. labelText: "Name",
  29. ),
  30. ),
  31. ),
  32. Padding(
  33. padding: const EdgeInsets.all(25),
  34. child: TextField(
  35. controller: _email,
  36. decoration: InputDecoration(
  37. border: OutlineInputBorder(),
  38. labelText: "Email",
  39. ),
  40. ),
  41. ),
  42. Padding(
  43. padding: const EdgeInsets.all(25),
  44. child: TextField(
  45. controller: _phoneno,
  46. decoration: InputDecoration(
  47. border: OutlineInputBorder(),
  48. labelText: "Number",
  49. ),
  50. ),
  51. ),
  52. ],
  53. ),
  54. ),
  55. );
  56. }
  57. }
  58.  
  59. //2B. nextpage.dart
  60.  
  61. import 'package:flutter/material.dart';
  62. class nextpage extends StatelessWidget {
  63. String name, email, phoneno;
  64. // Constructor to get the data from the previous page.
  65. nextpage({required this.name, required this.email, required this.phoneno});
  66. @override
  67. Widget build(BuildContext context) {
  68. // To listen to the changes in the textfield.
  69. TextEditingController _name = TextEditingController(text: name);
  70. TextEditingController _email = TextEditingController(text: email);
  71. TextEditingController _phoneno = TextEditingController(text: phoneno);
  72. return Scaffold(
  73. appBar: AppBar(
  74. title: Text('Next Page'),
  75. ),
  76. body: Center(
  77. child: Column(
  78. mainAxisAlignment: MainAxisAlignment.center,
  79. children: [
  80. Padding(
  81. padding: const EdgeInsets.all(25),
  82. child: TextField(
  83. // To set the appropriate controller to the text field.
  84. controller: _name,
  85. decoration: InputDecoration(
  86. border: OutlineInputBorder(),
  87. labelText: "Name",
  88. ),
  89. ),
  90. ),
  91. Padding(
  92. padding: const EdgeInsets.all(25),
  93. child: TextField(
  94. controller: _email,
  95. decoration: InputDecoration(
  96. border: OutlineInputBorder(),
  97. labelText: "Email",
  98. ),
  99. ),
  100. ),
  101. Padding(
  102. padding: const EdgeInsets.all(25),
  103. child: TextField(
  104. controller: _phoneno,
  105. decoration: InputDecoration(
  106. border: OutlineInputBorder(),
  107. labelText: "Number",
  108. ),
  109. ),
  110. ),
  111. ],
  112. ),
  113. ),
  114. );
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement