如何在 flutter 中安排每月或每周通知?其目的是提醒用户某件事......
这是我的代码
void showMonthlyAtDayTime() async {
//var scheduledNotificationDateTime = DateTime.now().add(Duration(seconds: 10));
var time = Time(12, 6, 0);
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'alarm_notif',
'Scheduled notification', // name of the notif channel
'A scheduled notification', // description of the notif channel
icon: 'question',
largeIcon: DrawableResourceAndroidBitmap('question'),
);
var iOSPlatformChannelSpecifics = IOSNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: true);
var platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.showMonthlyAtDayTime(
0,
'Title',
'Body',
Day.Tuesday,
time,
platformChannelSpecifics);
}
Run Code Online (Sandbox Code Playgroud)
该代码在 showMonthlyAtDayTime 下方有(红色)下划线
'等待 flutterLocalNotificationsPlugin.showMonthlyAtDayTime' 行
和“Day.Tuesday”行... …
我通过文档 ID 获取数据,但收到此错误:
\n错误状态:无法获取 DocumentSnapshotPlatform 上不存在的字段
\n它正在工作,我可以通过文档 id 从 firebase 获取数据,但它在调试控制台中给出错误。
\n我正在使用StreamBuilder获取数据:
\n StreamBuilder(\n stream: _databaseService.productCollection.doc(docID).snapshots(),\n builder: (context, snapshot) {\n if (!snapshot.hasData) {\n return Center(\n child: CircularProgressIndicator(\n valueColor:\n new AlwaysStoppedAnimation<Color>(Colorsx.mainColor),\n ),\n );\n }\n var document1 = snapshot.data;\n\n return Container(\n decoration: BoxDecoration(\n color: Colorsx.mainColor,\n borderRadius: radius,\n ),\n // color: Colorsx.mainColor,\n child: Column(\n children: [\n Expanded(\n child: Row(\n mainAxisAlignment: MainAxisAlignment.spaceEvenly,\n children: [\n Chip(\n label: LabelText1("\xc3\x9cr\xc3\xbcn Ad\xc4\xb1: "),\n backgroundColor: Colorsx.mainColor,\n ),\n Chip(\n shadowColor: Colorsx.mainColor2,\n elevation: 24,\n …Run Code Online (Sandbox Code Playgroud) 在终端中运行“flutter run --release”时出现此错误。我正在寻找是否有人可以提出解决此问题的建议。我尝试了网上找到的很多解决方案,但都没有字。谢谢。
失败:构建失败并出现异常。
无法解析配置“:app:debugRuntimeClasspath”的所有工件。无法转换 libs.jar 以匹配属性 {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}。> JetifyTransform 执行失败:C:\Users\mn\AndroidStudioProjects\myport\build\app\intermediates\flutter\debug\libs.jar。> Transform 的输入文件不存在:C:\Users\mn\AndroidStudioProjects\myport\build\app\intermediates\flutter\debug\libs.jar。(参见https://issuetracker.google.com/iss ues/158753935)
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。
在https://help.gradle.org获取更多帮助
在 1m 49s 内构建失败运行 Gradle 任务“assembleRelease”...运行 Gradle 任务“assembleRelease”...完成 110.5s 异常:Gradle 任务 assembleRelease 失败,退出代码 1
我在 Flutter 中有这个应用程序。它有两个类来生成笔记列表。
\n这是主类,MyApp 类:
\nimport 'package:flutter/cupertino.dart';\nimport 'package:flutter/material.dart';\nimport 'package:notesgenerator/sala.dart';\n\nvoid main() => runApp(MyApp());\n\nclass MyApp extends StatelessWidget {\n // This widget is the root of your application.\n @override\n\n Widget build(BuildContext context) {\n\n List<Sala> locs = [\n Sala(note: 'Study', noteDes: 'from 6pm ~ 8pm'),\n Sala(note: 'Work', noteDes: 'from 8pm ~ 9pm'),\n Sala(note: 'Play', noteDes: 'from 9pm ~ 9:30pm'),\n Sala(note: 'Eat', noteDes: 'from 9:30pm ~ 10pm'),\n ];\n\n return Scaffold(\n appBar: AppBar(\n title: Text('NoteIndex'),\n centerTitle: true,\n ),\n body: ListView.builder(\n itemCount: 10,\n itemBuilder: (context, …Run Code Online (Sandbox Code Playgroud) dart android-studio flutter flutter-dependencies flutter-layout
我创建了一个具有干净架构的项目,其中有 2 个模块:域和数据:
mainProject
- dataModule
- domainModule
lib
Run Code Online (Sandbox Code Playgroud)
我正在使用可注入包来实现依赖项注入,但我不知道是否有一种方法可以在此结构中实现依赖项注入。
我有一个文本字段,然后是一个按钮,然后是一个文本字段。按 Tab 键,焦点将转到第一个文本字段,再次按 Tab 键,焦点将转到按钮。当按 Tab 键两次时,如何忽略按钮上的焦点并将焦点放在第二个文本字段上?
我正在开发一个 flutter web 项目,我有一个小部件,我想编写测试。该小部件正在使用 ,MouseRegion当用户将其悬停或未悬停时,该小部件会执行一些操作。
举个例子:
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
bool isHovered = false;
@override
Widget build(BuildContext context) {
return MouseRegion(
onExit: (_) {
setState(() {
isHovered = false;
});
},
onEnter: (_) {
setState(() {
isHovered = true;
});
},
child: Container(
color: isHovered ? Colors.blue : Colors.red,
height: 50,
width: 50,
)
);
}
}
Run Code Online (Sandbox Code Playgroud)
我可以编写一个小部件测试来测试我的容器是红色的:
testWidgets('MyWidget should be red by default', (WidgetTester tester) …Run Code Online (Sandbox Code Playgroud) 我用条子做了一些类似的事情
import 'package:flutter/material.dart';
class ProfilePage extends StatefulWidget {
@override
_ProfilePageState createState() => _ProfilePageState();
}
class _ProfilePageState extends State<ProfilePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: DefaultTabController(
length: 4,
child: NestedScrollView(
body: TabBarView(children: [
//pages of tabBar
]),
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return [
SliverAppBar(
//for the pinned appBar
elevation: 0.0,
backgroundColor: Colors.red,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(backgroundColor: Colors.red.withOpacity(0.4),
child: Icon(Icons.arrow_back,color: Colors.white,),
),
),
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Image.network(
"https://images.pexels.com/photos/396547/pexels-photo-396547.jpeg?auto=compress&cs=tinysrgb&h=350",
fit: …Run Code Online (Sandbox Code Playgroud) 颤动,导航器
我想从新屏幕返回数据
使用旧的 Navigator 非常简单,在基本屏幕上使用 Navigator.push('new screen').then('process result') ,并在新屏幕上使用 Navigator.pop(result) 。 https://flutter.dev/docs/cookbook/navigation/returning-data
如何使用新的 Navigator 2.0 做到这一点?
我希望我的应用程序仅在设计时处于纵向模式,但应用程序默认情况下会旋转。该应用程序位于 Flutter 框架中。请帮忙。
flutter ×10
dart ×3
android ×1
button ×1
debugging ×1
firebase ×1
flutter-test ×1
flutter-web ×1
focus ×1
gradle ×1
hover ×1
libs ×1
release ×1
sliverappbar ×1