Skip to content

Instantly share code, notes, and snippets.

@umrysh
Created February 23, 2024 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umrysh/3e55c517151da0e292d4304d82fddd17 to your computer and use it in GitHub Desktop.
Save umrysh/3e55c517151da0e292d4304d82fddd17 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
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