Posts

Showing posts with the label dart

Warp text on a row with an input

Image
Warp text on a row with an input I have a situation where I need to wrap text with an input in Flutter. An example: 'The cat goes <TextField> , the dog goes bark.' <TextField> I'm using the Row class to format it this way, however, the row class doesn't wrap text. Widget _buildQuestionText(String sentence) { List splitSentence = sentence.split('$guess'); return new Container( child: Row( children: <Widget>[ new Text(splitSentence[0]), new Expanded(child: new TextField()), new Text(splitSentence[1]), ] ), ); } Which creates: I have looked at using the Flex class but was unable to achieve the format I wanted. How can I achieve text wrapping with an input in the middle of text? Just to be clear, are you trying to make multiple bits of text that each wrap, or do you want an entire sentence with an input in the middle of it with the entire thing wrapping? ...

My async call is returning before list is populated in forEach loop

My async call is returning before list is populated in forEach loop I have a routine which gets a list of filenames from the device, then reads the file(s) to build a list. However, the calling routine always returns with zero items. I print the filenames, so I know they exist, however, it appears that the async is returning before I read the files. I used similar code when making an HTTP call. But, something here is causing the routine to return the list even though it hasn't completed. Perhaps, it is possible that I am calling it at the wrong time? I am calling retrieveItems here: @override void initState() { super.initState(); retrieveItems(); } Eventually I will have a refresh button, but for now I'd simply like the list to populate with the data from the files... Callee Future<List<String>> readHeaderData() async { List<String> l = new List(); List<String> files = await readHeaders(); // Gets filenames files.forEach((filename...

Flutter: StreamBuilder uses old stream instead of new stream

Flutter: StreamBuilder uses old stream instead of new stream I'm trying to show a Google-Firestore real-time list on my Flutter app using Flutter's StreamBuilder. However, the stream seems to be using both the old data and the new data, instead of just the new one. (See below) //This is the widget with the stream Expanded( child: StreamBuilder<QuerySnapshot>( stream: _firestoreInstance.collection("seeks").document('145725').collection("classes").document(_chosenClass) .collection("classTopics").document(date).collection("dateTopics").snapshots(), builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot){ if (!snapshot.hasData) return Text('Loading...'); return ListView( children: snapshot.data.documents.map((DocumentSnapshot document){ debugPrint("DOCCUMENT ID: ${document.documentID} AND topic...