I created my database with this function:
void CreateDatabase() async {
database = await openDatabase(
'todo.db',
version: 1,
onCreate: (database, version) {
print('database is created ');
database
.execute(
'CREATE TABLE tasks(id INTEGER PRIMARY KEY , title TEXT, date TEXT , time TEXT , Status Text )')
.then((value) {
print('table created');
}).catchError((error) {
print('error when creating table ${error.runtimeType}');
});
},
onOpen: (database) {
print('database is opned ');
},
);
}
Of course after installing dependencies in pubspec.yaml
dependencies:
flutter:
sdk: flutter
sqflite: ^1.3.0
Then, I called the function CreateDatabase(); but this error appear:
Error: MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
at Object.throw_ [as throw] (http://localhost:41319/dart_sdk.js:5375:11)
at MethodChannel._invokeMethod (http://localhost:41319/packages/flutter/src/services/system_channels.dart.lib.js:1551:21)
at _invokeMethod.next (<anonymous>)
at http://localhost:41319/dart_sdk.js:39799:33
at _RootZone.runUnary (http://localhost:41319/dart_sdk.js:39656:58)
at _FutureListener.thenAwait.handleValue (http://localhost:41319/dart_sdk.js:34585:29)
at handleValueCallback (http://localhost:41319/dart_sdk.js:35170:49)
at Function._propagateToListeners (http://localhost:41319/dart_sdk.js:35208:17)
at _Future.new.[_completeWithValue] (http://localhost:41319/dart_sdk.js:35050:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:41319/dart_sdk.js:35073:35)
at Object._microtaskLoop (http://localhost:41319/dart_sdk.js:39961:13)
at _startMicrotaskLoop (http://localhost:41319/dart_sdk.js:39967:13)
at http://localhost:41319/dart_sdk.js:35432:9
I called the function inside floating button:
floatingActionButton: FloatingActionButton(
onPressed: () {
CreateDatabase();
},
child: Icon(Icons.format_list_bulleted),
// fabIcon,
),
Did I miss any step in creating database?
A simple flutter clean and flutter build should fix it.
That happens when the dependencies are not embedded in the binary.
Status column type Text wrong, right status TEXT
Maybe
I change your code check your code
Related
My app is using the image_picker plugin to let the user upload a profile picture from his phone and on Android everything works as expected.
The problem is that when I try to run the same code on web, it throws me the following error:
Error: AppwriteException: null, On web `bytes` is required (0)
at Object.throw_ [as throw] (http://localhost:42231/dart_sdk.js:5080:11)
at new input_file.InputFile.new (http://localhost:42231/packages/appwrite/src/input_file.dart.lib.js:79:17)
at database.DatabaseService.new.uploadProfilePic (http://localhost:42231/packages/presents/services/database.dart.lib.js:299:104)
at uploadProfilePic.next (<anonymous>)
at runBody (http://localhost:42231/dart_sdk.js:40660:34)
at Object._async [as async] (http://localhost:42231/dart_sdk.js:40691:7)
at database.DatabaseService.new.uploadProfilePic (http://localhost:42231/packages/presents/services/database.dart.lib.js:297:20)
at http://localhost:42231/packages/presents/screens/profile/show_profilepic_menu.dart.lib.js:262:33
at Generator.next (<anonymous>)
at http://localhost:42231/dart_sdk.js:40641:33
at _RootZone.runUnary (http://localhost:42231/dart_sdk.js:40511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:42231/dart_sdk.js:35438:29)
at handleValueCallback (http://localhost:42231/dart_sdk.js:35999:49)
at Function._propagateToListeners (http://localhost:42231/dart_sdk.js:36037:17)
at _Future.new.[_completeWithValue] (http://localhost:42231/dart_sdk.js:35872:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:42231/dart_sdk.js:35906:35)
at Object._microtaskLoop (http://localhost:42231/dart_sdk.js:40778:13)
at _startMicrotaskLoop (http://localhost:42231/dart_sdk.js:40784:13)
at http://localhost:42231/dart_sdk.js:36261:9
I don't know if the problem is with the image_picker plugin or with AppWrite (the backend server), but since when I run the code in Debug mode it stops in the image_picker_for_web.dart file I'd guess the problem is with the former.
Actually, it stops on line 274 where it returns an XFile without the bytes parameter (see the code below), so maybe this is the problem? How can I fix that?
(the code of image_picker_for_web.dart I was talking about, from line 273)
if (!_completer.isCompleted && files != null) {
_completer.complete(files.map((html.File file) {
return XFile(
html.Url.createObjectUrl(file),
name: file.name,
length: file.size,
lastModified: DateTime.fromMillisecondsSinceEpoch(
file.lastModified ?? DateTime.now().millisecondsSinceEpoch,
),
mimeType: file.type,
);
}).toList());
}
Ok, after some further debugging I found out the problem was not with the image_picker package but with uploading the picked image on AppWrite storage.
Initially, I was uploading it with a code like this one:
Future<void> uploadProfilePic(XFlie file) async {
File res = await _storage.createFile(
bucketId: Constants.profilePicsBucketID,
fileId: 'unique()',
file: InputFile(
path: file.path,
filename: '$_uid.${file.path.split('.').last}',
),
read: ['role:all'],
);
}
And then I solved my problem passing the createFile function also a bytes parameter. So my final code is:
Future<void> uploadProfilePic(XFlie file) async {
List<int> fileBytes = await file.readAsBytes();
File res = await _storage.createFile(
bucketId: Constants.profilePicsBucketID,
fileId: 'unique()',
file: InputFile(
path: file.path,
bytes: fileBytes,
filename: '$_uid.${file.path.split('.').last}',
),
read: ['role:all'],
);
}
I'm using the new experimental LockCachingAudioSource with just_audio. It seems to work on Android and iOS but when I run my app on the web I get the following uncaught error:
Error: MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)
at Object.throw_ [as throw] (http://localhost:49168/dart_sdk.js:5041:11)
at platform_channel.MethodChannel.new._invokeMethod (http://localhost:49168/packages/flutter/src/services/system_channels.dart.lib.js:943:21)
at _invokeMethod.next (<anonymous>)
at http://localhost:49168/dart_sdk.js:37403:33
at _RootZone.runUnary (http://localhost:49168/dart_sdk.js:37274:59)
at _FutureListener.thenAwait.handleValue (http://localhost:49168/dart_sdk.js:32530:29)
at handleValueCallback (http://localhost:49168/dart_sdk.js:33057:49)
at Function._propagateToListeners (http://localhost:49168/dart_sdk.js:33095:17)
at _Future.new.[_completeWithValue] (http://localhost:49168/dart_sdk.js:32943:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:49168/dart_sdk.js:32964:35)
at Object._microtaskLoop (http://localhost:49168/dart_sdk.js:37526:13)
at _startMicrotaskLoop (http://localhost:49168/dart_sdk.js:37532:13)
at http://localhost:49168/dart_sdk.js:33303:9
Here is my code:
_playlist = ConcatenatingAudioSource(
children: mediaItemList
.where((item) => item.extras?['url'] is String)
.map((item) {
final String url = item.extras?['url'];
return LockCachingAudioSource(Uri.parse(url));
}).toList(),
);
await _player.setAudioSource(_playlist);
I found a solution so I am posting it below.
Currently just_audio doesn't support LockCachingAudioSource on the web. The solution is to use one of the supported AudioSources when running on on the web:
if (kIsWeb) {
return AudioSource.uri(Uri.parse(url));
}
return LockCachingAudioSource(Uri.parse(url));
I am developing a website with flutter web.
on this web site there is a page to directly send an email from the site.
To do this I thought about using Backendless:
https://backendless.com/docs/flutter/email_settings.html
But when I send a simple email it gives me the following problem.
Error: PlatformException(error, Expected a value of type '(dynamic) => dynamic', but got one of type '(Object) => Object', null, null)
at Object.throw_ [as throw] (http://localhost:61993/dart_sdk.js:5032:11)
at StandardMethodCodec.decodeEnvelope (http://localhost:61993/packages/flutter/src/services/system_channels.dart.lib.js:791:19)
at MethodChannel._invokeMethod (http://localhost:61993/packages/flutter/src/services/system_channels.dart.lib.js:955:47)
at _invokeMethod.next (<anonymous>)
at http://localhost:61993/dart_sdk.js:37210:33
at _RootZone.runUnary (http://localhost:61993/dart_sdk.js:37081:59)
at _FutureListener.thenAwait.handleValue (http://localhost:61993/dart_sdk.js:32337:29)
at handleValueCallback (http://localhost:61993/dart_sdk.js:32864:49)
at Function._propagateToListeners (http://localhost:61993/dart_sdk.js:32902:17)
at _Future.new.[_completeWithValue] (http://localhost:61993/dart_sdk.js:32750:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:61993/dart_sdk.js:32771:35)
at Object._microtaskLoop (http://localhost:61993/dart_sdk.js:37333:13)
at _startMicrotaskLoop (http://localhost:61993/dart_sdk.js:37339:13)
at http://localhost:61993/dart_sdk.js:33110:9
Below is the code for sending the email
#override
void initState() {
super.initState();
Backendless.initWebApp('**APP_ID**', '**JS_ID**');
}
Future<void> _sendMail() async {
Backendless.messaging.sendTextEmail("Reminder", "Email text body",
["my_email#gmail.com"]).then((response) {
print("Email has been sent");
});
}
in the backendless e-mail setting everything is set correctly.
Hi Im making app with Flutter for Android, iOS, Web
After a user sign in, Dashboard view loads all documents from collection 'projects'.
But error below arise without any further information.
[cloud_firestore/unknown] NoSuchMethodError: invalid member on null: 'includeMetadataChanges'
My code to load documents is..
static Future<List<Project>> getProjects(String userID) async {
try {
var user = FirebaseAuth.instance.currentUser;
var db = FirebaseFirestore.instance;
var colRef = db
.collection("users")
.doc(user.uid)
.collection("projects")
.orderBy("modifiedTime", descending: true);
var documents = await colRef.get();
var list = documents.docs.map((document) {
var data = document.data();
return Project(
data["owner"],
data["id"],
data["name"],
data["description"],
data["createdTime"].toDate(),
data["modifiedTime"].toDate());
}).toList();
return list;
} catch (exception) {
print(exception);
return null;
}
}
After researching, I finally can print stacktrace with below code modified slightly from above.
colRef.get().onError((error, stackTrace)
{
print(stackTrace);
print(error);
});
and result is..
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw_
packages/cloud_firestore_web/src/query_web.dart 127:7 get
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1613:54 runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 155:18 handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 707:44 handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 736:13 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 542:5 [_completeWithValue]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 580:7 callback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15 <fn>
[cloud_firestore/unknown] NoSuchMethodError: invalid member on null: 'includeMetadataChanges'
After some googling, there is a stackoverflow question and someone said this is version issue and change the version of library from index.html to 7.22.1
Im currently working on 8.2.7, but replacing it to 7.22.1 also give me the same result.
This occurs only in web platform. With same code, Android works just fine. iOS never tested yet.
At last, this is libraries that Im using right now.
pubspec.yaml
firebase_core: "^0.7.0"
firebase_auth: "^0.20.0+1"
google_sign_in: "^4.5.1"
email_validator: "^1.0.5"
intl: "^0.16.1"
cloud_firestore: "^0.16.0"
property_change_notifier: "^0.2.0"
main.html
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.7/firebase-analytics.js"></script>
Is there any way I can handle with this issue?
Thank you for reading.
I'm having this problem about flutter and firebase(realtime-database).
Unhandled Exception: MissingPluginException(No implementation found for method Query#observe on channel plugins.flutter.io/firebase_database)
Here is the error in terminal
error
// error message
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method Query#observe on channel plugins.flutter.io/firebase_database)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#2 Query._observe.<anonymous closure> (package:firebase_database/src/query.dart:50:38)
#3 _runGuarded (dart:async/stream_controller.dart:820:24)
#4 _BroadcastStreamController._subscribe (dart:async/broadcast_stream_controller.dart:215:7)
#5 _ControllerStream._createSubscription (dart:async/stream_controller.dart:833:19)
#6 _StreamImpl.listen (dart:async/stream_impl.dart:475:9)
#7 Stream.first (dart:async/stream.dart:1254:25)
#8 Query.once (package:firebase_database/src/query.dart:84:55)
#9 _IoTState.initState (package:flutter_try_iot/main.dart:36:13)
#10 StatefulElement._f<…>
I'm trying to get data from firebase to display in flutter app.
Here is my code main.dart
class _IoTState extends State<IoT> {
final getIot = FirebaseDatabase.instance.reference();
final getData = FirebaseDatabase.instance.reference().child('xxx-xxx');
String temperatue = "0";
String illuminance = "0";
List<String> temp = [];
List<String> light = [];
#override
void initState(){
getData.once().then((DataSnapshot snapshot){
if (snapshot.value == null) {
print("Item doesn't exist in the db");
} else {
print("Item exists in the db");
}
});
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF7ACADA),
title: Text(
"IoT ZigBee Simulation",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF1A1244)
),
),
),
body: Column(
),
);
}
}
pubspec.yaml
firebase_core: ^0.4.5
firebase_database: ^3.1.6
flutter_icons: ^1.1.0
fl_chart: ^0.10.1
I follow instructions to add ios to firebase .ios add firebase
no issues found by flutter doctor
I follow other peoples suggestion to do flutter clean & flutter packages get, but still not able to fix this problem
https://github.com/flutter/flutter/issues/13971
terminal
Also pop up a window telling me The file “Runner.xcworkspace” has been modified by another application" everytime I execute flutter clean/ flutter packages get
I successfully connect to firebase yesterday, but after I close my simulator I start to receive error message
success picture
Please give me some solution or advice to fix this problem, thanks.
Please tell me if I need to provide additional information