-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
91 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; | ||
|
||
void main() => runApp(const MyApp()); | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
home: Scaffold( | ||
body: Center( | ||
child: ElevatedButton( | ||
onPressed: () => _show(), | ||
child: const Text('show'), | ||
), | ||
), | ||
), | ||
navigatorObservers: [FlutterSmartDialog.observer], | ||
builder: FlutterSmartDialog.init(), | ||
); | ||
} | ||
|
||
void _show() async { | ||
print("before:${DateTime.now().millisecondsSinceEpoch}"); | ||
var result = await SmartDialog.show<bool>( | ||
tag: 'tag', | ||
backDismiss: false, | ||
clickMaskDismiss: false, | ||
builder: (_) { | ||
return ElevatedButton( | ||
onPressed: () { | ||
SmartDialog.dismiss(tag: 'tag', result: true); | ||
}, | ||
child: const Text('关闭Dialog,显示Loading'), | ||
); | ||
}, | ||
onDismiss: () { | ||
print("onDismiss:${DateTime.now().millisecondsSinceEpoch}"); | ||
// showLoading()放在这里能正常显示 | ||
// SmartDialog.showLoading(); | ||
}); | ||
|
||
print("aftermiss:${DateTime.now().millisecondsSinceEpoch}"); | ||
if (result == true) { | ||
// showLoading() 放在这里需要加一点延时才能显示Loading | ||
// await Future.delayed(const Duration(seconds: 1)); | ||
SmartDialog.showLoading(); | ||
|
||
// 延时关闭Loading | ||
await Future.delayed(const Duration(seconds: 2)); | ||
SmartDialog.dismiss(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters