Skip to content

Instantly share code, notes, and snippets.

@esouthren
Created January 16, 2023 14:10
Show Gist options
  • Save esouthren/4d3d979fd0ff6b00823573c9d7e0d609 to your computer and use it in GitHub Desktop.
Save esouthren/4d3d979fd0ff6b00823573c9d7e0d609 to your computer and use it in GitHub Desktop.
TextField disabled example
// 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.
// Flutter code sample for [TextFormField].
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
final theme = ThemeData.light(useMaterial3: true);
return MaterialApp(
theme: theme.copyWith(
textTheme: theme.textTheme,
),
// Interestingly, we can override the input value via subtitle1's color.
// .copyWith(subtitle1: const TextStyle(color: Colors.purple))),
title: _title,
home: MyWidget(),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Center(
child: TextField(
controller: TextEditingController(text: 'this text should be in disabled style'),
decoration: const InputDecoration(
enabled: false,
icon: Icon(Icons.person),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment