Answers for "future.delayed"

6

future delayed flutter

Future.delayed(Duration(seconds: 5), () {
  // 5s over, navigate to a new page
  Navigator.pushNamed(context, MaterialPageRoute(builder: (_) => Screen2()));
});
Posted by: Guest on March-17-2021
1

sleep in dart

import 'dart:io';

main() {
  sleep(const Duration(seconds:1));
}
Posted by: Guest on November-01-2020
0

dart language asynchronous ??

import 'dart:async';

void main() {
  final myFuture = Future(() {
    print("Hello from the future!");
    return true;
  });

  print("Done!");
}
Posted by: Guest on January-04-2021
0

future as a parameter with async in flutter

FloatingActionButton(
  onPressed: () => getImageFromCam(index),
  tooltip: 'Pick Image',
  child: Icon(Icons.add_a_photo),
);

...

Future<void> getImageFromCam(int index) async {
  // Do whatever you want with `index`.
  final image = await ImagePicker.pickImage(source: ImageSource.camera);
  setState(() => _image = image);
}
Posted by: Guest on December-27-2020

Code answers related to "Dart"

Browse Popular Code Answers by Language