Flutter

Setstate for statless widget dropdownButton from a stateful parent

半城伤御伤魂 提交于 2021-01-29 09:53:10
问题 I have three widgets first one is LightBulb(stateless) that have some color properties. The second one is widget named as LightColorSelector(stateless) that has a DropdownMenu with string type items Red , Green and Blue . And, the third class is Classroom(stateful widget) which is the parent of that two classes. My aim is to set the states from that class. I need to set a list of that three colors inside the Classroom , when someone clicks on one of the LightColorSelector items the LightBulb

Create a resizable view in flutter

荒凉一梦 提交于 2021-01-29 09:42:03
问题 I am creating a resizable view for an image. The code is as follows: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: SafeArea( child: ImageManager(), ), ), ); } } final ballRadius = 7.5; class ImageManager extends StatefulWidget { @override _ImageManagerState createState() => _ImageManagerState(); } class

How do i compress a PDF in Flutter?

喜你入骨 提交于 2021-01-29 09:38:23
问题 I built an app for my university where students can access documents such as notes, question papers etc. in PDF format. I am using Firebase Storage for the back-end. I want to compress the PDF files client side. I thought of using ilovepdf.com's API but i'm not able to do that. Is there anyway to do that in dart? any package in flutter? Would be great if someone could help. Thanks. 回答1: You can use any file compression method, not just those specific to PDF. You could use the archive package,

Flutter Provider reinitialize model

流过昼夜 提交于 2021-01-29 09:29:50
问题 I use MultiProvider and then create all my models. Lazy loading is enabled and as such when I open my page widget the constructor of my model is called when I call Provider.of<>(context) . This initialize my model and the model gets fresh data. I have the following issue however, when I pop the view(widget) and revisit the view(widget) later, Provider.of<>(context) is called again, but since the model was already initialized I get the previous data from the model (This is useful because I do

Getting 'Future<Image>' can't be assigned to a variable of type 'Image' in this Flutter/Dart code?

牧云@^-^@ 提交于 2021-01-29 09:25:27
问题 I'm trying create a function to load images in Flutter (Dart) but not sure how to get this code working. I'm getting: A value of type 'Future' can't be assigned to a variable of type 'Image'. Try changing the type of the variable, or casting the right-hand type to 'Image'. import 'dart:typed_data'; import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build

“Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': Cookies are disabled inside 'data:' URLs.” Flutter webview

泄露秘密 提交于 2021-01-29 09:24:46
问题 WebView(initialUrl:Uri.dataFromString('<script type="text/javascript" src="https://cdn.embedly.com/widgets/platform.js"></script>'+<html>Some code</html>,mimeType: 'text/html').toString(), javascriptMode: JavascriptMode.unrestricted,), This CDN is throwing this error: Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': Cookies are disabled inside 'data:' URLs." Flutter webview 回答1: You can try my plugin flutter_inappwebview, which is a Flutter plugin that allows you

delete a document in firebase when you know the field value

天大地大妈咪最大 提交于 2021-01-29 09:20:01
问题 Context: In the frontend the user can enter of delete dates for availability. This is how I added a date: Firestore.instance.collection('availableDates').add({ 'availableDates':date}); But I also need to delete a document from a collection in Firestore . I don't know the document id but I know the the field value which is unique. How would I go about deleting the document if I know the field value within the document. Here is a screen shot of firestore: 回答1: You can fetch the document first

How to Change Screen Using Flutter Getx

我的未来我决定 提交于 2021-01-29 09:15:28
问题 i Got Questions here. How to change screen using FLutter Getx. I got GetxControll that searchUser from firestore. Here's the code. class AuthenticationC extends GetxController { final usersRef = FirebaseFirestore.instance.collection('Users'); List<QueryDocumentSnapshot> searchResultFuture; searchUser(String query) async { QuerySnapshot snapshot = await usersRef .where('DisplayName', isGreaterThanOrEqualTo: query) .get(); searchResultFuture = snapshot.docs; return snapshot.docs; } } then i

Is it possible to connect a local Functions emulator to a non-local Firebase Realtime Database?

限于喜欢 提交于 2021-01-29 09:14:48
问题 Due to problems using a Realtime Database emulator for development in Flutter ( see How do I connect to my local Realtime Database emulator in my Flutter app? ), I am now simply using my non-local Realtime Database for development. However, I am also using Cloud Functions, and I have created a Functions emulator. I tried the following to connect to it, based on this StackOverflow-answer: const functions = require("firebase-functions"); const admin = require("firebase-admin"); functions.config

How to reuse the same layout screen without creating a new widget tree branch

我是研究僧i 提交于 2021-01-29 09:04:44
问题 I am developing Flutter Web Application. The object is to reuse the same layout screen widget(Drawer, AppBar) for most of route screen. I have tried create a new Scaffold class and add body widget to each screen. The problem is every time I navigate to a new screen. There is a new (MyScaffold) created on the widget tree. So it is not good for performance. I also tried to use nested router, the problem is nested router is not supported by url that I can not navigate to the screen by typing the