We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: HomePage(), // here navigatorObservers: [FlutterSmartDialog.observer], // here builder: FlutterSmartDialog.init(), ); } }
SmartDialog.showLoading(builder: (_) => CustomLoadingWidget);
SmartDialog.showLoading();
void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: HomePage(), // here navigatorObservers: [FlutterSmartDialog.observer], // here builder: FlutterSmartDialog.init( //default toast widget toastBuilder: (String msg) => CustomToastWidget(msg: msg), //default loading widget loadingBuilder: (String msg) => CustomLoadingWidget(msg: msg), //default notify widget notifyStyle: FlutterSmartNotifyStyle( successBuilder: (String msg) => CustomSuccessWidget(msg: msg), failureBuilder: (String msg) => CustomFailureWidget(msg: msg), warningBuilder: (String msg) => CustomWarningWidget(msg: msg), alertBuilder: (String msg) => CustomAlertWidget(msg: msg), errorBuilder: (String msg) => CustomErrorWidget(msg: msg), ), ), ); } }
void main() { MyFlutterBinding(); runApp(const MyApp()); } class MyFlutterBinding extends WidgetsFlutterBinding with BoostFlutterBinding {} class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); static Map<String, FlutterBoostRouteFactory> routerMap = { '/page/test': (settings, uniqueId) { return MaterialPageRoute(settings: settings, builder: (_) => const TestPage()); }, }; Route<dynamic>? _routeFactory(RouteSettings settings, String? uniqueId) { var func = routerMap[settings.name!]; // here return FlutterSmartDialog.boostMonitor(func?.call(settings, uniqueId)); } @override Widget build(BuildContext context) { // here final initSmartDialog = FlutterSmartDialog.init(); final boost = BoostLifecycleBinding.instance; if (!boost.navigatorObserverList.contains(FlutterSmartDialog.observer)) { boost.addNavigatorObserver(FlutterSmartDialog.observer); } return FlutterBoostApp( _routeFactory, appBuilder: (Widget home) { return MaterialApp( home: home, debugShowCheckedModeBanner: true, //here builder: (context, child) => initSmartDialog(context, home), ); }, ); } }
void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp.router( routeInformationParser: MyRouteParser(), routerDelegate: MyRouteDelegate(), // here builder: FlutterSmartDialog.init(), ); } } class MyRouteDelegate extends RouterDelegate<String> with PopNavigatorRouterDelegateMixin<String>, ChangeNotifier { @override Widget build(BuildContext context) { return Navigator( key: navigatorKey, onPopPage: _onPopPage, // here observers: [FlutterSmartDialog.observer], pages: List.generate(_stack.length, (index) { return MaterialPage(child: DemoPage(title: 'Route:${_stack[index]}')); }), ); } List<String> _stack = []; @override GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); @override String? get currentConfiguration => _stack.isNotEmpty ? _stack.last : null; @override Future<void> setNewRoutePath(String configuration) { _stack = [configuration]; return SynchronousFuture<void>(null); } static MyRouteDelegate of(BuildContext context) { return Router.of(context).routerDelegate as MyRouteDelegate; } void push(String newRoute) { _stack.add(newRoute); notifyListeners(); } void remove(String routeName) { _stack.remove(routeName); notifyListeners(); } bool _onPopPage(Route<dynamic> route, dynamic result) { if (_stack.isNotEmpty) { if (_stack.last == route.settings.name) { _stack.remove(route.settings.name); notifyListeners(); } } return route.didPop(result); } } class MyRouteParser extends RouteInformationParser<String> { @override Future<String> parseRouteInformation(RouteInformation routeInformation) { return SynchronousFuture(routeInformation.location ?? ''); } @override RouteInformation restoreRouteInformation(String configuration) { return RouteInformation(location: configuration); } } class DemoPage extends StatelessWidget { const DemoPage({Key? key, required this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(title)), body: Center( child: ElevatedButton( child: const Text('Click Me'), onPressed: () => _showDialog(context), ), ), ); } void _showDialog(BuildContext context) { SmartDialog.show(builder: (_) { return Container( height: 150, width: 150, color: Colors.white, alignment: Alignment.center, child: ElevatedButton( child: const Text('to next page'), onPressed: () => MyRouteDelegate.of(context).push('Route$hashCode'), ), ); }); } }
void main() => runApp(const App()); class App extends StatelessWidget { const App({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp.router( // here builder: FlutterSmartDialog.init(), // here routerDelegate: _appRouter.delegate( navigatorObservers: [FlutterSmartDialog.observer], ), routeInformationParser: _appRouter.defaultRouteParser(), ); } }
void main() => runApp(const App()); class App extends StatelessWidget { const App({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp.router( // here builder: FlutterSmartDialog.init(), routerConfig: GoRouter( initialLocation: '/' // here observers: [FlutterSmartDialog.observer], routes: <GoRoute>[], ), ); } }
void main() => runApp(const App()); class App extends StatelessWidget { const App({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp.router( // here builder: FlutterSmartDialog.init(), routerDelegate: RoutemasterDelegate( // here observers: [FlutterSmartDialog.observer], routesBuilder: (context) => RouteMap(routes: { '/': (_) => MaterialPage(child: Container()), }), ), routeInformationParser: const RoutemasterParser(), ); } }
The text was updated successfully, but these errors were encountered:
看了上述初始化发现没有fluent_ui库的初始化方法,我最近使用fluent_ui库开发桌面程序,怎么初始化smartdialog呢?因为main.dart里面他需要用FluentApp.router,而不是MaterialApp,希望大佬指点,感激不尽
Sorry, something went wrong.
No branches or pull requests
MaterialApp场景初始化
配置全局自定义样式
SmartDialog.showLoading(builder: (_) => CustomLoadingWidget);
SmartDialog.showLoading();
各类场景初始化
flutter_boost场景
MaterialApp.router场景
auto_route场景
go_router场景
routemaster场景
The text was updated successfully, but these errors were encountered: