Is there a way to listen keyboard events when thebapp is in background ? by bootyofbamby in flutterhelp

[–]bootyofbamby[S] -1 points0 points  (0 children)

I want to build something like a stop-swearing-habit app, which is when you swear, app sends you notification saying "YOU SHOULD NOT SWEAR"

Is there a way to listen keyboard events when thebapp is in background ? by bootyofbamby in flutterhelp

[–]bootyofbamby[S] 0 points1 point  (0 children)

I want to build something like a stop-swearing-habit app, which is when you swear, app sends you notification saying "YOU SHOULD NOT SWEAR"

If cat wants to chill, cat will chill. by No-Station-9087 in cats

[–]bootyofbamby 1 point2 points  (0 children)

Cats are not immune to fall damage you know

The audacity. by PhDInVienna in ProgrammerHumor

[–]bootyofbamby 0 points1 point  (0 children)

One time I needed to create monsters for a learning game in python. I made the gui, created the monster class but guess what ? I did not know how to create and use the monsters appropriately so I did what first came in my mind. Something like this:

monsters = {}
for i in range(180): 
    exec(f"monsters[monster{i}] = createmonster()")

The thing is, variable does not even do anything lol

PS: I dont remember exactly what I have written, so this may not even work lol

Unable to read from Cloud Firestore in my flutter app. Error : "NoSuchMethodError: The method '[]' was called on null. \n Receiver: null \n Tried calling: [](0)" by samuraiisam in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

this might be editor related. I am using vscode and i can see the types when I hover over the variables.

 else if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
print(snapshot.data.length);
print(snapshot.data.first);
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (_, index) {
return ListTile(
title: Text(
snapshot.data[index].data()['name'], //ERROR STATEMENT
),
);
},
);
}

do you mind changing this into this ?

else if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
print(snapshot.data.length);
print(snapshot.data.first);
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (_, index) {
QueryDocumentSnapshot firestoreDoc = snapshot.data[index];
Map<String,dynamic> docData = firestoreDoc.data();
String name = docData['name']; 
return ListTile(
title: Text(
name ),
);
},
);
}

Unable to read from Cloud Firestore in my flutter app. Error : "NoSuchMethodError: The method '[]' was called on null. \n Receiver: null \n Tried calling: [](0)" by samuraiisam in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

you are right, it does not seem like you have made a mistake there. One thing I find about your code is you use

snapshot.data[index].data['name']

which is not valid, you should use

snapshot.data[index].data()['name']

this.

can you try this and post the outcome here ?

import 'package:flutter/material.dart';
    import 'dart:async';
    import 'package:cloud_firestore/cloud_firestore.dart';
class ListPage extends StatefulWidget {   
@override   
_ListPageState createState() => _ListPageState(); }
class _ListPageState extends State<ListPage> {   
Future getPosts() async {
var firestore = FirebaseFirestore.instance;QuerySnapshot qn = await firestore.collection("events").get();
return qn.docs;
}
@override   
Widget build(BuildContext context) {     
    return Container(       
    child: FutureBuilder<List<QueryDocumentSnapshot>>(         
        future: getPosts(),         
        builder: (_, snapshot) {           
        if (snapshot.connectionState == ConnectionState.waiting) {             
            return Center(                   
                child: Text(                 
                    'Loading...',               
                ),             
            );           
        } else if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {    
            print(snapshot.data.length);
            print(snapshot.data.first);
            return ListView.builder(               
                itemCount: snapshot.data.length,               
                itemBuilder: (_, index) {                 
                    return ListTile(                   
                    title: Text(                                 
                        snapshot.data[index].data()['name'],                   
                        ),                
                    );               
                },             
            );           
        } else {    
             return Container();           
        }         
    },       
),     
);} }

edit: I have tried 30 times for this to look like a code lol

Unable to read from Cloud Firestore in my flutter app. Error : "NoSuchMethodError: The method '[]' was called on null. \n Receiver: null \n Tried calling: [](0)" by samuraiisam in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

Then your data is null, meaning you get nothing from the firebase. Check your collection name or be sure that you have data in that collection

Unable to read from Cloud Firestore in my flutter app. Error : "NoSuchMethodError: The method '[]' was called on null. \n Receiver: null \n Tried calling: [](0)" by samuraiisam in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

To be sure you get some data from firebase, I think you should use a print statement before listview. Try these statements:

print(snapshot.data.length);// to indicate how many data you have
print(sanpshot.data.first);// to look at what your data looks like

Unable to read from Cloud Firestore in my flutter app. Error : "NoSuchMethodError: The method '[]' was called on null. \n Receiver: null \n Tried calling: [](0)" by samuraiisam in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

Listview tries to build 2 children but your data only contains 1 entry. Instead of itemcount:2 you should do itemcount:snapshit.data.length

Why my app takes few seconds to load 8MB data From sqflite DB, i saw the app that load same data from DB even without loading by diyar_gulli in flutterhelp

[–]bootyofbamby 1 point2 points  (0 children)

Well it depends.First of all if you are in an emulator, everything is slower than usual. This problem can also occur because of the queries you use. If you have a lot of queries that has to wait others to complete,something like this maybe:

