Migrating to angulardart 4.0.0 fails with message Unsupported operation: Using the 'angular2' transformer is required - angular-dart

I just migrated my project from angulardart 3.1.0 to 4.0.0 my pubspec.yaml was:
dependencies:
angular2: ^3.1.0
http: ^0.11.0
#...other deps
dev_dependencies:
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
entry_points: web/main.dart
resolved_identifiers:
BrowserClient: 'package:http/browser_client.dart'
Client: 'package:http/http.dart'
- dart_to_js_script_rewriter
- $dart2js:
sourceMaps: true
and became :
dependencies:
angular: ^4.0.0
angular_router: ^1.0.2
angular_components: ^0.8.0
http: ^0.11.0
#... other deps
dev_dependencies:
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular:
entry_points: web/main.dart
- $dart2js:
sourceMaps: true
- dart_to_js_script_rewriter
My issue is that in dartium (Version 50.0.2661.108 (64-bit) "on mac") I have this error on startup:
VM970:1 Uncaught Unhandled exception:
Unsupported operation: Using the 'angular2' transformer is required.
Please see https://webdev.dartlang.org/angular/tutorial for setup instructions,
and ensure your 'pubspec.yaml' file is configured to invoke the 'angular2'
transformer on your application's entry point.
#0 bootstrap (package:angular/src/platform/bootstrap.dart:107:5)
#1 main (http://localhost:3000/web/main.dart:50:3)
<asynchronous suspension>
And when I try to run pub build it does not recognize ngIf and ngFor :
Error: Template parse errors: line 13, column 11 of UserListPopup: ParseErrorLevel.FATAL: Property binding ngIf not used by any directive on an embedded template
For reference, this is my entire pubspec.yaml now:
name: share_place
description: Collaborate around your documents in a seamless way
version: 0.0.1
environment:
sdk: '>=1.24.0 <2.0.0'
dependencies:
angular: ^4.0.0
angular_router: ^1.0.2
angular_components: ^0.8.0
http: ^0.11.0
stream_transformers: ^0.3.0
http_server: any
js: ^0.6.0
uuid: ^0.5.3
croppie_dart: ^2.4.1
stack_trace: any
source_map_stack_trace: any
source_maps: any
validator: ">=0.0.4 <0.1.0"
dev_dependencies:
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular:
entry_points:
- web/main.dart
- $dart2js:
sourceMaps: true
- dart_to_js_script_rewriter
This is reproducible on twos machines I tested to upgrade dart on (windows and mac). I still didn't try to uninstall reinstall
Here's the content of my main.dart there's nothing special I think:
int version;
Future loadLastVersion() async {
String version = await html.HttpRequest.getString('/sp/util/loadAppVersion');
if (conf.appVersion != version) {
if (conf.isWebApp) {
html.window.alert("you have an old version : ${conf.appVersion} we must load the new version :${version}");
html.window.location.assign("${conf.remoteUrl}/v${version}");
} else {
html.window.alert("A new version ${version} is available! Please download it from : https://www.share.place/downloads");
}
}
}
Future main() async {
loadLastVersion();
Logger.root.level = Level.FINE;
Logger.root.onRecord.listen((LogRecord rec) {
if (rec.level == Level.SEVERE || rec.level == Level.WARNING)
html.window.console.error('${rec.level.name} - ${rec.loggerName} : ${rec.message}');
else if (rec.level == Level.INFO)
html.window.console.info('${rec.level.name} - ${rec.loggerName} : ${rec.message}');
else
html.window.console.debug('${rec.level.name} - ${rec.loggerName} : ${rec.message}');
});
bootstrap(AppComponent, [provide(Client, useClass: BrowserDataService), provide(ExceptionHandler, useClass: ErrorHandler), Environment, EventBus]
// Using a real back end? Import browser_client.dart and change the above to
// [provide(Client, useFactory: () => new BrowserClient(), deps: [])]
);
}

This is not supported anymore
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
You need to add to #Component(...)
directives: const [COMMON_DIRECTIVES]
pipes: const [COMMON_PIPES]
to every component where you use them.

Related

The Flutter build is stuck on the splash screen

Flutter build is stuck on the splash screen. I tried it on both a real device and the Pixel 4 Api33 emulator. Using Namal woocommerce source code available on codecanyon website and I am a beginner. I tried my best to figure out what's wrong but I failed. Asking for your help guys, please let me know if you need any other information.
**main.dart error log file on Pixel 4 Api33 emulator**
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
D/FlutterGeolocator(10640): Attaching Geolocator to activity
W/FlutterActivityAndFragmentDelegate(10640): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
D/FlutterGeolocator(10640): Creating service.
D/FlutterGeolocator(10640): Binding to location service.
D/FlutterLocationService(10640): Creating service.
D/FlutterLocationService(10640): Binding to location service.
D/FlutterGeolocator(10640): Geolocator foreground service connected
D/FlutterGeolocator(10640): Initializing Geolocator services
D/FlutterGeolocator(10640): Flutter engine connected. Connected engine count 1
Debug service listening on ws://127.0.0.1:54544/-pXfnrJ83sQ=/ws
Syncing files to device sdk gphone64 x86 64...
V/OneSignal(10640): Initializing the OneSignal Flutter SDK (3.3.2)
D/OneSignal(10640): Adding a task to the pending queue with ID: 1
D/OneSignal(10640): startPendingTasks with task queue quantity: 1
D/OneSignal(10640): Attempted to clean 6 month old IAM data, but none exists!
D/OneSignal(10640): OneSignal InAppMessageTracker initInfluencedTypeFromCache: OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}
D/OneSignal(10640): OneSignal NotificationTracker initInfluencedTypeFromCache: OSChannelTracker{tag=notification_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}
D/OneSignal(10640): OneSignal getUnattributedUniqueOutcomeEventsSentByChannel: null
W/OneSignal(10640): appContext set, but please call setAppId(appId) with a valid appId to complete OneSignal init!
V/OneSignal(10640): setAppId called with id: YOUR_ONESIGNAL_APP_ID changing id from: null
V/OneSignal(10640): Starting OneSignal initialization!
D/OneSignal(10640): Retrieved IAMs from DB redisplayedInAppMessages: []
V/OneSignal(10640): No class found, not setting up OSRemoteNotificationReceivedHandler
I/OneSignal(10640): Last Pending Task has ran, shutting down
V/OneSignal(10640): OneSignal SDK initialization delayed, waiting for remote params.
D/OneSignal(10640): Starting request to get Android parameters.
D/OneSignal(10640): OneSignalRestClient: Making request to: https://api.onesignal.com/apps/YOUR_ONESIGNAL_APP_ID/android_params.js
W/SQLiteLog(10640): (28) double-quoted string literal: "notification"
D/OneSignal(10640): OneSignalRestClient: Adding header if-none-match: W/"05702b137a259242f45cdd80824abb9f"
D/TrafficStats(10640): tagSocket(135) with statsTag=0x2710, statsUid=-1
V/OneSignal(10640): OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/apps/YOUR_ONESIGNAL_APP_ID/android_params.js
D/OneSignal(10640): OneSignalRestClient: GET - Using Cached response due to 304: {"awl_list":{},"receive_receipts_enable":false}
D/OneSignal(10640): OneSignal saveInfluenceParams: InfluenceParams{indirectNotificationAttributionWindow=1440, notificationLimit=10, indirectIAMAttributionWindow=1440, iamLimit=10, directEnabled=false, indirectEnabled=false, unattributedEnabled=false}
D/OneSignal(10640): reassignDelayedInitParams with appContext: androidx.multidex.MultiDexApplication#7610e7d
V/OneSignal(10640): setAppId called with id: YOUR_ONESIGNAL_APP_ID changing id from: null
V/OneSignal(10640): Starting OneSignal initialization!
V/OneSignal(10640): No class found, not setting up OSRemoteNotificationReceivedHandler
E/OneSignal(10640): OneSignal AppId format is invalid.
E/OneSignal(10640): Example: 'b2f7f966-d8cc-11e4-bed1-df8f05be55ba'
E/OneSignal(10640):
E/OneSignal(10640): java.lang.IllegalArgumentException: Invalid UUID string: YOUR_ONESIGNAL_APP_ID
E/OneSignal(10640): at java.util.UUID.fromString(UUID.java:194)
E/OneSignal(10640): at com.onesignal.OSUtils.initializationChecker(OSUtils.java:118)
E/OneSignal(10640): at com.onesignal.OneSignal.init(OneSignal.java:841)
E/OneSignal(10640): at com.onesignal.OneSignal.setAppId(OneSignal.java:735)
E/OneSignal(10640): at com.onesignal.OneSignal.reassignDelayedInitParams(OneSignal.java:1181)
E/OneSignal(10640): at com.onesignal.OneSignal.onRemoteParamSet(OneSignal.java:889)
E/OneSignal(10640): at com.onesignal.OneSignal$7.complete(OneSignal.java:1122)
E/OneSignal(10640): at com.onesignal.OneSignalRemoteParams.processJson(OneSignalRemoteParams.java:211)
E/OneSignal(10640): at com.onesignal.OneSignalRemoteParams.access$100(OneSignalRemoteParams.java:12)
E/OneSignal(10640): at com.onesignal.OneSignalRemoteParams$1.onSuccess(OneSignalRemoteParams.java:156)
E/OneSignal(10640): at com.onesignal.OneSignalRestClient$5.run(OneSignalRestClient.java:279)
E/OneSignal(10640): at java.lang.Thread.run(Thread.java:1012)
V/OneSignal(10640): initWithContext called with: androidx.multidex.MultiDexApplication#7610e7d
V/OneSignal(10640): Starting OneSignal initialization!
V/OneSignal(10640): No class found, not setting up OSRemoteNotificationReceivedHandler
I/flutter (10640): --> GET https://sidemenclothing.in/wp-json/api/tc_settings/app_all_settings
I/flutter (10640): {clientid: 1234, clientsecret: sk_1234, X-Requested-With: XMLHttpRequest, authorization: }
[log]
<-- START PARAMS:
null
END PARAMS -->
<-- END HTTP
I/flutter (10640): Hivedata
I/flutter (10640): Instance of 'BoxImpl<WooCartData>'
E/flutter (10640): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 0
E/flutter (10640): #0 List.[] (dart:core-patch/growable_array.dart:264:36)
E/flutter (10640): #1 _SplashScreenState.getCart (package:flutter_kundol/ui/screens/splash_screen.dart:136:28)
E/flutter (10640): <asynchronous suspension>
E/flutter (10640):
I/flutter (10640): <-- 200 GET https://sidemenclothing.in/wp-json/api/tc_settings/app_all_settings
[log]
<-- START RESPONSE:
{last_tab: 1, home_style: 1, category_style: 1, banner_style: 3, card_style: 1, cancel_order_button: 0, cancel_order_hours: 1, package_name: app.beastdeals, site_url: https://sidemenclothing.in/, new_product_duration: 5, filter_max_price: 100000, update_order: 10, one_page_checkout: 1, checkout_process: yes, custom_css_for_checkout: .site-header, nav, #secondary, footer {display: none!important;}, contact_us_email: info#domain-name.com, from_email: from#domain-name.com, phone_no: +92 123 456-789, address: 228 Park avs, city: New York, state: NY, Zip: 10003, Country: USA, Latitude: 40.730610, Longitude: -73.935242, sidebar_menu_icon: 0, wish_list_page: 0, edit_profile_page: 0, shipping_address_page: 0, my_orders_page: 0, contact_us_page: 0, about_us_page: 0, bill_ship_info: 0, downloads: 0, news_page: 0, intro_page: 0, share_app: 0, rate_app: 0, setting_page: 0, notification_title: Theme Coder, notification_text: A bundle of products wating for you!, notification_duration: 0, facebook_login: 0, about_page_id: , refund_page_id: , privacy_page_id: , terms_page_id: , wpml_enabled: 0, mvf_enabled: 0, wp_point_reward: 0, wp_multi_currency: 0, delivery_tracking: 0, tracking_url: http://urltracking.com/, geo_fencing: 0, one_signal_notification: 0, one_signal_app_id: , one_signal_app_key: , privacy_page: , refund_page: , terms_page: , about_page: , currency: {name: INR, position: left}, language: {name: en_US}}
END RESPONSE -->
<-- END HTTP
E/flutter (10640): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter (10640): #0 _SplashScreenState.build.<anonymous closure> (package:flutter_kundol/ui/screens/splash_screen.dart:74:76)
E/flutter (10640): #1 _BlocListenerBaseState._subscribe.<anonymous closure> (package:flutter_bloc/src/bloc_listener.dart:204:24)
E/flutter (10640): #2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
E/flutter (10640): #3 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (10640): #4 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
E/flutter (10640): #5 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
E/flutter (10640): #6 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
E/flutter (10640): #7 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (10640): #8 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (10640):
D/EGL_emulation(10640): app_time_stats: avg=988.05ms min=162.14ms max=1813.96ms count=2
**pubsec.yml file**
name: flutter_kundol
description: A new Flutter ecommerce application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: '>=2.17.6 <3.0.5'
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
flutter_bloc: ^7.3.3 # need to change InitialState implementations for above 7.3.3
equatable: ^2.0.5
shared_preferences: ^2.0.15
carousel_slider: ^4.1.1
dio: ^4.0.6
cached_network_image: ^3.2.1
flutter_html: ^2.2.1
# flutter_range_slider: "^1.5.0"
firebase_auth: ^4.1.1
google_sign_in: ^5.4.1
firebase_core: ^2.1.1
flutter_login_facebook: ^1.6.0
share: ^2.0.4
in_app_review: ^2.0.4
onesignal_flutter: ^3.4.1
flutter_svg: ^0.23.0+1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.5
launch_review: ^3.0.1
dropdown_search: ^1.0.0
google_maps_place_picker_mb: ^2.0.0-mb.22
google_maps_flutter: ^2.1.12
bubble_tab_indicator: ^0.1.6
webview_flutter: ^2.8.0
url_launcher: ^6.1.5
hive: ^2.2.3
path_provider: ^2.0.11
hive_flutter: ^1.1.0
dev_dependencies:
hive_generator: ^1.1.3
build_runner: ^2.2.0
change_app_package_name: ^1.1.0
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/langs/
- assets/images/
- assets/icons/
- assets/json/
fonts:
- family: MontserratRegular
fonts:
- asset: assets/fonts/Montserrat-Regular.ttf
- family: MontserratLight
fonts:
- asset: assets/fonts/Montserrat-Light.ttf
- family: MontserratMedium
fonts:
- asset: assets/fonts/Montserrat-Medium.ttf
- family: MontserratBold
fonts:
- asset: assets/fonts/Montserrat-Bold.ttf
- family: MontserratSemiBold
fonts:
- asset: assets/fonts/Montserrat-SemiBold.ttf
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

Hive generate adapter could not generate outputs

I am having issue generating the hive type adapter. No such output generated by the command line codes
flutter packages pub run build_runner build --delete-conflicting-outputs
or
flutter packages pub run build_runner build
final output massage is appaired as Succeeded after 101ms with 0 outputs (0 actions)
import 'package:hive/hive.dart';
part 'person2.g.dart';
#HiveType(typeId:1)
class Person {
const Person({required this.age,required this.friends,required this.person});
#HiveField(0)
final String person;
#HiveField(1)
final int age;
#HiveField(2)
final List<Person> friends;
}
my pubspec.yamel file
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
hive: ^2.1.0
hive_flutter: ^1.1.0
pdf: ^3.1.0
path_provider: ^2.0.1
open_file: ^3.1.0
intl: ^0.17.0
dev_dependencies:
flutter_test:
sdk: flutter
hive_generator: ^1.1.2
build_runner: ^2.1.10

Flutter cloud_firestore: ^2.0.0 build failure

When I use cloud_firestore: package that is less than version ^2.0.0, everything works fine. But when I upgrade to cloud_firestore: ^2.0.0, I get a error: Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
Here's the full error that I get:
An exception has occurred in the compiler (1.8.0_212-release). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
at com.sun.tools.javac.util.Assert.error(Assert.java:133)
at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitVarDef(TypeAnnotations.java:1164)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1042)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.code.TypeAnnotations$1.run(TypeAnnotations.java:127)
at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:152)
at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:93)
at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:54)
at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:100)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
at org.gradle.api.internal.tasks.compile.CleaningJavaCompiler.execute(CleaningJavaCompiler.java:53)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory.lambda$createRebuildAllCompiler$0(IncrementalCompilerFactory.java:98)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:60)
at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:44)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:208)
at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:179)
at sun.reflect.GeneratedMethodAccessor2133.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
at org.gradle.api.internal.project.taskfactory.IncrementalInputsTaskAction.doExecute(IncrementalInputsTaskAction.java:32)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:568)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:553)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:536)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:109)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:276)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:265)
at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:63)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:153)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:67)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:41)
at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
at java.util.Optional.orElseGet(Optional.java:267)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:192)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:184)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.lang.Thread.run(Thread.java:748)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cloud_firestore:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Here the app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.XXXXXXXXX.yyyyyyy"
minSdkVersion 23
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
aaptOptions { cruncherEnabled = false }
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// Import the Firebase BoM
//implementation platform('com.google.firebase:firebase-bom:28.1.0')
implementation "com.android.support:multidex:1.0.3"
//The dependency below works
implementation platform('com.google.firebase:firebase-bom:29.0.0')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-analytics'
implementation("com.google.firebase:firebase-iid")
}
Here's the android/build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
//classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here's the flutter doctor report
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale en-ZA)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] Connected device (2 available)
• No issues found!
Here are the packages on pubspec.yaml
name: xxxx
description: A new Flutter application.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.15+15
environment:
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
sdk: flutter
sqflite: ^2.0.0+4
path_provider: ^2.0.5
intl: ^0.17.0
http: ^0.13.3
shared_preferences: ^2.0.8
json_annotation: ^4.1.0
dio: ^4.0.0
provider: ^6.0.1
badges: ^2.0.1
device_info: ^2.0.2
package_info: ^2.0.2
connectivity: ^3.0.6
pdf: ^3.6.0
printing: ^5.6.0
font_awesome_flutter: ^9.1.0
flutter_slidable: ^0.6.0
cached_network_image: ^3.1.0
share: ^2.0.4
file_picker: ^4.1.1
whatsapp_share2: ^2.0.2
url_launcher: ^6.0.12
image_picker: ^0.8.4+2
image_cropper: ^1.4.1
azblob: ^2.0.0
firebase_storage: ^10.0.3
permission_handler: ^8.1.6
contactus: ^1.2.0
firebase_messaging: ^10.0.7
firebase_core: ^1.10.0
flutter_local_notifications: ^8.2.0
contacts_service: ^0.6.3
# Package to use Firestore Database
cloud_firestore: ^3.1.0
#Works...doesn't crash during build
#cloud_firestore: ^1.0.0
#cloud_firestore: ^1.0.7 #works
firebase_auth: ^3.2.0
# Creates unique ID for items sent to Firestore. Else we would have to wait for Firebase to create ID for us
uuid: ^3.0.5
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.9.2
flutter_native_splash: ^1.2.4
# run to create splash screen: flutter clean && flutter pub get && flutter pub run flutter_native_splash:create
flutter_native_splash:
color: "#ffffff"
image: assets/splash.png
android: true
ios: true
flutter_icons:
android: true
ios: true
image_path: "dev_assets/pfama.jpg"
adaptive_icon_background: "#191919"
adaptive_icon_foreground: "dev_assets/pfama-adaptive.jpg"
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/kile.db
- images/placeholder_image.png
- images/placeholder_image2.png
- images/pfama_clear_logo.png
- assets/splash.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Raleway
fonts:
- asset: assets/fonts/Raleway-Regular.ttf
- asset: assets/fonts/Raleway-Bold.ttf
weight: 700
- asset: assets/fonts/Raleway-Black.ttf
weight: 900
- family: RobotoCondensed
fonts:
- asset: assets/fonts/RobotoCondensed-Regular.ttf
- asset: assets/fonts/RobotoCondensed-Bold.ttf
weight: 700
- asset: assets/fonts/RobotoCondensed-Light.ttf
weight: 300
- asset: assets/fonts/RobotoCondensed-Italic.ttf
style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
Try running with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Always make sure the newly added dependencies match the version of your gradle, you may need to either upgrade or downgrade the dependencies to match your gradle version, but most importantly, it's recommended to use the latest gradle version and match this with the latest plugin dependencies to avoid these errors.
Please refer to changelog for the breaking changes in each of the versions. See the migration guide for more information on how to update your code if using cloud_firestore : 2.0.0 and refer to this 1 and 2 for any other working versions of firebase products.
Also this seems to be an Androidx issue, the flutter version, plugin version, and how did you create the project all decide whether you have Androidx support. Have a look at a similar stackoverflow thread which revealed the issue lies in AndroidX.
One more error I observe here (because I was also facing same issue and found the solution), while declaring assets, especially fonts, I was declaring it is pybsec.yaml like this -
flutter:
fonts:
- family: Raleway
fonts:
- asset: assets/fonts/Raleway-Regular.ttf
- asset: assets/fonts/Raleway-Italic.ttf
style: italic
- family: RobotoMono
fonts:
- asset: assets/fonts/RobotoMono-Regular.ttf
- asset: assets/fonts/RobotoMono-Bold.ttf
weight: 700
But the asset url should include "lib" as well and it should be like this -
flutter:
fonts:
- family: Raleway
fonts:
- asset: lib/assets/fonts/Raleway-Regular.ttf
- asset: lib/assets/fonts/Raleway-Italic.ttf
style: italic
- family: RobotoMono
fonts:
- asset: lib/assets/fonts/RobotoMono-Regular.ttf
- asset: lib/assets/fonts/RobotoMono-Bold.ttf
weight: 700
Hope it helps you resolve at least asset related error.

app database generated file having errors in moor flutter

I am using moor package in flutter for my application. im following the instructions online
https://moor.simonbinder.eu/docs/getting-started/starting_with_sql/#what-moor-generates
but when i run the build command: flutter pub run build_runner build
the appdatabase.g.dart file that gets generated has errors. here is a snapshot of errors:
here is my dependencies
cupertino_icons: ^0.1.2
month_picker_dialog: ^0.3.1
flutter_cupertino_localizations: ^1.0.1
moor: ^2.3.0
provider: ^4.0.3
moor_ffi: ^0.4.0
path_provider: ^1.6.0
dev_dependencies:
flutter_test:
sdk: flutter
intl_translation: ^0.17.1
moor_generator: ^2.3.1
build_runner:
the problem seems to be with 'Table' class. there is a conflict between dart and moor. the message indicate there are two versions. how can i solve this problem so that my error goes away
the answer is to use import 'package:flutter/widgets.dart' hide Table;
dependencies:
flutter:
sdk: flutter
#moor database
moor_flutter: ^3.1.0
# For the UI
provider: ^4.3.1
# For OS-specific directory paths
path_provider: ^1.6.11
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
#new Dependencies add
moor_generator: ^3.2.0
build_runner:
Step 1 : delete file appdatabase.g.dart
step 2: flutter clean
Step 3: flutter pub get
Step 4: flutter pub run build_runner build watch
This error occurs when you don't have the 'import' of your table or dao in your AppDb class, in my case I have more than 90 tables and dao's, I separated then in a class with a static list, but I need do the imports of my files in the app_database.dart too, because of the error.
I have this class for tables:
import '../tables/table_one.dart';
import '../tables/table_two.dart';
class TableList {
static const List<Type> tables = [
TableOne,
TableTwo,
]
}
And another for Dao files:
import '../dao/table_one_dao.dart';
import '../dao/table_two_dao.dart';
class DaoList{
static const List<Type> daos= [
TableOne,
TableTwo,
]
}
And this is my AppDb class:
import '../tables/table_one.dart';
import '../tables/table_two.dart';
import '../dao/table_one_dao.dart';
import '../dao/table_two_dao.dart';
part 'app_db.g.dart';
#DriftDatabase(
tables: TableList.tables,
daos: DaoList.daos,
)
class AppDb extends _$AppDb {
AppDb() : super(_openConnection());
#override
int get schemaVersion => 1;
}
LazyDatabase _openConnection() {
return LazyDatabase(() async {
final dbFolder = await getApplicationDocumentsDirectory();
final file = File(p.join(dbFolder.path, 'app_database.db'));
return NativeDatabase(file);
});
}
As you see, i have to declare the imports again in my AppDb file to resolve. If you declare your tables directly in the AppDb escope, i think you don't have problem.

