how to create a widget in a flutter

how to create a widget in a flutter

 how to create a widget in a flutter





Introduction to widgets

Flutter widgets are built using a modern framework that takes inspiration from React. The central idea is that you build your UI out of widgets. Widgets describe what their view should look like given their current configuration and state more info.


Create a Widget in below 


  

Widget txtBox1() {

  return Center(
child: Container( margin: EdgeInsets.symmetric(vertical: 5, horizontal: 3), alignment: Alignment.center, height: MediaQuery.of(context).size.height / 15, width: MediaQuery.of(context).size.width / 10, child: TextFormField( autofocus: true, textAlign: TextAlign.center, keyboardType: TextInputType.number, controller: AllControllers.teOtpDigitOne, textInputAction: TextInputAction.next, onChanged: (_) => FocusScope.of(context).nextFocus(), maxLength: 1, decoration: InputDecoration( errorStyle: TextStyle(height: 0), counterText: '', contentPadding: const EdgeInsets.all(5)), validator: (value) { if (value == null || value.isEmpty) { Fluttertoast.showToast( msg: "Please Enter OTP", toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.TOP, timeInSecForIosWeb: 1, backgroundColor: Colors.red, textColor: Colors.white, fontSize: 13.0); return ''; } return null; }, ), decoration: BoxDecoration( border: Border( left: BorderSide( color: Colors.white, width: 3.0, ), top: BorderSide( color: Colors.white, width: 3.0, ), ), ), ), ); }



Post a Comment

Previous Post Next Post

Design a beautiful Login/Signup (with google map) in Flutter | Flutter UI | VS Code | iOS Android