
在SliderThemeData trackheight给出,但我想增加轨道的宽度。
这是我当前的代码:
SliderTheme(
data: SliderThemeData(
trackHeight: 1,
),
child: RangeSlider(
min: 0.0,
max: 4.0,
onChanged: _onChange,
values: state.value,
onChangeEnd: _onChangeEnd,
inactiveColor: Colors.grey,
activeColor: Theme.of(state.context).accentColor,
),
),
Run Code Online (Sandbox Code Playgroud) 我想从列表块中的 Firestore 读取数据我不想使用流构建器我想单独访问文档字段我尝试这个但不起作用
class ProductList extends StatelessWidget {
Stream<DocumentSnapshot> snapshot = Firestore.instance.collection("listofprods").document('ac1').snapshots();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black)
),
child: ListTile(
title: Text(snapshot['name']),//here error
),
)
],
Run Code Online (Sandbox Code Playgroud) 我正在将图像从图库上传到应用程序,我的应用程序自动请求许可,但不知道现在发生了什么,当我尝试在应用程序中打开图库时,它不请求许可并收到错误“权限被拒绝”
loadGallery() async {
List<Asset> resultImages = List<Asset>();
try {
resultImages = await MultiImagePicker.pickImages(
maxImages: 10,
selectedAssets: images,
);
} catch (e) {
print("error is : $e");
}
setState(() {
images = resultImages;
});
}
Run Code Online (Sandbox Code Playgroud) Json 可序列化无法正常工作,我该如何解决这个问题,我不知道这个错误。我使用了 flutter build_runner: ^1.7.2 json_serialized: ^3.4.1 分析器: ^0.39.17 json_annotation: ^3.0.1 没有一个文件正在创建 json
Json 可序列化无法正常工作,我该如何解决这个问题,我不知道这个错误。我使用了 flutter build_runner: ^1.7.2 json_serialized: ^3.4.1 分析器: ^0.39.17 json_annotation: ^3.0.1 没有一个文件正在创建 json
import 'package:dance/models/tutorials-model/video-data.dart';
import 'package:json_annotation/json_annotation.dart';
part 'metadata.g.dart';
@JsonSerializable()
class MetaData {
final String category;
final String categoryId;
final List<VideoData> data;
MetaData(this.category, this.categoryId, this.data);
factory MetaData.fromJson(Map<String, dynamic> json) => _$MetaDataFromJson(json);
Map<String, dynamic> toJson() => _$MetaDataToJson(this);
}
------------------------terminal------------------------
flutter pub run build_runner watch
[INFO] Running build...
[INFO] Generating SDK summary...
[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
Bad state: Unexpected …Run Code Online (Sandbox Code Playgroud) 收到此错误我尝试修复此参考:Application.kt:未解析的参考:firebasemessaging但没有工作,所以我需要再次发布我也尝试删除 application.kt 文件但没有工作。如果有人知道解决方案,请让我知道我做错了什么,这样我就可以学会不再重复这些
ext.kotlin_version = '1.4.32'
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath 'com.google.gms:google-services:4.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
package com.godatu.dance
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService
class Application : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
override fun onCreate() {
super.onCreate()
FlutterFirebaseMessagingService.setPluginRegistrant(this)
}
override fun registerWith(registry: PluginRegistry?) {
if (registry != null) {
FirebaseCloudMessagingPluginRegistrant.registerWith(registry)
FlutterLocalNotificationPluginRegistrant.registerWith(registry)
FlutterPathProviderPluginRegistrant.registerWith(registry)
}
}
}
enter code here
[ +2 ms] e: C:\Users\Admin\Desktop\Android\godatu-App\android\app\src\main\kotlin\com\godatu\dance\Application.kt: (6, 27): Unresolved reference: firebasemessaging
[ +3 ms] e: C:\Users\Admin\Desktop\Android\godatu-App\android\app\src\main\kotlin\com\godatu\dance\Application.kt: (7, 27): Unresolved reference: firebasemessaging
[ ] e: …Run Code Online (Sandbox Code Playgroud) 我还没有创建任何在屏幕之间导航的路线。我使用 Navigator 进行导航:
Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage()));
Run Code Online (Sandbox Code Playgroud)
我所做的是导航到从主页到成功屏幕的四个屏幕:
主页 => CreatePostScreen => CreateImagePost => SuccessScreen
当我到达成功屏幕时,我想弹出两个屏幕并返回到 CreatePostScreen。我不想写 Navigator.pop(context) 两次。
我尝试使用它,但它会出现黑屏:
Navigator.popUntil(context, (route) => route is CreatePostScreen);
Run Code Online (Sandbox Code Playgroud)
但这不起作用。我想了解 flutter 如何处理小部件导航而不是通过路线名称以及解决方案。
我知道导航器类如何处理路线名称,但我想知道如果我推送小部件及其工作如何解决它。
我想找出所有以#开头的单词。
例如=这是一个#tag
我想创建这个(#tag)可点击并将其颜色更改为蓝色。请指教一下!
Text("This is a #tag"),
Run Code Online (Sandbox Code Playgroud) 我正在尝试将数据保存在 firestore 上,但在保存到 toJson 时出现错误。我创建了两个模型 Diet-model 和 TargetModel 使用 json_serialized: ^4.0.0 和 json_annotation: ^4.0.0 存储在 firestore 上。TargetModel 有饮食模型列表。错误是运行时错误
错误:
Unhandled Exception: Invalid argument: Instance of 'DietModel'
[ ] E/flutter (23502): #0 convertPlatformException (package:cloud_firestore_platform_interface/src/method_channel/utils/exception.dart:13:5)
[ ] E/flutter (23502): #1 MethodChannelDocumentReference.set (package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:43:13)
[ ] E/flutter (23502): <asynchronous suspension>
[ ] E/flutter (23502): #2 DietPageRepositoryImpl.setTarget (package:dance/services/firestore/firestore-impl/diet-page-repository-impl.dart:31:5)
[ ] E/flutter (23502): <asynchronous suspension>
[ ] E/flutter (23502): #3 DietPageViewModel.setTargetedModel (package:dance/viewmodels/diet-page-view-model/diet-page-view-model.dart:120:5)
[ ] E/flutter (23502): <asynchronous suspension>
Run Code Online (Sandbox Code Playgroud)
import 'package:dance/models/diet-model/diet-model.dart';
import 'package:json_annotation/json_annotation.dart';
part 'targeted-model.g.dart';
@JsonSerializable()
class …Run Code Online (Sandbox Code Playgroud) 我的滑块从一个值跳到另一个值。如何使其在值之间移动或使其在 Flutter 中更加平滑?
Column(
children: <Widget>[
RangeSlider(
min: 1,
max: 40,
divisions: 4,
onChanged: onChange,
values: RangeValues((startValue ?? 1).toDouble(), (endValue ?? 40).toDouble()),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text('Beginner', style: Theme.of(context).textTheme.body2),
Text('Ameateur', style: Theme.of(context).textTheme.body2),
Text('Intermediate', style: Theme.of(context).textTheme.body2),
Text('Advanced', style: Theme.of(context).textTheme.body2),
Text('Professional', style: Theme.of(context).textTheme.body2),
],
),
],
);
Run Code Online (Sandbox Code Playgroud) 我正在写一个标题,因此文本大小很大,因此换行符从左侧开始,但我希望它从中心开始。
示例:当前文本显示如下。
This is a new
line
Run Code Online (Sandbox Code Playgroud)
但是,我想这样展示
This is a new
line
Run Code Online (Sandbox Code Playgroud)
我正在使用这个代码
Text("Please Contact us in the morning timings are 10 AM to 12 AM",
style: Theme.of(context).textTheme.headline5,),
Run Code Online (Sandbox Code Playgroud) 我今天更新了我的 flutter 并且 build_runner 没有工作得到这个(下面)错误错误 - 当我运行 flutter pun run build_runner build 尝试了每个命令
扑干净| flutter pub 包升级 | flutter pub缓存修复等但不起作用
dependencies:
flutter:
sdk: flutter
...
...
flutter_svg: ^0.19.3
xml: ^4.2.0
build_resolvers: ^1.5.4
build: ^1.6.3
injectable_generator: ^1.2.0
convert: ^3.0.0
glob: ^2.0.0
dev_dependencies:
flutter_test:
sdk: flutter
built_value_generator: ^7.0.9
json_serializable: ^4.0.2
build_runner: ^1.11.5
retrofit_generator: ^1.3.7+2
mobx_codegen: ^1.1.0+1
dependency_overrides:
convert: ^3.0.0
pedantic: ^1.9.0
analyzer: ^0.41.2
Failed to precompile build_runner:build_runner:
../../flutter-dart/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.14/lib/src/source_visitor.dart:302:16: Error: The getter 'typeArguments' isn't defined for the class 'Annota
tion'.
- 'Annotation' is …Run Code Online (Sandbox Code Playgroud) 我试图将颜色保存在共享首选项中,但它只有有限的数据类型(字符串、整数、双精度等),我不知道
Future getColor() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
Color color = prefs.getString("color"); //error
return color;
}
Future setColor(Color themeColor) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("color", (themeColor); //error
}
Run Code Online (Sandbox Code Playgroud)
}