From 3d35b1f35fe507a94c2293c614396dc59a650afb Mon Sep 17 00:00:00 2001 From: Anders Cheow Date: Tue, 9 Jan 2024 14:12:44 +0800 Subject: [PATCH 1/3] Replaced `WillPopScope` with `PopScope` --- lib/src/flutter/dialog.dart | 12 ++++++------ lib/src/flutter/popup_menu.dart | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/src/flutter/dialog.dart b/lib/src/flutter/dialog.dart index 908a313..c49a0ff 100644 --- a/lib/src/flutter/dialog.dart +++ b/lib/src/flutter/dialog.dart @@ -35,8 +35,8 @@ mixin VxDialog { context: context, barrierDismissible: barrierDismissible, builder: (context) { - return WillPopScope( - onWillPop: () async => barrierDismissible, + return PopScope( + canPop: barrierDismissible, child: AlertDialog( contentPadding: EdgeInsets.zero, content: _VxDialog( @@ -73,8 +73,8 @@ mixin VxDialog { context: context, barrierDismissible: barrierDismissible, builder: (context) { - return WillPopScope( - onWillPop: () async => barrierDismissible, + return PopScope( + canPop: barrierDismissible, child: AlertDialog( contentPadding: EdgeInsets.zero, content: _VxDialog( @@ -112,8 +112,8 @@ mixin VxDialog { context: context, barrierDismissible: barrierDismissible, builder: (context) { - return WillPopScope( - onWillPop: () async => barrierDismissible, + return PopScope( + canPop: barrierDismissible, child: AlertDialog( contentPadding: EdgeInsets.zero, content: _VxDialog( diff --git a/lib/src/flutter/popup_menu.dart b/lib/src/flutter/popup_menu.dart index 8013829..3be9af0 100644 --- a/lib/src/flutter/popup_menu.dart +++ b/lib/src/flutter/popup_menu.dart @@ -198,11 +198,9 @@ class VxPopupMenuState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () { - _hideMenu(); - return Future.value(true); - }, + return PopScope( + canPop: true, + onPopInvoked: (_) => _hideMenu(), child: GestureDetector( behavior: HitTestBehavior.translucent, child: widget.child, From 759d4410b03646683c615ce6ae4267410b6428ba Mon Sep 17 00:00:00 2001 From: Anders Cheow Date: Tue, 9 Jan 2024 14:17:01 +0800 Subject: [PATCH 2/3] Replaced `textScaleFactor` to `textScaler` --- lib/src/flutter/rich_text.dart | 3 ++- lib/src/flutter/selectable_text.dart | 3 ++- lib/src/flutter/text.dart | 3 ++- lib/src/flutter/timeline/timeline_view.dart | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/flutter/rich_text.dart b/lib/src/flutter/rich_text.dart index 9faa298..8459fea 100644 --- a/lib/src/flutter/rich_text.dart +++ b/lib/src/flutter/rich_text.dart @@ -470,7 +470,8 @@ class VxRichText extends VxWidgetBuilder key: key, textAlign: _textAlign, maxLines: _maxLines, - textScaleFactor: _scaleFactor, + textScaler: + _scaleFactor == null ? null : TextScaler.linear(_scaleFactor!), softWrap: _softWrap ?? true, overflow: _overflow ?? TextOverflow.clip, strutStyle: _strutStyle, diff --git a/lib/src/flutter/selectable_text.dart b/lib/src/flutter/selectable_text.dart index a06455f..0527e39 100644 --- a/lib/src/flutter/selectable_text.dart +++ b/lib/src/flutter/selectable_text.dart @@ -369,7 +369,8 @@ class VxSelectableTextBuilder extends VxWidgetBuilder onTap: _onTap as void Function()?, enableInteractiveSelection: true, showCursor: _showCursor ?? false, - textScaleFactor: _scaleFactor, + textScaler: + _scaleFactor == null ? null : TextScaler.linear(_scaleFactor!), style: _themedStyle?.merge(ts) ?? _textStyle?.merge(ts) ?? ts, strutStyle: _strutStyle, contextMenuBuilder: _contextMenuBuilder, diff --git a/lib/src/flutter/text.dart b/lib/src/flutter/text.dart index 01dc31a..19ffa08 100644 --- a/lib/src/flutter/text.dart +++ b/lib/src/flutter/text.dart @@ -508,7 +508,8 @@ class VxTextBuilder extends VxWidgetBuilder key: key, textAlign: _textAlign, maxLines: _maxLines, - textScaleFactor: _scaleFactor, + textScaler: + _scaleFactor == null ? null : TextScaler.linear(_scaleFactor!), style: _themedStyle?.merge(ts) ?? _textStyle?.merge(ts) ?? ts, softWrap: _softWrap ?? true, overflow: _overflow ?? TextOverflow.clip, diff --git a/lib/src/flutter/timeline/timeline_view.dart b/lib/src/flutter/timeline/timeline_view.dart index 7c5d4c6..3ed450d 100644 --- a/lib/src/flutter/timeline/timeline_view.dart +++ b/lib/src/flutter/timeline/timeline_view.dart @@ -85,7 +85,7 @@ class VxTimelineView extends StatelessWidget { style: TextStyle( color: descriptionColor ?? Colors.black, ), - textScaleFactor: 1.25, + textScaler: const TextScaler.linear(1.25), ), ) ], From c0f95e6a4cf523e326e64786506b85d4a3e7a058 Mon Sep 17 00:00:00 2001 From: Anders Cheow Date: Tue, 9 Jan 2024 14:17:32 +0800 Subject: [PATCH 3/3] Added TODO on requesting help to replace `WillPopCallback` to `PopEntry` --- lib/src/flutter/drawer.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/flutter/drawer.dart b/lib/src/flutter/drawer.dart index e2ce0f8..b6f04ef 100644 --- a/lib/src/flutter/drawer.dart +++ b/lib/src/flutter/drawer.dart @@ -86,9 +86,11 @@ mixin VxDrawer { return Future.value(false); } + // TODO(iampawan): Not sure how to change it to use `PopEntry` route?.addScopedWillPopCallback(backClose); hide = () async { + // TODO(iampawan): Not sure how to change it to use `PopEntry` route?.removeScopedWillPopCallback(backClose); await key.currentState?.reverseAnimation(); overlayEntry?.remove();