dart

Google Drive Consent Screen Stuck

馋奶兔 提交于 2021-02-16 05:20:58
问题 I am trying to backup the application data of my android app on Google Drive. Therefore I request access to the https://www.googleapis.com/auth/drive.appdata, https://www.googleapis.com/auth/drive.file scopes using the google_sign_in package. I created a project on the Google Developer Console, enabled the Drive API and added the scopes to the OAuth Consent Screen and added an OAuth Client ID with the package name and the SHA-1 of the debug key. The application works fine if I don't request

Can any one tell me how to open another app using flutter?

走远了吗. 提交于 2021-02-15 11:04:23
问题 I want to open a bunch of music app links using links data I have in firebase. I want to open, amazonPrimeMusic, Ganna, Spotify, Wynk, JioSavaan to name some. Widget buildResultCard(data) { List items = [Text(data['Ganna']), IconButton(icon:Icon(Icons.all_inclusive), onPressed: ()=> {Text("Ganna")} ), Text(data['Wynk']), IconButton(icon:Icon(Icons.all_inclusive), onPressed: ()=> {Text("Ganna")} ), Text(data['JioSavaan']), IconButton(icon:Icon(Icons.all_inclusive), onPressed: ()=> {Text("Ganna

forEach vs for in: Different Behavior When Calling a Method

回眸只為那壹抹淺笑 提交于 2021-02-15 07:48:08
问题 I noticed that forEach and for in to produce different behavior. I have a list of RegExp and want to run hasMatch on each one. When iterating through the list using forEach , hasMatch never returns true. However, if I use for in , hasMatch returns true. Here is a DartPad with sample code https://dartpad.dev/daab4a914762256369bbf582ffcfb7cd The only difference between the methods a and b is that a uses forEach and b uses for in , yet they produce different results. Why is this? 回答1: Although

Deleting Firestore Data in Flutter List View

烈酒焚心 提交于 2021-02-15 07:32:15
问题 I have a regular List View that fetches some data from Firestore, here is the code for it: body: StreamBuilder( stream: FirebaseFirestore.instance.collection('orders').snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return Center( child: CircularProgressIndicator(), ); return ListView.builder( itemCount: snapshot.data.docs.length, itemBuilder: (context, index) { DocumentSnapshot ds = snapshot.data.docs[index]; return Text(ds['name']); Now if I wanted to create a delete

Flutter学习笔记(4)--Dart函数

强颜欢笑 提交于 2021-02-14 11:34:08
如需转载,请注明出处: Flutter学习笔记(4)--Dart函数 Dart是一个面向对象的语言,所以函数也是对象,函数属于Function对象,函数可以像参数一样传递给其他函数,这样便于做回调处理; 一.指定返回值的函数 // 判断两个字符串是否相等 bool isEqual(String name1,String name2){ return name1 == name2; } print(isEqual( ' 张三 ' , ' 李四 ' )); // 打印结果:false 上面的示例我们指定了参数的类型,在不确定参数的类型的情况下,我们的参数可以用dynamic、object或var来接收参数 // 判断两个字符串是否相等 bool isEqual( dynamic name1, var name2){ return name1 == name2; } print(isEqual( ' 张三 ' , ' 李四 ' )); // 打印结果:false 二.不指定返回值的函数 // 判断两个字符串是否相等 isEqual(String name1,String name2){ return name1 == name2; } print(isEqual( ' 张三 ' , ' 李四 ' )); // 打印结果:false // 打印文本 isEqual( dynamic

Flutter学习笔记(5)--Dart运算符

寵の児 提交于 2021-02-14 11:14:37
如需转载,请注明出处: Flutter学习笔记(5)--Dart运算符 先给出一个Dart运算符表,接下来在逐个解释和使用。如下: 描述 运算符 一元后缀 expr++  expr--  ()  []  .  ?. 一元前缀 -expr  !expr  ~expr  ++expr  --expr 乘法类型 *  /  %  ~/ 加法类型 +  - 移位运算符 <<  >> 与位运算 & 异或位运算 ^ 或位运算 | 关系和类型测试 >=  <=  >  <  as  is  is! 等式 ==   != 逻辑与 && 逻辑或 || 条件 expr1?expr2:expr3 级联 .. 赋值 =  *=  /=  ~/=  %=  +=  -=  <<=  >>=  &=  ^=  |=  ??= 注:在上面的运算符表中,操作符的优先级由上到下逐个减小,上面行内的操作符优先级大于下面行内的操作符; 一.算数运算符 int a = 10 ; int b = 2 ; print(a + b); // 12 print(a - b); // 8 print(a * b); // 20 print(a / b); // 5.0 这个不是整除,值是duoble类型的 print(a ~/ b); // 5 整除,余数部分舍弃取整 print(a % b); // 0 去余数 var ++,

Flutter之Container详解

↘锁芯ラ 提交于 2021-02-12 04:55:45
1 基本内容 1.1 继续关系 Object > Diagnosticable > DiagnosticableTree > Widget > StatelessWidget > Container 注:所有控件都是Widget的子类! 1.2 介绍 一个便利的控件,结合了常见的绘画,定位和大小调整。 1.3 行为 由于Container结合了许多其他Widget,每个Widget都有自己的布局行为,因此Container的布局行为有点复杂。 依次是: 1.采用alignment 2.以child调整自身大小 3. 采用了width,height和constraints 4.扩大以适应父Widget 5.要尽可能小 具体情况来说: 1· 如果Container没有子Widget,没有height,没有width,没有constraints,并且父窗口提供无限制约束,则Container尝试尽可能小。 2· 如果Container没有子Widget,没有alignment,而是一个height,width或 constraints提供,Container试图给出这些限制和父Widget的约束相结合,以尽可能小。 3· 如果Container没有子Widget,没有height,没有width,没有constraints,没有alignment,但是父窗口提供了有界约束

Does dart allows users to write platform specific implementation?

风流意气都作罢 提交于 2021-02-11 18:22:49
问题 If not - are there are any plans to make it so? I know that dart itself has different backends that might have different implementation. I was curious if users can do the same, e.g. have a function that delegates to one @patch for js runtime and to another @patch in case of dart vm. 回答1: If you're creating a package, you can export different implementations for different platforms, see here: https://dart.dev/guides/libraries/create-library-packages#conditionally-importing-and-exporting

How to handle invalid value: valid value range is empty using ? operator

二次信任 提交于 2021-02-11 18:20:01
问题 var items = []; var index = 0; var value = items[index]; // returns invalid value error, understood! I should rather use following to prevent the error if (index < items.length) { value = items[index]; } Since there are ? operators in Dart, I wanted to know is there any way I can do something like: var value = items?.[0] ?? -1; var value = items?[0] ?? -1; 回答1: No. ? is used to for null -aware operators (or for the ternary operator). Accessing an invalid element of a List throws an exception

Flutter Await not waiting

北城余情 提交于 2021-02-11 18:00:43
问题 Why won't the program wait for the function to return the list before going to the print statement? I think it's because I made the forEach loop async but I need it to be async to get the newSummary which is a Future. Future syncToCloud() async{ final List<Map<String,dynamic>> _events = await events(); print(_events.length); } Future<List<Map<String, dynamic>>> events() async { List<Map<String, dynamic>> maps = await db.query('data'); List<Map<String, dynamic>> newMaps=[]; maps.forEach(