我使用 Flutter bloc 包创建了一个应用程序。我创建了一个名为learning_dashboard_screen 的屏幕,其中包含从服务器获取的列表。在同一屏幕内,我有一个过滤器按钮,按下该按钮将使用底部工作表小部件显示过滤器屏幕。
它有不同的类别可供过滤列表。在learning_dashboard_screen_state屏幕中,我有一个名为filteroptions的Map,其类型为Map <String,Map <String,dynamic>>。该映射用于通过将映射与复选框小部件映射来填充复选框。
part of 'learning_dashboard_screen_bloc.dart';
class LearningDashboardScreenState extends Equatable {
static ScrollController controller = ScrollController();
final int courseLimit = 3;
final List<GPaginatedCoursesData_paginatedCourses_data> courses;
final DataRetrievalStatus initialCoursesStatus;
final Map<String, Map<String, dynamic>> filterOption;
Map<String, Map<String, dynamic>> getFilterOption() {
return filterOption;
}
final int currPage;
final bool hasNextPage;
final DataRetrievalStatus moreCoursesStatus;
LearningDashboardScreenState(
{this.courses = const [],
this.initialCoursesStatus = DataRetrievalStatus.NOT_INITIALIZED,
this.filterOption = const {
"Certificate Provider": {"NVQ": false, "City and Guilds": false},
"Course Language": {"Sinhala": false, "English": false, …Run Code Online (Sandbox Code Playgroud) 我有一个带有图标的提升按钮,该图标使用 放置在文本左侧ElevatedButton.icon。我真正想要的是将图标放置在文本的右侧。我该如何做我的代码:
ElevatedButton.icon(
onPressed: onPressed,
icon:Icon(icon,
color: color != null ? color : null,
size: getIconSize(),
),
label: Text(label),
style: buttonStyle);
Run Code Online (Sandbox Code Playgroud)
外观如何:
我想要的是 :
下一页->
我创建了一个登录屏幕,当用户按下登录按钮时,它会调用一个事件 LoginButtonOnPressedEvent。下面是我的 LoginBloc 类中的 onLoginButtonOnPressedEvent 函数。
Future<void> _onLoginButtonPressedEvent(
LoginButtonPressedEvent event, Emitter<LoginScreenState> emit) async {
GoogleSignIn _googleSignIn = GoogleSignIn(scopes: ['email']);
GoogleSignInAccount? user = _googleSignIn.currentUser;
await _googleSignIn.signIn();
emit(LoginScreenState(user: user));
print("USER DETAILS : ${user}");
}
Run Code Online (Sandbox Code Playgroud)
我在登录屏幕中触发此事件,如下所示,其中 RippleButton 是我制作的自定义按钮。
RippleButton(
onTap: () {
context.read<LoginScreenBloc>().add(LoginButtonPressedEvent());
},
),
Run Code Online (Sandbox Code Playgroud)
当我点击按钮时,不会显示选择帐户的弹出窗口,而是屏幕变得有点暗,然后恢复正常。
下面是调用事件相关的日志
I/ContentCaptureHelper(30073): Setting logging level to OFF
I/flutter (30073): USER DETAILS : null
I/et_schedule_ap(30073): Background concurrent copying GC freed 2871953(94MB) AllocSpace
objects, 9(308KB) LOS objects, 87% free, 3450KB/27MB, paused 142us,42us total 104.801ms
W/et_schedule_ap(30073): Reducing the number of …Run Code Online (Sandbox Code Playgroud) 当我尝试在手机上运行 flutter 应用程序时,出现此错误
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install C:\Users\kavis\OneDrive\Desktop\New
folder\care_receiver_app\ss_carereceiver_app\build\app\outputs\flutter-apk\app.apk:
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI:
/data/app/vmdl378681921.tmp/base.apk (at Binary XML file line #26):
com.owaslo.sukithasagayo.carereceiver.mainActivity: Targeting S+ (version 31 and above)
requires that an explicit value for android:exported be defined when intent filters are
present]
Error launching application on Pixel 6.
Run Code Online (Sandbox Code Playgroud)
我在这里阅读了许多其他有关它的问题,但到目前为止我还没有找到解决方案,任何人都可以查看我的清单并告诉我我做错了什么吗?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.owaslo.sukithasagayo.carereceiver">
<application
android:label="Sukitha Sagayo"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable" …Run Code Online (Sandbox Code Playgroud)