From f34fc301857362f99a95831227f916ebadbc9607 Mon Sep 17 00:00:00 2001 From: Talha Iqbal <61588132+talha828@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:38:55 +0500 Subject: [PATCH] #2995 \ Displaying a Snackbar that is does not use the full width makes buttons on that height unclickable - Resolved --- example_nav2/android/app/build.gradle | 6 +- .../android/app/src/main/AndroidManifest.xml | 1 + example_nav2/android/build.gradle | 6 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example_nav2/android/local.properties | 7 +- lib/get_navigation/src/snackbar/snackbar.dart | 114 ++++++++++-------- 6 files changed, 77 insertions(+), 59 deletions(-) diff --git a/example_nav2/android/app/build.gradle b/example_nav2/android/app/build.gradle index b07a8f9b6..2c20e3457 100644 --- a/example_nav2/android/app/build.gradle +++ b/example_nav2/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 33 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -35,8 +35,8 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.get.example_nav2" - minSdkVersion 16 - targetSdkVersion 30 + minSdkVersion flutter.minSdkVersion + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example_nav2/android/app/src/main/AndroidManifest.xml b/example_nav2/android/app/src/main/AndroidManifest.xml index d4e7bbe02..8a3a93d02 100644 --- a/example_nav2/android/app/src/main/AndroidManifest.xml +++ b/example_nav2/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ android:icon="@mipmap/ic_launcher"> @override Widget build(BuildContext context) { - return Align( - heightFactor: 1.0, - child: Material( - color: widget.snackStyle == SnackStyle.floating - ? Colors.transparent - : widget.backgroundColor, - child: SafeArea( - minimum: widget.snackPosition == SnackPosition.bottom - ? EdgeInsets.only( - bottom: MediaQuery.of(context).viewInsets.bottom) - : EdgeInsets.only(top: MediaQuery.of(context).padding.top), - bottom: widget.snackPosition == SnackPosition.bottom, - top: widget.snackPosition == SnackPosition.top, - left: false, - right: false, - child: Stack( - children: [ - FutureBuilder( - future: _boxHeightCompleter.future, - builder: (context, snapshot) { - if (snapshot.hasData) { - if (widget.barBlur == 0) { - return _emptyWidget; - } - return ClipRRect( - borderRadius: BorderRadius.circular(widget.borderRadius), - child: BackdropFilter( - filter: ImageFilter.blur( - sigmaX: widget.barBlur, sigmaY: widget.barBlur), - child: Container( - height: snapshot.data!.height, - width: snapshot.data!.width, - decoration: BoxDecoration( - color: Colors.transparent, - borderRadius: - BorderRadius.circular(widget.borderRadius), - ), - ), - ), - ); - } else { + if (widget.disableSelfAlignment) { + return _snackBar(context); + } else { + return Align( + heightFactor: 1.0, + child: _snackBar(context), + ); + } + } + + Material _snackBar(BuildContext context) { + return Material( + color: widget.snackStyle == SnackStyle.floating + ? Colors.transparent + : widget.backgroundColor, + child: SafeArea( + minimum: widget.snackPosition == SnackPosition.bottom + ? EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom) + : EdgeInsets.only(top: MediaQuery.of(context).padding.top), + bottom: widget.snackPosition == SnackPosition.bottom, + top: widget.snackPosition == SnackPosition.top, + left: false, + right: false, + child: Stack( + children: [ + FutureBuilder( + future: _boxHeightCompleter.future, + builder: (context, snapshot) { + if (snapshot.hasData) { + if (widget.barBlur == 0) { return _emptyWidget; } - }, - ), - if (widget.userInputForm != null) - _containerWithForm() - else - _containerWithoutForm() - ], - ), + return ClipRRect( + borderRadius: BorderRadius.circular(widget.borderRadius), + child: BackdropFilter( + filter: ImageFilter.blur( + sigmaX: widget.barBlur, sigmaY: widget.barBlur), + child: Container( + height: snapshot.data!.height, + width: snapshot.data!.width, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: + BorderRadius.circular(widget.borderRadius), + ), + ), + ), + ); + } else { + return _emptyWidget; + } + }, + ), + if (widget.userInputForm != null) + _containerWithForm() + else + _containerWithoutForm() + ], ), ), );