import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Bug'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _hidden = true;
void _changeVisibility() {
setState(() {
_hidden = !_hidden;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Container(
width: 300,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
obscureText: _hidden,
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(0),
prefixIcon: Icon(Icons.lock_outline),
border: const OutlineInputBorder(),
labelText: "labelText",
suffixIcon: GestureDetector(
onTap: () {
_changeVisibility();
},
child: Icon(_hidden ? Icons.visibility_off : Icons.visibility),
),
),
),
],
),
),
),
);
}
}
or hide all of the characters.
[√] Flutter (Channel beta, 1.24.0-10.2.pre, on Microsoft Windows [Version 10.0.19042.685], locale en-GB)
• Flutter version 1.24.0-10.2.pre at D:\Flutter
• Framework revision 022b333a08 (5 weeks ago), 2020-11-18 11:35:09 -0800
• Engine revision 07c1eed46b
• Dart version 2.12.0 (build 2.12.0-29.10.beta)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at D:\Android\SDK
• Platform android-30, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 50.0.1
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code, 64-bit edition (version 1.52.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.17.0
[√] Connected device (1 available)
• SM G960U1 (mobile) • 3054524d4a313498 • android-arm64 • Android 10 (API 29)
• No issues found!
Steps to Reproduce
flutter create bug.Expected results:
when its state changes, it must show all
bug-2020-12-22-224631.mp4
or hide all of the characters.