我正在编写一个简单的优惠券应用程序,但是我在快速行动包方面挣扎。
我想做的是允许用户使用快速操作导航到屏幕。我创建了一个快速操作,并尝试导航到它,但是它不起作用。
当我单击快速操作时,它会将我重定向到应用程序的主屏幕。这不是我想要的。
import 'package:flutter/material.dart';
import './route_generator/route_generator.dart';
import 'package:quick_actions/quick_actions.dart';
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
final quickactions quickactions = quickactions();
quickactions.initialize((shortcutType) {
if (shortcutType == 'cheeseburger') {
Navigator.of(context).pushNamed('/generatedMailCouponScreen',arguments: 'assets/images/without_logo_coupon_cheeseburger.png');
}
});
quickactions.setShortcutItems([
ShortcutItem(
type: 'cheeseburger',localizedTitle: 'Cheeseburger'
)
]);
return MaterialApp(
initialRoute: '/',onGenerateRoute: RouteGenerator.generateRoute,theme: _theme()
);
}
}
ThemeData _theme() {
const LargeTextSize = 26.0;
const MediumTextSize = 20.0;
const Body1TextSize = 16.0;
const Body2TextSize = 12.0;
const String FontNameDefault = 'Lato';
return ThemeData(
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),TargetPlatform.iOS: CupertinoPageTransitionsBuilder()
}
),appBarTheme: AppBarTheme(
color: Colors.blueGrey[700],textTheme: TextTheme(
title: TextStyle(
fontFamily: FontNameDefault,fontWeight: FontWeight.w300,fontSize: LargeTextSize
)
)
),tabBarTheme: TabBarTheme(
labelStyle: TextStyle(
fontFamily: FontNameDefault,fontSize: Body1TextSize,),unselectedLabelStyle: TextStyle(
fontFamily: FontNameDefault,fontSize: Body1TextSize
)
),indicatorColor: Colors.blueGrey[100],scaffoldBackgroundColor: Colors.blueGrey[600],textTheme: TextTheme(
title: TextStyle(
fontFamily: FontNameDefault,fontWeight: FontWeight.w600,fontSize: LargeTextSize,color: Colors.white
),body1: TextStyle(
fontFamily: FontNameDefault,body2: TextStyle(
fontFamily: FontNameDefault,fontSize: Body2TextSize,color: Colors.white
)
)
);
}