1) Validaie form fields to make sure they are not empily (2) Usen vavigator to transfer daia from Form screen to Confirm

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

1) Validaie form fields to make sure they are not empily (2) Usen vavigator to transfer daia from Form screen to Confirm

Post by answerhappygod »

1 Validaie Form Fields To Make Sure They Are Not Empily 2 Usen Vavigator To Transfer Daia From Form Screen To Confirm 1
1 Validaie Form Fields To Make Sure They Are Not Empily 2 Usen Vavigator To Transfer Daia From Form Screen To Confirm 1 (1.17 MiB) Viewed 31 times
I need help making a Form in Flutter Android Studio, I can makemultiple pages but I don't know how to add forms to them other thana button that takes me to the next page. Here is my code sofar...
import 'package:flutter/material.dart';
void main() { runApp(MaterialApp( initialRoute: '/home', routes: { '/home': (context) => constMyCustomForm(), '/second': (context) => constSecondRoute(), }, ));}
//Page 1 / Homeclass MyCustomForm extends StatefulWidget { const MyCustomForm({super.key});
@override MyCustomFormState createState() { return MyCustomFormState(); }}
// Create a corresponding State class.// This class holds data related to the form.class MyCustomFormState extends State<MyCustomForm> { // Create a global key that uniquely identifies the Formwidget // and allows validation of the form. // // Note: This is a GlobalKey<FormState>, // not a GlobalKey<MyCustomFormState>. final _formKey = GlobalKey<FormState>();
@override Widget build(BuildContext context) { // Build a Form widget using the _formKey createdabove. return Form( key: _formKey, child: Column( crossAxisAlignment:CrossAxisAlignment.start, children: [ TextFormField( // The validator receivesthe text that the user has entered. validator: (value){ if (value == null|| value.isEmpty) { return'Please enter some text'; } return null; }, ), Padding( padding: constEdgeInsets.symmetric(vertical: 16.0), child:ElevatedButton( child:const Text('Submit'), style:ElevatedButton.styleFrom(primary: Colors.blue), onPressed:() { Navigator.pushNamed(context, '/second'); }), ), ], ), ); }}
// Page 2class SecondRoute extends StatelessWidget { const SecondRoute({Key? key}) : super(key: key);
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: constText('Conformation'), backgroundColor: Colors.black, ), body: Center( child: Column( mainAxisAlignment:MainAxisAlignment.end, children: <Widget>[ ElevatedButton( child: constText('Back'), style:ElevatedButton.styleFrom(primary: Colors.blue), onPressed: (){ Navigator.pushNamed(context, '/home'); }, ), ], ), ), ); }}
1) Validaie form fields to make sure they are not empily (2) Usen vavigator to transfer daia from Form screen to Confirmation Sereen. 3) New triry shall navicate to an emply form i.e., nodisplaying prior entry)

Guest Book
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply