-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
Steps to reproduce
Run code bellow in Android platform and web individually.
Click floatingButton and see result.
Execution order should same in different platform,otherwise, it could potentially lead to critical bugs, or we may have to discuss implementing different logic for different platforms(But I'm not sure if the specific behavior will change with different versions. And I think it should not be handled this way).
Expected results
Console log result should be same.
Actual results
-
On Web:
res:0
res:2 -
On Android :
res:0
res:0
Code sample
Code sample
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const App());
}
class App extends StatefulWidget {
const App({Key? key}) : super(key: key);
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: Home(),
);
}
}
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(),
floatingActionButton: FloatingActionButton(
onPressed: () {
test1();
res = 2;
},
child: Icon(Icons.add),
),
);
}
int res = 0;
void test1() async {
print("res:$res");
await syncAction();
print("res:$res");
}
Future<int> syncAction() {
return SynchronousFuture(1);
}
}Screenshots or Video
No response
Logs
flutter version : 3.22.2 stable
Flutter Doctor output
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [版本 10.0.22631.3737], locale zh-CN)
• Flutter version 3.22.2 on channel stable at C:\Users\letpub_it_data\fvm\versions\3.13.9
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747b (5 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[√] Windows Version (Installed version of Windows is version 10 or higher)