Flutter 1.0 - Unable to load text asset

I'm having some trouble loading text assets in flutter (1.0).
This is the current code attempting to read the asset.
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future<String> getFileData(String path) async {
return await rootBundle.loadString(path);
}
Future<File> get _localFile async {
final path = await _localPath;
final file = File('$path/toon_test_3.json');
bool exists = file.existsSync();
if(exists){
return file;
} else {
// Load the default file
final newfile = await getFileData('toonRepo/data.json');
return file.writeAsString(newfile);
}
}
loadString will failing popping up the following:
Could not load source 'dart:core/runtime/libobject_patch.dart': <source not available>.
If execution continues the following exception is raised:
Exception has occurred.
FlutterError (Unable to load asset: toonRepo/data.json)
I've tried a lot of solutions here that revolve around the asset section in pubspec.yaml
name: hello_world
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
path_provider: ^0.4.1
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
english_words: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
assets:
- toonRepo/
uses-material-design: true
Am I going wrong somewhere very silly?
Cheers for any pointers you have.
Project Structure
Here is a temporary copy of the code if you want to take a peek.
Github
And here's a stack trace
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
Unable to load asset: toonRepo/data.json
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
<asynchronous suspension>
#1 AssetBundle.loadString (package:flutter/src/services/asset_bundle.dart:67:33)
<asynchronous suspension>
#2 CachingAssetBundle.loadString.<anonymous closure> (package:flutter/src/services/asset_bundle.dart:162:56)
#3 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.putIfAbsent (dart:collection/runtime/libcompact_hash.dart:284:23)
The asset access works fine with the pubspec.yaml in your question.
new Text("Name: " + toon.info.name)),
fails because toon is null because it never got a value assigned.
You could use new Text("Name: " + (toon?.info?.name ?? 'foo')), to work around the exception.
If you add
widget.storage.getFileData('toonRepo/data.json').then((f) => print(f));
to _FlutterDemoState.initState(), you'll see that reading the asset works just fine.