我有一个简单的小部件,在小部件中,我有一个棕色和一个网格视图。问题是由于高度的原因,它在末端显示了额外的空间。如果我删除高度,则小部件不会显示。
代码
class PodcastSection extends StatelessWidget {
final String title;
final DiscoverExtended arg;
final List<Item> listOfPodcasts;
PodcastSection({@required this.title, this.arg, this.listOfPodcasts});
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 18),
padding: EdgeInsets.only(left: 1, right: 1),
height: MediaQuery.of(context).size.height * 0.66,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Color(0xFF707070).withOpacity(0.35)),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
),
//TOP Row
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
title.toUpperCase(),
style: TextStyle(
fontFamily: "Segoe UI",
fontSize: 20,
color: Colors.white,
),
), …Run Code Online (Sandbox Code Playgroud) Flutter 我正在使用 Silver Widget 来显示列表,但它显示错误
RenderViewport 期望有一个 RenderSliver 类型的子级,但收到了一个 RenderErrorBox 类型的子级
我认为 Silver Widget 中存在问题,或者当我在构建器中调用该小部件时?
我的代码
class _EventsState extends State<Events> {
dynamic _events = [];
dynamic isloader = false;
@override
initState() {
// TODO: implement initState
super.initState();
doSomeAsyncStuff();
}
Future<void> doSomeAsyncStuff() async {
setState((){isloader = true;});
final storage = new FlutterSecureStorage();
String value = await storage.read(key: 'token');
print(value);
String url = 'http://sublimeapi.netcodesolution.com/api/NewsAndEvents/';
String token = value;
final response = await http.get(url, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer $token', …Run Code Online (Sandbox Code Playgroud) 我正在使用 Google 地图 API,我需要使用一些 TextFormField 在 google 地图上显示一些容器。我面临的问题是我需要滚动谷歌地图顶部的容器。也就是说,当用户将容器从下往上移动时,容器才会像这样来到顶部。
我的代码
Stack(children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: GoogleMap(
markers: Set<Marker>.of(_markers.values),
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: currentPostion,
zoom: 18.0,
),
myLocationEnabled: true,
onCameraMove: (CameraPosition position) {
if (_markers.length > 0) {
MarkerId markerId = MarkerId(_markerIdVal());
Marker marker = _markers[markerId];
Marker updatedMarker = marker.copyWith(
positionParam: position.target,
);
setState(() {
_markers[markerId] = updatedMarker;
});
}
},
),
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Container(
color: Colors.white, …Run Code Online (Sandbox Code Playgroud) 我正在使用图像选择器,我需要将图像存储在文件中以便可以显示。
我正在这样做
final ImagePicker _picker = ImagePicker();
PickedFile? _imageFile;
File? imageFile;
_imgFromCamera() async {
final pickedFile =
await _picker.getImage(source: ImageSource.camera, imageQuality: 50);
setState(() {
_imageFile = pickedFile;
imageFile = File(pickedFile!.path);
});
}
_imgFromGallery() async {
final pickedFile =
await _picker.getImage(source: ImageSource.gallery, imageQuality: 50);
setState(() {
_imageFile = pickedFile;
imageFile = File(pickedFile!.path);
});
}
Run Code Online (Sandbox Code Playgroud)
但当我展示这个时
Image.file(
imageFile,
width: 100,
height: 100,
fit: BoxFit.fitHeight,
)
Run Code Online (Sandbox Code Playgroud)
它显示了这个错误 Flutter The argument type 'File?' can't be assigned to the parameter type 'File'。如果我?从文件中删除,那么它会显示一些空安全错误。
我使用 Flutter nfc_manager 只是为了在 android 中的 NFC 标签上写入 URL,它工作得很好。但在 IOS 上,标签上没有写任何内容,也没有显示任何错误。
在他们的 IOS 设置文档中,他们说要这样做
Add Near Field Communication Tag Reader Session Formats Entitlements to your entitlements.
Add NFCReaderUsageDescription to your Info.plist.
Add com.apple.developer.nfc.readersession.felica.systemcodes and com.apple.developer.nfc.readersession.iso7816.select-identifiers to your Info.plist as needed.
Run Code Online (Sandbox Code Playgroud)
我只完成了第一步和第二步。似乎第三步仅用于读取我不想在我的应用程序中使用的标签。我需要添加第三步 另外如何添加此步骤我正在使用协议的 NFC 标签:ISO14443A
我正在尝试格式化我的日期和时间。
我的代码
String dateStart = data[i]['notification_date'];
DateTime input = DateTime.parse(dateStart);
String datee = DateFormat('hh:mm a').format(input);
Run Code Online (Sandbox Code Playgroud)
它显示错误未处理的异常:FormatException:无效的日期格式
现在它看起来像这样22-04-2021 05:57:58 PM
I am trying to change some bool values in my Dialog. I am doing like this
showDialog(
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
bool testBool = true;
return Dialog(
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(12.0),
side: BorderSide(
color:
kPrimaryColor)), //this right here
child: GestureDetector(
onTap: (){
print(testBool);
setState((){
testBool = !testBool;
});
print(testBool);
},
child: Container(
height: 525,
width: width * 0.85,
child:
Text('12313', style: TextStyle(color: testBool? Colors.red : Colors.green),),
),
),
);
},
);
},
); …Run Code Online (Sandbox Code Playgroud) 需要从 SQLite 中删除所有行
这是我拥有数据库所有功能的文件
class DatabaseHelper {
static final _databaseName = "MyDatabase.db";
static final _databaseVersion = 1;
static final table = 'cart_table';
// make this a singleton class
DatabaseHelper._privateConstructor();
static final DatabaseHelper instance = DatabaseHelper._privateConstructor();
// only have a single app-wide reference to the database
static Database _database;
Future<Database> get database async {
if (_database != null) return _database;
// lazily instantiate the db the first time it is accessed
_database = await _initDatabase();
return _database;
}
// this opens …Run Code Online (Sandbox Code Playgroud) 我从商店获取日期和时间。在数据库中它看起来像这样
需要知道如何将其显示为 DD/MM/YY
我正在尝试这样做
String timeString = snapshot.data[index]['lastupdate'].toString();
DateTime date = DateTime.parse(timeString);
print(DateFormat('yyyy-MM-dd').format(date));
Run Code Online (Sandbox Code Playgroud)
它显示日期格式无效的错误
我已经创建了一个集群、任务定义和负载均衡器,现在我正在 Ecs 集群上创建一个服务,但它显示此错误
我的镜像中的 Docker 文件是
FROM node:alpine
# Set the working directory to /app inside the container
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm i
# add app
COPY . ./
EXPOSE 8080
# start app
CMD ["npm", "start"]
Run Code Online (Sandbox Code Playgroud) 我有一个简单的图表,其中 x 轴为字符串,y 轴为 int,但我的值太长 10000 我需要将其显示为 10k
我的代码
Container(
height: MediaQuery.of(context).size.height * 0.25,
child: SfCartesianChart(
enableAxisAnimation: true,
primaryXAxis: CategoryAxis(
majorGridLines: MajorGridLines(width: 0),
//Hide the axis line of x-axis
axisLine: AxisLine(width: 0),
interval: 1),
primaryYAxis: NumericAxis(
minimum: 0, maximum: highSale,
interval: highSale < 200 ? 100 : 2000,
majorGridLines: MajorGridLines(width: 0),
//Hide the axis line of x-axis
axisLine: AxisLine(width: 0),
),
tooltipBehavior: _tooltip,
plotAreaBorderWidth: 0,
legend: Legend(isVisible: false),
series: <ChartSeries<_ChartData, String>>[
ColumnSeries<_ChartData, String>(
dataSource: weekly
? data
: yearly
? …Run Code Online (Sandbox Code Playgroud) 我想添加数据和集合我正在尝试这样
Future<void> createRoom(collection, docid, data) async {
await FirebaseFirestore.instance
.collection(collection)
.doc()
.set(data)
.collection('messages');
}
Run Code Online (Sandbox Code Playgroud)
但它显示错误The method 'collection' isn't defined for the type 'Future'.
我正在使用 pydantic 来验证我需要验证电子邮件的响应。我正在这样尝试。
class CheckLoginRequest(BaseModel):
user_email: str = Field(min_length=5, default="username")
user_number: str = Field(min_length=5, default="+923323789263")
@field_validator("user_email")
def validate_email(self, value):
try:
validate_email(value)
except EmailNotValidError:
raise ValueError("Invalid email format")
return value
Run Code Online (Sandbox Code Playgroud)
但它显示错误pydantic.errors.PydanticUserError: @field_validator cannot be applied to instance methods
我尝试使用@validator它,但它已被弃用。
flutter ×11
dart ×9
amazon-ecs ×1
aws-application-load-balancer ×1
datetime ×1
fastapi ×1
firebase ×1
google-maps ×1
gridview ×1
ios ×1
nfc ×1
pydantic ×1
python ×1
xcode ×1