Reverse Iterator for List?

You can now reverse the iteration of a list in Dart. Use the reversed getter on List. var fruits = [‘apples’, ‘oranges’, ‘pears’]; Iterable inReverse = fruits.reversed; var fruitsInReverse = inReverse.toList(); print(fruitsInReverse); // [pears, oranges, apples] You could shorten this to: var fruits = [‘apples’, ‘oranges’, ‘pears’]; print(fruits.reversed.toList()); See the API docs.

Using a SliverFillRemaining with a CustomScrollView and SliverList

For anyone that is looking for an answer to this, I have a solution that has been working well whenever I needed something similar. This is how I’ve managed it: class ScrollOrFitBottom extends StatelessWidget { final Widget scrollableContent; final Widget bottomContent; ScrollOrFitBottom({this.scrollableContent, this.bottomContent}); @override Widget build(BuildContext context) { return CustomScrollView( slivers: <Widget>[ SliverFillRemaining( hasScrollBody: false, … Read more

Flutter – Is it possible to extract data from a Future without using a FutureBuilder?

FutureBuilder is just a convenient helper to get the widget tree rebuilt when a Future completes. You can use funcThatReturnsFuture().then((result) { print(result); setState(() { someVal = result; }) }) or Future funcThatMakesAsyncCall() async { var result = await funcThatReturnsFuture(); print(result); setState(() { someVal = result; }) } The main limitation is that you can’t return … Read more

What is the difference between == and === in Dart?

Dart supports == for equality and identical(a, b) for identity. Dart no longer supports the === syntax. Use == for equality when you want to check if two objects are “equal”. You can implement the == method in your class to define what equality means. For example: class Person { String ssn; String name; Person(this.ssn, … Read more

How to wrap row items in a card with flutter

I fixed your code with the following changes: Removed Row widget inside Wrap. Removed Expanded widget. Add the property maxLines to your Text widget. Widget _buildCategories() { return Card( margin: const EdgeInsets.only(top: 20.0), child: Padding( padding: const EdgeInsets.all(20.0), child: Column( children: <Widget>[ Text( ‘Categories’, style: TextStyle(fontFamily: ‘MonteSerrat’, fontSize: 16.0), ), Wrap( children: <Widget>[ _checkBox(‘Gaming’), _checkBox(‘Sports’), … Read more

Flutter: password autofill

Flutter supports now autofill (password, email, username, etc.) ☑️ The merged pull request with an example: https://github.com/flutter/flutter/pull/52126 Example: @override Widget build(BuildContext context) { return AutofillGroup( child: Column( children: <Widget>[ TextField(controller: username, autofillHints: [AutofillHints.username]), Checkbox( value: isNewUser, onChanged: (bool newValue) { setState(() { isNewUser = newValue; }); }, ), if (isNewUser) TextField(controller: newPassword, autofillHints: [AutofillHints.newPassword]), if … Read more

How do I make some text tappable (respond to taps) in Flutter?

As seen on this answer, you can use an InkWell or a gesture detector. For example InkWell( child: Text(“Hello”), onTap: () {print(“value of your text”);}, ) Or var textValue = “Flutter” InkWell( child: Text(textValue), onTap: () {print(textValue);}, ) EDIT : As Collin Jackson suggested, you can also use a FlatButton FlatButton( onPressed: () {print(“Hello world”);}, … Read more