Skip to content

Commit e239c4e

Browse files
committed
Update README.md
1 parent a024982 commit e239c4e

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ A simple, smart and powerful flutter calculator widget.
1313
- **Auto-resize** the formula or result font size to adapt the text box's boundary.
1414
- Supports **undo** and **redo**.
1515
- Supports to relocate and input symbols.
16-
- [**WIP**] Supports to specify the result's precision.
1716

1817
## Getting Started
1918

@@ -24,7 +23,7 @@ dependencies:
2423
flutter_calculator:
2524
git:
2625
url: git://github.com/flytreeleft/flutter_calculator.git
27-
ref: master
26+
ref: bugfix-0.1.x
2827
```
2928
3029
- Import package `import 'package:flutter_calculator/flutter_calculator.dart';` and call `await showCalculator(context: context);` in your code:
@@ -52,18 +51,10 @@ class HomePage extends StatefulWidget {
5251
}
5352
5453
class _HomePageState extends State<HomePage> {
55-
final FocusNode _focusNode = FocusNode();
5654
final TextEditingController _textController = TextEditingController(text: '0.00');
5755
58-
@override
59-
void initState() {
60-
this._focusNode.addListener(this._showCalculatorDialog);
61-
super.initState();
62-
}
63-
6456
@override
6557
void dispose() {
66-
this._focusNode.removeListener(this._showCalculatorDialog);
6758
this._textController.dispose();
6859
super.dispose();
6960
}
@@ -75,21 +66,17 @@ class _HomePageState extends State<HomePage> {
7566
body: TextField(
7667
showCursor: false,
7768
readOnly: true,
78-
focusNode: this._focusNode,
7969
controller: this._textController,
70+
onTap: () => this._showCalculatorDialog(),
8071
),
8172
);
8273
}
8374
8475
void _showCalculatorDialog() async {
85-
if (!this._focusNode.hasFocus) {
86-
return;
87-
}
88-
89-
final result = await showCalculator(context: this.context);
76+
final result = await showCalculator(context: this.context) ?? 0.00;
9077
9178
this._textController.value = this._textController.value.copyWith(
92-
text: result?.toString() ?? '0.00',
79+
text: result.toStringAsFixed(2),
9380
);
9481
}
9582
}

0 commit comments

Comments
 (0)