-
Notifications
You must be signed in to change notification settings - Fork 180
Expand file tree
/
Copy pathsample3.dart
More file actions
59 lines (56 loc) · 1.88 KB
/
sample3.dart
File metadata and controls
59 lines (56 loc) · 1.88 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import 'package:flutter/material.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
/// Sample [Widget] demonstrating the usage of [KeyboardActionsConfig.defaultDoneWidget].
class Sample3 extends StatelessWidget {
final _focusNodes =
Iterable<int>.generate(7).map((_) => FocusNode()).toList();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Sample 3"),
),
body: Padding(
padding: const EdgeInsets.only(top: 15.0, left: 15.0, right: 15.0),
child: Center(
child: KeyboardActions(
tapOutsideBehavior: TapOutsideBehavior.translucentDismiss,
config: KeyboardActionsConfig(
// Define ``defaultDoneWidget`` only once in the config
defaultDoneWidget: _buildMyDoneWidget(),
actions: _focusNodes
.map((focusNode) => KeyboardActionsItem(focusNode: focusNode))
.toList(),
),
child: ListView.separated(
itemBuilder: (ctx, idx) => TextField(
focusNode: _focusNodes[idx],
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: "Field ${idx + 1}",
),
),
separatorBuilder: (ctx, idx) => const SizedBox(height: 10.0),
itemCount: _focusNodes.length,
),
),
),
),
);
}
/// Returns the custom [Widget] to be rendered as the *"Done"* button.
Widget _buildMyDoneWidget() {
return Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
Text('My Done Widget'),
const SizedBox(width: 10.0),
Icon(Icons.arrow_drop_down, size: 20.0),
],
),
),
);
}
}