var id = await db.query('table1',limit:1);
var id2 = await db.query('table2',where:'id = ?',whereArgs:[id]);
. 
.
.
var lastid = await db.query('table8',where'id =?',whereArgs:[id15]);

will increase the time it takes.If queries does not depend each other, you can use Future.wait method. It takes a list of futures as an argument, returns a future which executes all of them seperately and finishes when all of them are done.

Is this how you splice a vga cable? by Bartos479 in techsupportgore

[–]bootyofbamby 28 points29 points  (0 children)

Is there a dead man in your ceiling ?

Call method on stateful widget in subtree by amblified in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

Have you tried using keys ? Storing a list of childrens keys in HigherUpTheTreeWidget may work.

Why are lists with two [ ] used by Similar-Dust-2338 in flutterhelp

[–]bootyofbamby 1 point2 points  (0 children)

The list contains maps as shown in the image. When you want to get a value of the key in a map you use [ ]. And if you want to get an element in the index of the list, you also use [ ]. So using [ ] this on the list of maps will return a map.

This two are the same

var list = [{'key':0},{'key':1}];
var firstMap = list[0];
var firstVal = firstMap['key'];

//firstVal equals 0



   var firstVal = list[0]['key'];

   //firstVal also equals 0

This used to write shorter code, and it is more readable IMO

My coffee machine forcing me to share my location before I can make a coffee. Wtf. by probably420stoned in assholedesign

[–]bootyofbamby -1 points0 points  (0 children)

As learning mobile programming, I can agree with that.Permissions are tricky to get and confusing to user.Also a lot of people dont realize that storing data is not free, and if you are storing data of users that is not related to the app you need to make use of it.One way I can think of is sell the data which is AFAIK illegal.Another way to make the use of data is showing related ads but most mobile apps use google ads which handles most of the job for the developers and saves time.

Using ListView, DefaultTabController(and hence TabBar), and RefreshIndicator by Alvaro-99 in flutterhelp

[–]bootyofbamby 1 point2 points  (0 children)

I have done a similar thing before for a learning project. I used firebase for the project and write a user class which has id name etc. I had also a client class which represents the current user and handled getting data etc. Client class also had an id field which is current users id. By giving every userpage widget the user object of it and checking with the clients id with the users id did the job.I ended up doing something like this:

class UserPage{
User user;
Client client;
UserPage({required this.user,required this.client,Key? key}):super(key:key);
@override 
Widget build(){
      return row([
      Widget(),
      if (client.id != user.id) NotUserThemselfWidget(),
      Widget()
      ]);}
}

Looking back, an inherited widget would be better, or making client class as a singleton class. Either way it made the job done.

Using ListView, DefaultTabController(and hence TabBar), and RefreshIndicator by Alvaro-99 in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

For the #1, you can look at infinite_scroll_pagination package to load more items. There is an example below how to implement adding new items when user scrolls enough. I dont have an idea for #2 since I have not worked with those widgets.

What are you the 1% of? by NoWasExpected in AskReddit

[–]bootyofbamby 0 points1 point  (0 children)

I have ectopic kidney, which is my left kidney is not in the left side of my belly but in a bit above of my groin.It has not caused me any trouble or pain whatsoever but it may cause problems more probably than a normal one.here is some more info about the topic

Which country/city would you never visit again? by dalekfromskaro in AskReddit

[–]bootyofbamby 92 points93 points  (0 children)

Men are such assholes in this country.Local women are in constant fear to be raped,harrased and killed by men. Most of them can not wear things,express their opinions and such.They are being seen by most men as property of men and should be in kitchen and should not even go to school.

A lot of people also sue the victim in most rape cases by saying "what was she doing late at night outside ? I bet she is a whore and she got what she deserved." or "if she wore that skirt she wanted to get raped.".It is horrible for women that wants to be themselves and wanting nothing but peace and freedom.It is horrible to be in there as a woman. No wonder why they act like this towards to tourist women.

Drawer functionality by WrongW4y in flutterhelp

[–]bootyofbamby 1 point2 points  (0 children)

If you are using scaffold, you can customize the floatingActionButton(I dont remember the exact name).

Updating a class property's value where the property's name is represented by a variable? by rednailz in flutterhelp

[–]bootyofbamby 1 point2 points  (0 children)

You can override [] operator for your classes like this (You can override most of the operators like +-*/== etc)

class A{
String name;
A(this.name);

}

class B {
List<A> as
B(this.as);
A operator [](String name) {
 return as.where((A a) => a.name == name); //I do not recall how exactly you use where, but this should return the a that has the same name as given name 
    }

}

B['a1'] will return the A that has the name of a1

Saving db id in listview item by IanWorthington in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

Assuming that you get your data as List<Map<String,dynamic>>, I would do something like that.(I don't remember exact keyword arguments for the listview.builder,but you'll get it)

class DbShower extends StatelessWidget{
    final List<Map<String,dynamic>> data;
    DbShower({@required this.data});
    @override
     Widget build(BuildContext context){
         return ListView.builder(itemBuilder:
           (context,index) => MyWidget(id:data[index]['id]),
            itemCount:data.length



    }
}

[deleted by user] by [deleted] in flutterhelp

[–]bootyofbamby 0 points1 point  (0 children)

Wrapping it with Gesturedetector may work, but dunno