编译Flutter应用时出现错误:
Because every version of flutter_test from sdk depends on path 1.8.1 and easy_localization 3.0.0 depends on path >=1.8.0-nullsafety <=1.8.0, flutter_test from sdk is incompatible with easy_localization
3.0.0.
And because no versions of easy_localization match >3.0.0 <4.0.0, flutter_test from sdk is incompatible with easy_localization ^3.0.0.
So, because zcart depends on both easy_localization ^3.0.0 and flutter_test from sdk, version solving failed.
Running "flutter pub get" in zcart...
pub get failed (1; So, because zcart depends on both easy_localization ^3.0.0 and flutter_test from sdk, version solving failed.)
这是我的main.dart文件:
import 'package:easy_dynamic_theme/easy_dynamic_theme.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:nb_utils/nb_utils.dart';
import 'package:zcart/Theme/theme.dart';
import 'package:zcart/config/config.dart';
import 'package:zcart/data/network/api.dart';
import 'package:zcart/helper/constants.dart';
import 'package:zcart/riverpod/providers/logger_provider.dart';
import 'package:zcart/translations/codegen_loader.g.dart';
import 'package:zcart/translations/supported_locales.dart';
import 'views/screens/startup/loading_screen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize the localizations
await EasyLocalization.ensureInitialized();
//Shared Pref Initialization
await initialize();
//Hive Initialization
await Hive.initFlutter();
await Hive.openBox(hiveBox);
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
//Run the app
runApp(
EasyDynamicThemeWidget(
child: EasyLocalization(
path: "assets/translations",
supportedLocales: supportedLocales,
fallbackLocale: const Locale("en"),
assetLoader: const CodegenLoader(),
child: ProviderScope(
observers: [Logger()],
child: const MyApp(),
),
),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
locale: context.locale,
debugShowCheckedModeBanner: false,
title: API.appName,
themeMode: MyConfig.isDynamicThemeActive
? EasyDynamicTheme.of(context).themeMode == ThemeMode.system
? ThemeMode.light
: EasyDynamicTheme.of(context).themeMode
: ThemeMode.light,
theme: AppTheme.light(context),
darkTheme: AppTheme.dark(context),
home: const LoadingScreen(),
);
}
}
这是我的pubspec.yaml文件
#Don't Change anything here
name: zcart
description: A multivendor E commerce App.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
#Only Chnage this value to update your version
#1.0.0 is version number and 1 is build number
version: 2.0.1+2
#Don't Change Anything From here
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
flutter_riverpod: ^0.14.0
http: ^0.13.3
flutter_widget_from_html: ^0.8.0
carousel_slider: ^4.0.0
flutter_rating_bar: ^4.0.0
shimmer: ^2.0.0
flutter_slidable: ^0.6.0
nb_utils: ^4.2.3
velocity_x: ^3.3.0
share: ^2.0.1
datetime_picker_formfield: ^2.0.0
flutter_countdown_timer: ^4.1.0
font_awesome_flutter: ^9.1.0
google_fonts: ^2.1.0
flutter_spinkit: ^5.0.0
cupertino_icons: ^1.0.0
animations: ^2.0.1
easy_localization: ^3.0.0
easy_dynamic_theme: ^2.2.0
google_sign_in: ^5.0.7
flutter_facebook_auth: ^3.5.1
hive: ^2.0.4
hive_flutter: ^1.1.0
device_info: ^2.0.2
flutter_credit_card: ^3.0.0
flutter_paystack: ^1.0.5+1
flutter_paypal: ^0.0.8
sign_in_with_apple: ^3.2.0
url_launcher: ^6.0.12
razorpay_flutter:
git:
url: git://github.com/devShakib015/razorpay-flutter.git
dev_dependencies:
flutter_test:
sdk: flutter
flutter_native_splash: ^1.2.1
flutter_lints: ^1.0.4
flutter:
uses-material-design: true
assets:
- assets/images/
- assets/translations/
flutter_native_splash:
# This package generates native code to customize Flutter's default white native splash screen
# with background color and splash image.
# Customize the parameters below, and run the following command in the terminal:
# flutter pub run flutter_native_splash:create
# To restore Flutter's default white splash screen, run the following command in the terminal:
# flutter pub run flutter_native_splash:remove
# color or background_image is the only required parameter. Use color to set the background
# of your splash screen to a solid color. Use background_image to set the background of your
# splash screen to a png image. This is useful for gradients. The image will be stretch to the
# size of the app. Only one parameter can be used, color and background_image cannot both be set.
color: "#f5f5f5"
#background_image: "assets/splash.png"
# Optional parameters are listed below. To enable a parameter, uncomment the line by removing
# the leading # character.
# The image parameter allows you to specify an image used in the splash screen. It must be a
# png file and should be sized for 4x pixel density.
image: assets/images/splash.png
# The color_dark, background_image_dark, and image_dark are parameters that set the background
# and image when the device is in dark mode. If they are not specified, the app will use the
# parameters from above. If the image_dark parameter is specified, color_dark or
# background_image_dark must be specified. color_dark and background_image_dark cannot both be
# set.
#color_dark: "#042a49"
#background_image_dark: "assets/dark-background.png"
#image_dark: assets/splash-invert.png
# The android, ios and web parameters can be used to disable generating a splash screen on a given
# platform.
#android: false
#ios: false
#web: false
# The position of the splash image can be set with android_gravity, ios_content_mode, and
# web_image_mode parameters. All default to center.
#
# android_gravity can be one of the following Android Gravity (see
# https://developer.android.com/reference/android/view/Gravity): bottom, center,
# center_horizontal, center_vertical, clip_horizontal, clip_vertical, end, fill, fill_horizontal,
# fill_vertical, left, right, start, or top.
#android_gravity: center
#
# ios_content_mode can be one of the following iOS UIView.ContentMode (see
# https://developer.apple.com/documentation/uikit/uiview/contentmode): scaleToFill,
# scaleAspectFit, scaleAspectFill, center, top, bottom, left, right, topLeft, topRight,
# bottomLeft, or bottomRight.
#ios_content_mode: center
#
# web_image_mode can be one of the following modes: center, contain, stretch, and cover.
#web_image_mode: center
# To hide the notification bar, use the fullscreen parameter. Has no affect in web since web
# has no notification bar. Defaults to false.
# NOTE: Unlike Android, iOS will not automatically show the notification bar when the app loads.
# To show the notification bar, add the following code to your Flutter app:
# WidgetsFlutterBinding.ensureInitialized();
# SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom, SystemUiOverlay.top]);
fullscreen: true
# If you have changed the name(s) of your info.plist file(s), you can specify the filename(s)
# with the info_plist_files parameter. Remove only the # characters in the three lines below,
# do not remove any spaces:
#info_plist_files:
# - 'ios/Runner/Info-Debug.plist'
# - 'ios/Runner/Info-Release.plist'
# To enable support for Android 12, set the following parameter to true. Defaults to false.
#android12: true