Now consider the below code where inside the onpress event of the elevated button we try to call two different methods.
ElevatedButton(
onPressed: () async {
await method1();
await method2();
},
child: const Text('Click'),
),
Here in order to group these two individual methods in a single line we can wrap them using the square bracket [] as shown below ๐ to convert them as a single list of method. This will help increase the code quality without affecting the logic.
ElevatedButton(
onPressed: () async => [await method1(), await method2()],
child: const Text('Click'),
),
Well thatโs it. ๐ Run the code to see it in action.
Like it
14