mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
move experimental/form_app to root of project (#623)
This allows us to reference this sample from other places. See https://github.com/flutter/flutter/pull/70321 for more context.
This commit is contained in:
105
form_app/lib/src/autofill.dart
Normal file
105
form_app/lib/src/autofill.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// Demonstrates how to use autofill hints. The full list of hints is here:
|
||||
// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/text_editing/autofill_hint.dart
|
||||
class AutofillDemo extends StatefulWidget {
|
||||
@override
|
||||
_AutofillDemoState createState() => _AutofillDemoState();
|
||||
}
|
||||
|
||||
class _AutofillDemoState extends State<AutofillDemo> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Autofill'),
|
||||
),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: Scrollbar(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: AutofillGroup(
|
||||
child: Column(
|
||||
children: [
|
||||
...[
|
||||
Text('This sample demonstrates autofill. '),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Jane',
|
||||
labelText: 'First Name',
|
||||
),
|
||||
autofillHints: [AutofillHints.givenName],
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Doe',
|
||||
labelText: 'Last Name',
|
||||
),
|
||||
autofillHints: [AutofillHints.familyName],
|
||||
),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'foo@example.com',
|
||||
labelText: 'Email',
|
||||
),
|
||||
autofillHints: [AutofillHints.email],
|
||||
),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '(123) 456-7890',
|
||||
labelText: 'Telephone',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.telephoneNumber],
|
||||
),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '123 4th Ave',
|
||||
labelText: 'Street Address',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.streetAddressLine1],
|
||||
),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '12345',
|
||||
labelText: 'Postal Code',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.postalCode],
|
||||
),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: 'United States',
|
||||
labelText: 'Country',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.countryName],
|
||||
),
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
hintText: '1',
|
||||
labelText: 'Country Code',
|
||||
),
|
||||
autofillHints: <String>[AutofillHints.countryCode],
|
||||
),
|
||||
].expand(
|
||||
(widget) => [
|
||||
widget,
|
||||
SizedBox(
|
||||
height: 24,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user