Skip to content

Commit

Permalink
Update text field example 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sunarya-thito committed Nov 24, 2024
1 parent 98d443d commit 8850a0b
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions docs/lib/pages/docs/components/input/input_example_2.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
import 'package:shadcn_flutter/shadcn_flutter.dart';

class InputExample2 extends StatelessWidget {
class InputExample2 extends StatefulWidget {
const InputExample2({super.key});

@override
State<InputExample2> createState() => _InputExample2State();
}

class _InputExample2State extends State<InputExample2> {
final TextEditingController _searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return const TextField(
return TextField(
controller: _searchController,
initialValue: 'Hello World!',
placeholder: Text('Enter your message'),
placeholder: Text('Search something...'),
leading: StatedWidget.builder(
builder: (context, states) {
if (states.focused) {
return Icon(Icons.search);
} else {
return Icon(Icons.search).iconMutedForeground();
}
},
),
trailing: IconButton.text(
icon: Icon(Icons.close),
density: ButtonDensity.compact,
onPressed: () {
_searchController.clear();
},
),
);
}
}

0 comments on commit 8850a0b

Please sign in to comment.