Skip to content

Commit

Permalink
Avoid rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Huy Pham committed Mar 12, 2022
1 parent 9c8c6fc commit 95241e6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ui/widget/alice_base_call_details_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

abstract class AliceBaseCallDetailsWidgetState<T extends StatefulWidget>
extends State<T> {
extends State<T> with AutomaticKeepAliveClientMixin {
final JsonEncoder encoder = const JsonEncoder.withIndent(' ');

Widget getListRow(String name, String value) {
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/widget/alice_call_error_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _AliceCallErrorWidgetState

@override
Widget build(BuildContext context) {
super.build(context);
if (_call.error != null) {
final List<Widget> rows = [];
final dynamic error = _call.error!.error;
Expand All @@ -36,4 +37,7 @@ class _AliceCallErrorWidgetState
return const Center(child: Text("Nothing to display here"));
}
}

@override
bool get wantKeepAlive => true;
}
4 changes: 4 additions & 0 deletions lib/ui/widget/alice_call_overview_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _AliceCallOverviewWidget

@override
Widget build(BuildContext context) {
super.build(context);
final List<Widget> rows = [];
rows.add(getListRow("Method: ", _call.method));
rows.add(getListRow("Server: ", _call.server));
Expand All @@ -39,4 +40,7 @@ class _AliceCallOverviewWidget
child: ListView(children: rows),
);
}

@override
bool get wantKeepAlive => true;
}
4 changes: 4 additions & 0 deletions lib/ui/widget/alice_call_request_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class _AliceCallRequestWidget

@override
Widget build(BuildContext context) {
super.build(context);
final List<Widget> rows = [];
rows.add(getListRow("Started:", _call.request!.time.toString()));
rows.add(getListRow("Bytes sent:", formatBytes(_call.request!.size)));
Expand Down Expand Up @@ -80,4 +81,7 @@ class _AliceCallRequestWidget
child: ListView(children: rows),
);
}

@override
bool get wantKeepAlive => true;
}
4 changes: 4 additions & 0 deletions lib/ui/widget/alice_call_response_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class _AliceCallResponseWidgetState

@override
Widget build(BuildContext context) {
super.build(context);
final List<Widget> rows = [];
if (!_call.loading) {
rows.addAll(_buildGeneralDataRows());
Expand Down Expand Up @@ -301,4 +302,7 @@ class _AliceCallResponseWidgetState
return _call.response!.body != null &&
_call.response!.body.toString().length > _kLargeOutputSize;
}

@override
bool get wantKeepAlive => true;
}

0 comments on commit 95241e6

Please sign in to comment.