Created
February 23, 2024 17:22
-
-
Save umrysh/3e55c517151da0e292d4304d82fddd17 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
useMaterial3: true, | |
primarySwatch: Colors.orange, | |
inputDecorationTheme: InputDecorationTheme( | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(8.0), | |
borderSide: BorderSide.none, | |
), | |
filled: true, | |
fillColor: Colors.grey[200], | |
), | |
), | |
home: CreateAccountPage(), | |
); | |
} | |
} | |
class CreateAccountPage extends StatefulWidget { | |
@override | |
_CreateAccountPageState createState() => _CreateAccountPageState(); | |
} | |
class _CreateAccountPageState extends State<CreateAccountPage> { | |
final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); | |
bool _termsAccepted = false; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.white, | |
body: SingleChildScrollView( | |
padding: EdgeInsets.all(24.0), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
SizedBox(height: 60), | |
Text( | |
'Create an Account', | |
style: TextStyle( | |
fontSize: 32, | |
fontWeight: FontWeight.bold, | |
color: Colors.black, | |
), | |
), | |
SizedBox(height: 40), | |
Form( | |
key: _formKey, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
_buildTextFormField('Name', 'Enter your full name'), | |
SizedBox(height: 16), | |
_buildTextFormField('Address', 'Start typing your address'), | |
SizedBox(height: 16), | |
_buildTextFormField('Phone', 'Enter your phone number'), | |
SizedBox(height: 16), | |
_buildTextFormField('Email', 'Enter your email address'), | |
SizedBox(height: 16), | |
_buildTextFormField('Handicap', 'Enter your handicap number'), | |
SizedBox(height: 16), | |
_buildTextFormField('Home Course', 'Enter your home course'), | |
SizedBox(height: 24), | |
Row( | |
children: [ | |
Checkbox( | |
value: _termsAccepted, | |
onChanged: (bool? newValue) { | |
setState(() { | |
_termsAccepted = newValue!; | |
}); | |
}, | |
), | |
Expanded( | |
child: GestureDetector( | |
onTap: () { | |
// TODO: Navigate to Terms and Conditions page | |
}, | |
child: Text( | |
'I agree with the Terms and Conditions', | |
style: TextStyle( | |
color: Colors.black, | |
fontSize: 16, | |
), | |
), | |
), | |
), | |
], | |
), | |
SizedBox(height: 24), | |
ElevatedButton( | |
onPressed: _termsAccepted ? () { | |
if (_formKey.currentState!.validate()) { | |
// TODO: Handle form submission | |
} | |
} : null, | |
style: ElevatedButton.styleFrom( | |
primary: Colors.orange, | |
padding: EdgeInsets.symmetric(vertical: 16), | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.circular(8), | |
), | |
), | |
child: Text( | |
'SIGN UP', | |
style: TextStyle( | |
fontSize: 18, | |
fontWeight: FontWeight.bold, | |
color: Colors.white, | |
), | |
), | |
), | |
SizedBox(height: 16), | |
Center( | |
child: GestureDetector( | |
onTap: () { | |
// TODO: Navigate to Login page | |
}, | |
child: Text( | |
'Already have an account? Login', | |
style: TextStyle( | |
color: Colors.black, | |
fontSize: 16, | |
), | |
), | |
), | |
), | |
], | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
TextFormField _buildTextFormField(String label, String hint) { | |
return TextFormField( | |
decoration: InputDecoration( | |
labelText: label, | |
hintText: hint, | |
), | |
validator: (String? value) { | |
if (value == null || value.isEmpty) { | |
return 'Please enter your $label'; | |
} | |
return null; | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment