text_field.dart 1.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
// Copyright 2014 The Flutter Authors. 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';

import 'use_cases.dart';

class TextFieldUseCase extends UseCase {

  @override
  String get name => 'TextField';

  @override
  String get route => '/text-field';

  @override
  Widget build(BuildContext context) => const _MainWidget();
}

class _MainWidget extends StatelessWidget {
  const _MainWidget();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('TextField'),
      ),
31 32 33 34 35 36 37 38 39 40
      body: ListView(
        children: <Widget>[
          const TextField(
            key: Key('enabled text field'),
            autofocus: true,
            decoration: InputDecoration(
              labelText: 'Email',
              suffixText: '@gmail.com',
              hintText: 'Enter your email',
            ),
41
          ),
42 43 44 45 46 47 48 49 50 51 52
          TextField(
            key: const Key('disabled text field'),
            decoration: const InputDecoration(
              labelText: 'Email',
              suffixText: '@gmail.com',
              hintText: 'Enter your email',
            ),
            enabled: false,
            controller: TextEditingController(text: 'xyz'),
          ),
        ],
53 54 55 56
      ),
    );
  }
}