我正在构建一个使用 BLoC 模式并使用 Hydrated_bloc 包来保存数据的 flutter 应用程序。
块本身工作正常,即事件进入块并且块将状态返回给 ui。
问题是 bloc 没有使用 Hydrated_bloc 保存 json。
这是块和事件的代码:
enum ConditionsEvent { snowyPressed, sunnyPressed, rainyPressed }
class ConditionsBloc extends HydratedBloc<ConditionsEvent, String> {
ConditionsBloc() : super('unknown');
@override
Stream<String> mapEventToState(ConditionsEvent event) async* {
switch (event) {
case ConditionsEvent.snowyPressed:
yield 'Snowy';
break;
case ConditionsEvent.sunnyPressed:
yield 'Sunny';
break;
case ConditionsEvent.rainyPressed:
yield 'Rainy';
break;
}
throw UnimplementedError();
}
@override
Map<String, dynamic> toJson(String state) {
return <String, String>{'conditions': state};
}
@override
String fromJson(Map<String, dynamic> json) => json['value'] as String; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用程序中绘制这样的自定义形状:
尝试使用自定义画家进行绘制,但尚未弄清楚如何获得这种形状。我认为它实际上只是一个带有自定义边框的容器,但甚至不知道从哪里开始。我感兴趣的只是形式,而不是内容。
或者,如果有人知道如何绘制底部较薄的圆角矩形,那么这将真正帮助我解决其余问题。
另外,这里有人知道如何绘制中间较薄的圆角矩形,就像我给出的示例中紫色矩形后面的形状吗?
非常感谢任何帮助。
提前致谢
我不断收到错误消息“任务 ':app:transformClassesAndResourcesWithProguardForRelease' 执行失败。”
根据 stackoverflow 问题transformClassesAndResourcesWithProguardForRelease FAILED我需要将以下代码添加到我的 proguard-rules.pro:
-ignorewarnings
-keep class * {
public private *;
}
Run Code Online (Sandbox Code Playgroud)
我在哪里可以找到这个 proguard-rules.pro 文件?我是否需要自己创建它,如果需要,我应该把它放在我的应用程序目录中吗?
上面的错误信息显示在我的代码中。请参阅以下内容:
class BottomNaviBar extends StatefulWidget {
static const String id = 'bottom_navi_bar';
@override
_BottomNaviBarState createState() => _BottomNaviBarState();
}
class _BottomNaviBarState extends State<BottomNaviBar> {
int selectedIndex = 0;
bool showRecipeNotificationBadge = false;
bool showProfileNotificationBadge = false;
final _auth = FirebaseAuth.instance;
FirebaseUser loggedInUser;
String userEmail;
@override
void initState() {
super.initState();
getCurrentUser();
}
void getCurrentUser() async {
try {
final user = await _auth.currentUser();
if (user != null) {
loggedInUser = user;
userEmail = user.email;
}
} catch (e) {
print(e);
}
} …Run Code Online (Sandbox Code Playgroud)