Multipe images uploading on server not working flutter - flutter

I am trying to upload multiple images to server but always get issues. I tried some other solutions as well but not working.
saveImages() async {
// string to uri
Uri uri = Uri.parse('http://100.0.50.10:8000/API/AddImageCarSale/Post');
// create multipart request
MultipartRequest request = http.MultipartRequest("POST", uri);
if (images != null) {
for (var i = 0; i < images.length; i++) {
ByteData byteData = await images[i].getByteData();
List<int> imageData = byteData.buffer.asUint8List();
MultipartFile multipartFile = MultipartFile.fromBytes(
'photo', //key of the api
imageData,
filename: images[i].name,
contentType: MediaType("image",
"jpg"), //this is not nessessory variable. if this getting error, erase the line.
);
request.fields['PhoneNo'] = '1122';
request.fields['VehicleNo'] = '1234';
// add file to multipart
request.files.add(multipartFile);
// send
var response = await request.send();
}
}
}
My error is
[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: Bad state: Can't finalize a finalized Request.
E/flutter (11521): #0 BaseRequest.finalize (package:http/src/base_request.dart:104:20)
E/flutter (11521): #1 MultipartRequest.finalize (package:http/src/multipart_request.dart:92:11)
E/flutter (11521): #2 IOClient.send (package:http/src/io_client.dart:28:26)
E/flutter (11521): #3 BaseRequest.send (package:http/src/base_request.dart:119:35)
E/flutter (11521): #4 _SellerFormState.savedNew (package:Autolog/pages/buySell/sellerForm.dart:361:38)
E/flutter (11521):
E/flutter (11521): #5 _SellerFormState._buildBody. (package:Autolog/pages/buySell/sellerForm.dart:754:25)
E/flutter (11521): #6 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
E/flutter (11521): #7 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1098:38)
E/flutter (11521): #8 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
E/flutter (11521): #9 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
E/flutter (11521): #10 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
E/flutter (11521): #11 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:256:7)
E/flutter (11521): #12 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:158:27)
E/flutter (11521): #13 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:224:20)
E/flutter (11521): #14 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter (11521): #15 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
E/flutter (11521): #16 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
E/flutter (11521): #17 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
E/flutter (11521): #18 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (11521): #19 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (11521): #20 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (11521): #21 _invoke1 (dart:ui/hooks.dart:267:10)
E/flutter (11521): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
E/flutter (11521):

You need to create a new multipart request for every loop as multipart request gets finalized.
Try this modification and it should work.
// string to uri
Uri uri = Uri.parse('http://100.0.50.10:8000/API/AddImageCarSale/Post');
// create multipart request
if (images != null) {
for (var i = 0; i < images.length; i++) {
MultipartRequest request = http.MultipartRequest("POST", uri);
ByteData byteData = await images[i].getByteData();
List<int> imageData = byteData.buffer.asUint8List();
MultipartFile multipartFile = MultipartFile.fromBytes(
'photo', //key of the api
imageData,
filename: images[i].name,
contentType: MediaType("image",
"jpg"), //this is not nessessory variable. if this getting error, erase the line.
);
request.fields['PhoneNo'] = '1122';
request.fields['VehicleNo'] = '1234';
// add file to multipart
request.files.add(multipartFile);
// send
var response = await request.send();
}
}
}

Related

How to execute write method in function that changes value in slidebar?

When the slide bar value changes, it tries to write a packet.
I am using the example,
I made a function and tried it, but a null error occurs. (discoverService, characteristic.., etc.)
How can I solve this?
I'm using flutter_blue
In the flutter_blue example, write works fine.
I'm flutter beginer.
I need your help. thank you.
https://pub.dev/packages/flutter_blue
onWriteData
var data = [0x80, 0x80, 0xF0, 0x7D, 0x05, 0x00, 0x0E, 0x01, 60, 100, 00,0x80, 0xF7];
FlutterBlue flutterBlue = FlutterBlue.instance;
BluetoothDevice device;
BluetoothService service;
onWriteData() async {
List<BluetoothService> services = await device.discoverServices();
services.forEach((service) {
});
var characteristics = service.characteristics;
for(BluetoothCharacteristic c in characteristics) {
List<int> value = await c.read();
print(value);
await c.write(data);
}
}
slideBar class
class slidecontrollerr extends State<slidecontroller> {
static double volumeValue = 60;
void onVolumeChanged(double value) async { **// I want to execute the write function here**
setState(() {
volumeValue = value;
});
onWriteData(); **//error**
}
#override
Widget build(BuildContext context) {
return Scaffold(
.
.
.
[Error Code][1]
E/flutter ( 5640): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: NoSuchMethodError: The method 'discoverServices' was called on null.
E/flutter ( 5640): Receiver: null
E/flutter ( 5640): Tried calling: discoverServices()
E/flutter ( 5640): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
E/flutter ( 5640): #1 onWriteData (package:auto_humidity/main.dart:467:48)
E/flutter ( 5640): #2 slidecontrollerr.onVolumeChanged (package:auto_humidity/main.dart:1489:5)
E/flutter ( 5640): #3 RenderRadialAxisParent.createPointerValueChangedArgs (package:syncfusion_flutter_gauges/src/radial_gauge/axis/radial_axis_parent_widget.dart:584:43)
E/flutter ( 5640): #4 RenderRadialAxisParent._setCurrentPointerValue (package:syncfusion_flutter_gauges/src/radial_gauge/axis/radial_axis_parent_widget.dart:548:5)
E/flutter ( 5640): #5 RenderRadialAxisParent._updateDragValue (package:syncfusion_flutter_gauges/src/radial_gauge/axis/radial_axis_parent_widget.dart:527:7)
E/flutter ( 5640): #6 RenderRadialAxisParent._updatePointerValue (package:syncfusion_flutter_gauges/src/radial_gauge/axis/radial_axis_parent_widget.dart:452:7)
E/flutter ( 5640): #7 RenderRadialAxisParent._handleDragUpdate (package:syncfusion_flutter_gauges/src/radial_gauge/axis/radial_axis_parent_widget.dart:339:5)
E/flutter ( 5640): #8 DragGestureRecognizer._checkUpdate.<anonymous closure> (package:flutter/src/gestures/monodrag.dart:436:55)
E/flutter ( 5640): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 5640): #10 DragGestureRecognizer._checkUpdate (package:flutter/src/gestures/monodrag.dart:436:7)
E/flutter ( 5640): #11 DragGestureRecognizer.handleEvent (package:flutter/src/gestures/monodrag.dart:289:9)
E/flutter ( 5640): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:93:12)
E/flutter ( 5640): #13 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:138:9)
E/flutter ( 5640): #14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:397:8)
E/flutter ( 5640): #15 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:136:18)
E/flutter ( 5640): #16 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:122:7)
E/flutter ( 5640): #17 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:439:19)
E/flutter ( 5640): #18 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419:22)
E/flutter ( 5640): #19 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:287:11)
E/flutter ( 5640): #20 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374:7)
E/flutter ( 5640): #21 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338:5)
E/flutter ( 5640): #22 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296:7)
E/flutter ( 5640): #23 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279:7)
E/flutter ( 5640): #24 _rootRunUnary (dart:async/zone.dart:1370:13)
E/flutter ( 5640): #25 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 5640): #26 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter ( 5640): #27 _invoke1 (dart:ui/hooks.dart:182:10)
E/flutter ( 5640): #28 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282:7)
E/flutter ( 5640): #29 _dispatchPointerDataPacket (dart:ui/hooks.dart:96:31)
You need to connect to a specific service and characteristics of your BLE device
Here is a piece of code that I am using
final String serviceUUID = "0000ffe0-0000-1000-8000-00805f9b34fb";
final String characteristicWriteUUID = "0000fff1-0000-1000-8000-00805f9b34fb";
final String characteristicReadUUID = "0000fff2-0000-1000-8000-00805f9b34fb";
These services and characteristics must be set in the module itself by default or by you manually
discoverServices(BluetoothDevice device) async {
if (device == null) return;
List<BluetoothService> services = await device.discoverServices();
services.forEach((service) {
// do something with service
if (service.uuid.toString().toLowerCase() == serviceUUID) {
service.characteristics.forEach((characteristic) {
if (characteristic.uuid.toString().toLowerCase() == characteristicReadUUID) {
targetReadCharacteristic = characteristic;
_readData(targetReadCharacteristic);
}
if (characteristic.uuid.toString().toLowerCase() == characteristicWriteUUID) {
targetWriteCharacteristic = characteristic;
writeData(targetWriteCharacteristic, [0x49, 0x44, 0x02]);
}
});
}
});
}
Future<void> writeData(characteristic, data) async{
if (characteristic == null) return;
try {
List<int> bytes = data;
await characteristic.write(bytes, withoutResponse: true );
print("data: Send: $data");
} catch (e) {
print('Data Error ${e.message} | $data');
}
}
_readData(characteristic) async {
if (!characteristic.isNotifying) {
await characteristic.setNotifyValue(true);
}
readSubScription = characteristic.value.listen((value) {
List<int> readData = new List.from(value);
if(readData.isNotEmpty && readData != []){
print('BLE read data: $readData');
}
});
}

Uploading Screenshots to Firebase with Flutter

I want to upload the screenshot image to Firestore, but I am having some null errors,
Future uploadImagetoFirebase() async {
await screenshotController.capture().then((value) => (File image) {
_screenshot = image;
});
String fileName = _screenshot.path;
Reference firebaseStorageRef =
FirebaseStorage.instance.ref().child('orders/$fileName');
UploadTask uploadTask = firebaseStorageRef.putFile(_screenshot);
TaskSnapshot taskSnapshot = await uploadTask;
taskSnapshot.ref.getDownloadURL().then((value) => print('Done: $value'));
}
I am calling it with button like this:
onPressed: () async {
await uploadImagetoFirebase(); }
This is the error stack:
flutter ( 5143): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The getter 'path' was called on null.
E/flutter ( 5143): Receiver: null
E/flutter ( 5143): Tried calling: path
E/flutter ( 5143): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter ( 5143): #1 _CartState.uploadImagetoFirebase
package:CWCFlutter/model/cart.dart:88
E/flutter ( 5143): <asynchronous suspension>
E/flutter ( 5143): #2 _CartState.build.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure>
package:CWCFlutter/model/cart.dart:310
E/flutter ( 5143): #3 _InkResponseState._handleTap
package:flutter/…/material/ink_well.dart:993
E/flutter ( 5143): #4 _InkResponseState.build.<anonymous closure>
package:flutter/…/material/ink_well.dart:1111
E/flutter ( 5143): #5 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:183
E/flutter ( 5143): #6 TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:598
E/flutter ( 5143): #7 BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:287
E/flutter ( 5143): #8 BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/…/gestures/tap.dart:222
E/flutter ( 5143): #9 PrimaryPointerGestureRecognizer.handleEvent
package:flutter/…/gestures/recognizer.dart:476
E/flutter ( 5143): #10 PointerRouter._dispatch
package:flutter/…/gestures/pointer_router.dart:77
E/flutter ( 5143): #11 PointerRouter._dispatchEventToRoutes.<anonymous closure>
package:flutter/…/gestures/pointer_router.dart:122
E/flutter ( 5143): #12 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter ( 5143): #13 PointerRouter._dispatchEventToRoutes
package:flutter/…/gestures/pointer_router.dart:120
E/flutter ( 5143): #14 PointerRouter.route
package:flutter/…/gestures/pointer_router.dart:106
E/flutter ( 5143): #15 GestureBinding.handleEvent
package:flutter/…/gestures/binding.dart:358
E/flutter ( 5143): #16 GestureBinding.dispatchEvent
package:flutter/…/gestures/binding.dart:338
E/flutter ( 5143): #17 RendererBinding.dispatchEvent
package:flutter/…/rendering/binding.dart:267
E/flutter ( 5143): #18 GestureBinding._handlePointerEvent
package:flutter/…/gestures/binding.dart:295
E/flutter ( 5143): #19 GestureBinding._flushPointerEventQueue
package:flutter/…/gestures/binding.dart:240
E/flutter ( 5143): #20 GestureBinding._handlePointerDataPacket
package:flutter/…/gestures/binding.dart:213
E/flutter ( 5143): #21 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 5143): #22 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 5143): #23 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 5143): #24 _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter ( 5143): #25 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
I am not sure how path was called on null, any ideas? Basically I await for the app to take a screenshot, then add that image in _screenshot File variable, then try to store it in 'orders' folder in Firestore. I have searched for answers, and they say you need to initialize Firestore somewhere, but I am not sure where that would be, I have only worked with older versions, and not sure how to do all things in the newer ones. Thank you!
I have tried setting the state as well, but getting the same error:
Future uploadImagetoFirebase() async {
await screenshotController.capture().then((value) => (File image) {
setState(() {
_screenshot = image;
});
});
What I came up with that seems to work as a solution
Future<String> uploadImagetoFirebase2() async {
File img = await screenshotController.capture();
setState(() {
_screenshot = img;
});
//change filename not to be path, but something else short
String fileName = img.path;
Reference firebaseStorageRef =
FirebaseStorage.instance.ref().child('orders/$fileName');
UploadTask uploadTask = firebaseStorageRef.putFile(_screenshot);
TaskSnapshot taskSnapshot = (await uploadTask);
String uri = await taskSnapshot.ref.getDownloadURL();
print(uri);
return uri;
}
flutter ( 5143): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The getter 'path' was called on null.
E/flutter ( 5143): Receiver: null
E/flutter ( 5143): Tried calling: path
your path is null,
you can solve this in two ways
1. setstate
Future uploadImagetoFirebase() async {
await screenshotController.capture().then((value) => (File image) {
setState(() {
_screenshot = image;
});
});
//... your fireabase upload function
2 return from future
Future <File> uploadImagetoFirebase() async {
File myImage=await screenshotController.capture();
retun myImage
);
//get image onPress btn
onPressed: () async {
var myFile= await uploadImagetoFirebase();
//check if path is null using if ...
print(myFile.path);
// firebase function
Reference firebaseStorageRef =
FirebaseStorage.instance.ref().child('orders/${myFile.path}');
UploadTask uploadTask = firebaseStorageRef.putFile(myFile);
TaskSnapshot taskSnapshot = (await uploadTask);
String uri = await taskSnapshot.ref.getDownloadURL();
print(uri);
return uri;
}
try this;
Future<String> uploadImagetoFirebase() async {
File img = await screenshotController.capture();
String fileName = img.path;
Reference firebaseStorageRef =
FirebaseStorage.instance.ref().child('orders/$fileName');
UploadTask uploadTask = firebaseStorageRef.putFile(_screenshot);
TaskSnapshot taskSnapshot = (await uploadTask);
String uri = await taskSnapshot.ref.getDownloadURL();
print(uri);
return uri;
}

Flutter & Ethereum : Unhandled Exception: RangeError: Value not in range: 32

I am trying to make a simple Decentralization Application with flutter and Ethereum. But I keep on getting this error. It was working fine. Please have a look at my code and my error
I use :
Flutter
Remix Ethereum
MetaMask => Rinkeby
Infua.io
Question : Why do I get this RangerError?
Solidity
pragma solidity 0.6.6;
contract PKCoin{
int balance;
constructor() public {
balance = 0;
}
function getBalance() view public returns(int) {
return balance;
}
function depositBalance(int amount) public {
balance = balance + amount;
}
function withdrawBalance(int amount) public {
balance = balance - amount;
}
}
Flutter
#override
void initState() {
super.initState();
httpClient = Client();
// print(httpClient);
ethClient = Web3Client(
"https://rinkeby.infura.io/v3/b2a9d5831e3b4675a51144cfed03bafa",
httpClient);
getBalance(myAddress);
}
Future<DeployedContract> loadContract() async {
String abi = await rootBundle.loadString("assets/abi.json");
String contractAddress = "0xd9145CCE52D386f254917e481eB44e9943F39138";
final contract = DeployedContract(ContractAbi.fromJson(abi, "PKCoin"),
EthereumAddress.fromHex(contractAddress));
return contract;
}
// ==== This is to get the information only ==== //
// ==== Get method ==== //
Future<List<dynamic>> query(String functionName, List<dynamic> args) async {
//
final contract = await loadContract();
final ethFunction = contract.function(functionName);
// This line below doesn't work.
final result = await ethClient.call(
contract: contract, function: ethFunction, params: args);
// print(result.toString());
return result;
}
Future<void> getBalance(String targetAddress) async {
// EthereumAddress address = EthereumAddress.fromHex(targetAddress);
List<dynamic> result = await query("getBalance", []);
print('In getGreeting');
print(result[0]);
setState(() {
myData = result[0];
data = true;
});
}
Error
Performing hot restart...
Restarted application in 950ms.
E/flutter (28032): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: RangeError: Value not in range: 32
E/flutter (28032): #0 _rangeCheck (dart:typed_data-patch/typed_data_patch.dart:4807:5)
E/flutter (28032): #1 _ByteBuffer.asUint8List (dart:typed_data-patch/typed_data_patch.dart:1940:5)
E/flutter (28032): #2 _IntTypeBase.decode (package:web3dart/src/contracts/abi/integers.dart:23:31)
E/flutter (28032): #3 TupleType.decode (package:web3dart/src/contracts/abi/tuple.dart:102:29)
E/flutter (28032): #4 ContractFunction.decodeReturnValues (package:web3dart/src/contracts/abi/abi.dart:255:30)
E/flutter (28032): #5 Web3Client.call (package:web3dart/src/core/client.dart:310:21)
E/flutter (28032): <asynchronous suspension>
E/flutter (28032): #6 _MyHomePageState.query (package:greeting_blockchain/main.dart:70:36)
E/flutter (28032): <asynchronous suspension>
E/flutter (28032): #7 _MyHomePageState.getBalance (package:greeting_blockchain/main.dart:79:34)
E/flutter (28032): #8 _MyHomePageState.initState (package:greeting_blockchain/main.dart:48:5)
E/flutter (28032): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58)
E/flutter (28032): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (28032): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #13 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (28032): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (28032): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (28032): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (28032): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (28032): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (28032): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (28032): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (28032): #29 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter (28032): #30 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (28032): #31 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4606:5)
E/flutter (28032): #32 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4791:11)
E/flutter (28032): #33 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
E/flutter (28032): #34 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #35 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #36 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (28032): #37 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #38 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #39 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6118:14)
E/flutter (28032): #40 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
E/flutter (28032): #41 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
E/flutter (28032): #42 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16)
E/flutter (28032): #43 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4800:11)
E/flutter (28032): #44 Element.rebuild (package:flutter/src/widgets/framework.dart:4343:5)
E/flutter (28032): #45 ComponentElement._firstBuild (package:flutter/src/widgets/framework.d
Conclusion
Please take a look at my code and I am looking forward to see all of your answers. Thank you in advance.
Un-comment //EthereumAddress address = EthereumAddress.fromHex(targetAddress);
Future<void> getBalance(String targetAddress) async {
EthereumAddress address = EthereumAddress.fromHex(targetAddress);
List<dynamic> result = await query("getBalance", []);
print('In getGreeting');
print(result[0]);
setState(() {
myData = result[0];
data = true;
});
}

Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null. Shared Preference

While fetching the data for the first time from shared preference, I am getting this error: Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null. But after the hot restart, I am getting the data as usual.
Retrieving data from Dashboard Screen
loadSharedPrefs() async {
var decodedData = await sharedPref.read("details");
signInItem = SignInItem.fromJson(decodedData);
setState(() {});
}
Saving data in SignIn screen
await FirebaseAuth.instance
.signInWithCredential(_phoneAuthCredential)
.then((AuthResult authRes) {
Navigator.pop(context);
Flushbar(
message: "Verified!!",
duration: Duration(seconds: 2),
)..show(context);
sharedPref.save("details", signInItem);
Navigator.popAndPushNamed(context, DashboardScreen.id);
});
Model Class
class SignInItem {
String phoneNumber;
String schoolCode;
String schoolReference;
Map<String, dynamic> teacherData;
String error;
SignInItem.fromJson(Map<String, dynamic> json)
: phoneNumber = json['phoneNumber'],
schoolCode = json['schoolCode'],
schoolReference = json['schoolReference'],
teacherData = json['teacherData'],
error = json['error'];
Map<String, dynamic> toJson() => {
'phoneNumber': phoneNumber,
'schoolCode': schoolCode,
'schoolReference': schoolReference,
'teacherData': teacherData,
'error': error,
};
SignInItem(
{this.phoneNumber,
this.schoolCode,
this.schoolReference,
this.teacherData,
this.error});
}
Shared preference helper class
class SharedPref {
read(String key) async {
final prefs = await SharedPreferences.getInstance();
return json.decode(prefs.getString(key));
}
save(String key, SignInItem signInItem) async {
final prefs = await SharedPreferences.getInstance();
prefs.setString(key, json.encode(signInItem.toJson()));
}
}
Detail Stacktrace
[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null.
E/flutter (19241): Receiver: null
E/flutter (19241): Tried calling: length
E/flutter (19241): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (19241): #1 _parseJson (dart:convert-patch/convert_patch.dart:39:28)
E/flutter (19241): #2 JsonDecoder.convert (dart:convert/json.dart:505:36)
E/flutter (19241): #3 JsonCodec.decode (dart:convert/json.dart:156:41)
E/flutter (19241): #4 SharedPref.read (package:teacher_app/constants.dart:156:17)
E/flutter (19241): <asynchronous suspension>
E/flutter (19241): #5 _DashboardScreenState.loadSharedPrefs (package:teacher_app/screens/dashboard_screen.dart:33:40)
E/flutter (19241): #6 _DashboardScreenState.initState (package:teacher_app/screens/dashboard_screen.dart:49:5)
E/flutter (19241): #7 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4684:58)
E/flutter (19241): #8 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter (19241): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #11 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter (19241): #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter (19241): #15 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter (19241): #16 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter (19241): #17 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter (19241): #18 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #20 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter (19241): #21 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #23 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter (19241): #24 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #25 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #26 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter (19241): #27 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
E/flutter (19241): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter (19241): #29 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter (19241): #30 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4710:11)
E/flutter (19241): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter (19241): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #34 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter (19241): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #37 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter (19241): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter (19241): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter (19241): #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter (19241): #41 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
E/flutter (19241): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter (19241): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter (19241): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4710:11)
E/flutter (19241): #45 ComponentElement.mount (package:flutter/src/widgets/framework.dart
Shared Preference takes time to save the details and I was fetching the data before saving it. So that's why I was getting null.
I solved it by delaying to navigate to Dashboard screen by this:
await FirebaseAuth.instance
.signInWithCredential(_phoneAuthCredential)
.then((AuthResult authRes) {
sharedPref.save("details", signInItem);
Timer(Duration(seconds: 2), () {
Navigator.pop(context);
Navigator.popAndPushNamed(context, DashboardScreen.id);
});
});
But thanks #TheSohan for letting me know where I was getting null.
In SharedPref class read method; use a null check before decoding the data.
Ex:
class SharedPref {
read(String key) async {
final prefs = await SharedPreferences.getInstance();
string data = prefs.getString(key)
if(data){
return json.decode(prefs.getString(key));
}
return data
}
similarly, add null check in loadSharedPrefs method.
loadSharedPrefs() async {
var decodedData = await sharedPref.read("details");
if(decodedData){
signInItem = SignInItem.fromJson(decodedData);
}
setState(() {});
}

Flutter: version 0.2.8 breaks code that used to work

Before I update to the new version of flutter (see below) everything worked OK.
Now it does no longer work.
The following piece of code performs a "paged" load of a gridView
Could somebody tell me what has changed with the last version of Flutter and how to solve this issue ?
Many thanks
Flutter version:
flutter --version
Flutter 0.2.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision b397406561 (11 days ago) • 2018-04-02 13:53:20 -0700
Engine • revision c903c217a1
Tools • Dart 2.0.0-dev.43.0.flutter-52afcba357
Here is the code that used to work:
typedef Future<PageAnswer> ApiPageRequest(int page, int pageSize);
class MIDApi {
///
/// Returns the list of items belonging to the active profile
///
Future<PageAnswer> getItems({
int pageIndex: 0,
int pageSize: 50,
#required String sortOrder
}) async {
String url = "ItemsList/$sortOrder";
return ajaxGet(url).then((String responseBody) async {
// print(responseBody);
final Map response = json.decode(responseBody);
final _status = response["status"];
if (_status == "OK"){
// Everything is OK
Map map = json.decode(response["data"]);
List<Map> objects = map["List"];
int total = map["Total"];
return new PageAnswer(objects, total);
}
return Null;
}).catchError((){
return Null;
});
}
}
///
/// This widget is used to display a "paged" GridView
///
/// Invocation example:
/// new PagedGridView<Map>(request, widgetAdapter: adapt);
///
/// where: request could be
/// Future<List<Map>> request(int page, int pageSize) async {
/// routine to fetch the data from the server
/// }
///
/// and adapt could be:
/// Widget adapt(Map map){
/// return new MyWidget(map);
/// }
///
class PagedGridView extends StatefulWidget {
/// Abstraction for loading the data.
/// This can be anything: An API-Call,
/// loading data from a certain file or database,
/// etc. If will deliver a list of objects (of type T)
final ApiPageRequest pageRequest;
/// The number of columns per row of the grid
final int numberColumns;
/// The number of elements requested for each page
final int pageSize;
/// The number of left-over elements in list which
/// will trigger loading the next page
final int pageThreshold;
/// Used for building Widgets out of the fetched data
final WidgetAdapter<Map> widgetAdapter;
final bool reverse;
final Indexer<Map> indexer;
final Stream<Map> topStream;
/// Constructor
const PagedGridView({
Key key,
this.numberColumns: 2,
this.pageSize: 50,
this.pageThreshold: 10,
#required this.pageRequest,
#required this.widgetAdapter,
this.reverse: false,
this.indexer,
this.topStream
}): super(key: key);
#override
State<StatefulWidget> createState() {
return new PagedGridViewState();
}
}
class PagedGridViewState extends State<PagedGridView> {
/// Contains all fetched elements ready to display
List<Map> objects = [];
/// Total number of objects that could be returned
int total = -1;
/// A Future returned by loadNext() if there
/// is currently a request running
/// or null, if no request is performed
Future request;
Map<int, int> index = {};
void doSomething(){
print("I need to do something");
}
void Clear() async {
await onRefresh();
}
#override
void initState(){
super.initState();
/// At start, let's systematically try to fetch some data
this.lockedLoadNext();
if (widget.topStream != null){
widget.topStream.listen((Map t){
setState((){
this.objects.insert(0, t);
this.reIndex();
});
});
}
}
#override
Widget build(BuildContext context){
GridView listView = new GridView.builder(
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: widget.numberColumns),
itemBuilder: itemBuilder,
itemCount: objects.length,
reverse: widget.reverse
);
RefreshIndicator refreshIndicator = new RefreshIndicator(
onRefresh: onRefresh,
child: listView
);
return new NotificationListener<ListElementUpdate<Map>>(
child: refreshIndicator,
onNotification: onUpdate
);
}
Widget itemBuilder(BuildContext context, int index){
/// If we are entering the threshold zone,
/// try to fetch additional objects
if (index + widget.pageThreshold > objects.length){
notifyThreshold();
}
return widget.widgetAdapter != null ? widget.widgetAdapter(objects[index])
: new Container();
}
void notifyThreshold(){
lockedLoadNext();
}
bool onUpdate(ListElementUpdate<Map> update){
if (widget.indexer == null){
debugPrint('ListElementUpdate on un-indexed list');
return false;
}
int index = this.index[update.key];
if (index == null){
debugPrint('ListElementUpdate index not found');
return false;
}
setState((){
this.objects[index] = update.instance;
});
return true;
}
Future onRefresh() async {
this.request?.timeout(const Duration());
PageAnswer answer = await widget.pageRequest(0, widget.pageSize);
List<Map> fetched = answer.list;
total = answer.total;
setState(() {
this.objects.clear();
this.index.clear();
this.addObjects(fetched);
});
return true;
}
///
/// This routine only fetches new data, if no other request is pending
///
void lockedLoadNext() {
if (this.request == null) {
this.request = loadNext().then((x) {
this.request = null;
});
}
}
Future loadNext() async {
// If there is no need to fetch any further data, simply return
if (objects.length >= total && total != -1){
return Null;
}
int page = (objects.length / widget.pageSize).floor();
PageAnswer answer = await widget.pageRequest(page, widget.pageSize);
List<Map> fetched = answer.list;
total = answer.total;
if (mounted) {
this.setState(() {
addObjects(fetched);
});
}
}
void addObjects(Iterable<Map> objects) {
objects.forEach((Map object) {
int index = this.objects.length;
this.objects.add(object);
if (widget.indexer != null) {
this.index[widget.indexer(object)] = index;
}
});
}
void reIndex(){
this.index .clear();
if (widget.indexer!=null){
int i = 0;
this.objects.forEach((object){
index[widget.indexer(object)] == i;
i++;
});
}
}
}
Invocation code:
class ItemsPage extends StatefulWidget {
#override
_ItemsPageState createState() => new _ItemsPageState();
}
class _ItemsPageState extends State<ItemsPage> {
static final GlobalKey<PagedGridViewState> _gridKey = new GlobalKey<PagedGridViewState>();
String _path = mid.serverHttps ? "https://${mid.serverUrl}/"
: "http://${mid.serverUrl}/";
String _sortOrder;
final List<SortMethod> sortMethods = const <SortMethod>[
const SortMethod(value: 'alpha', title: "Alpha", icon: Icons.sort_by_alpha),
const SortMethod(value: 'older_first', title: "Older first", icon: Icons.autorenew),
const SortMethod(value: 'last_first', title: "Last first", icon: Icons.change_history),
];
Future<PageAnswer> request(int page, int pageSize) async {
PageAnswer answer = await mid.api.getItems(sortOrder: _sortOrder);
return answer;
}
void _handleTap(int lookId) {
print('tap:' + lookId.toString());
}
Widget adapt(Map map){
var photos = map["Photos"].split(";");
String photoName = photos[0].split("|")[0];
return new GestureDetector(
onTap: () {_handleTap(map["Id"]);},
child: new GridTile(
child: new Card(
child: new Stack(
fit: StackFit.expand,
children: <Widget>[
new Image.network(_path + photoName,
fit: BoxFit.fitHeight),
new Center(
child: new Text(
map["Title"],
textAlign: TextAlign.center,
)),
],
),
),
),
);
}
_onSortOrderChanged(String value) {
setState((){
_sortOrder = value;
_gridKey.currentState.Clear();
});
}
#override
void initState(){
super.initState();
_sortOrder = 'alpha';
}
#override
Widget build(BuildContext context) {
PagedGridView grid = new PagedGridView(
key: _gridKey,
pageRequest: request,
widgetAdapter: adapt,
numberColumns: 2,
);
DropdownButton ddl = new DropdownButton<String>(
value: _sortOrder,
items: sortMethods.map((SortMethod sort){
return new DropdownMenuItem(
value: sort.value,
child: new Row(children: <Widget>[new Icon(sort.icon), new Text(sort.title)],)
);
}).toList(),
onChanged: _onSortOrderChanged,
);
PopupMenuButton<ItemSorting> popSort = new PopupMenuButton<ItemSorting>(
icon: new Icon(Icons.sort),
itemBuilder: (BuildContext context) => <PopupMenuItem<ItemSorting>> [
const PopupMenuItem<ItemSorting>(
value: ItemSorting.alpha,
child: const Text('Sort Alpha')
),
const PopupMenuItem<ItemSorting>(
value: ItemSorting.last_first,
child: const Text('Sort Last First')
),
const PopupMenuItem<ItemSorting>(
value: ItemSorting.older_first,
child: const Text('Sort Older First')
)
],
onSelected: (ItemSorting action){
_onSortOrderChanged(action.toString().split('.')[1]);
},
);
return new Scaffold(
appBar: new AppBar(
title: new Text('My Items'),
actions: <Widget>[
popSort, //ddl,
],
),
body: new Center(
child: grid,
),
);
}
}
class SortMethod {
const SortMethod({this.title, this.icon, this.value});
final String title;
final IconData icon;
final String value;
}
Error stack:
E/flutter (15195): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (15195): type 'Future<Object>' is not a subtype of type 'FutureOr<PageAnswer>' where
E/flutter (15195): Future is from dart:async
E/flutter (15195): Object is from dart:core
E/flutter (15195): FutureOr is from dart:async
E/flutter (15195): PageAnswer is from file:///D:/Development/appli/lib/libraries/function_types.dart
E/flutter (15195):
E/flutter (15195): #0 MIDApi.getItems (file:///D:/Development/appli/lib/libraries/api.dart:35:8)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #1 _ItemsPageState.request (file:///D:/Development/appli/lib/pages/items.dart:30:39)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #2 PagedGridViewState.loadNext (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:191:38)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #3 PagedGridViewState.lockedLoadNext (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:178:22)
E/flutter (15195): #4 PagedGridViewState.initState (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:93:10)
E/flutter (15195): #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
E/flutter (15195): #6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #8 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #9 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4637:14)
E/flutter (15195): #10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #14 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #16 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #17 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #19 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #20 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #21 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #22 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3938:11)
E/flutter (15195): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #24 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4742:32)
E/flutter (15195): #25 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #26 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #28 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #29 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #30 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3752:11)
E/flutter (15195): #31 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #32 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #33 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #34 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636:16)
E/flutter (15195): #35 Element.rebuild (package:flutter/src/widgets/framework.dart:3478:5)
E/flutter (15195): #36 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605:5)
E/flutter (15195): #37 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
E/flutter (15195): #38 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
E/flutter (15195): #39 Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
E/flutter (15195): #40 ComponentElement.performRebuild (packag
E/flutter (15195): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (15195): type 'Future<Object>' is not a subtype of type 'FutureOr<PageAnswer>' where
E/flutter (15195): Future is from dart:async
E/flutter (15195): Object is from dart:core
E/flutter (15195): FutureOr is from dart:async
E/flutter (15195): PageAnswer is from file:///D:/Development/appli/lib/libraries/function_types.dart
E/flutter (15195):
E/flutter (15195): #0 MIDApi.getItems (file:///D:/Development/appli/lib/libraries/api.dart:34:8)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #1 _ItemsPageState.request (file:///D:/Development/appli/lib/pages/items.dart:30:39)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #2 PagedGridViewState.onRefresh (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:160:38)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #3 PagedGridViewState.Clear (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:85:11)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #4 _ItemsPageState._onSortOrderChanged.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:67:29)
E/flutter (15195): #5 State.setState (package:flutter/src/widgets/framework.dart:1108:30)
E/flutter (15195): #6 _ItemsPageState._onSortOrderChanged (file:///D:/Development/appli/lib/pages/items.dart:65:5)
E/flutter (15195): #7 _ItemsPageState.build.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:114:9)
E/flutter (15195): #8 _PopupMenuButtonState.showButtonMenu.<anonymous closure> (package:flutter/src/material/popup_menu.dart)
E/flutter (15195): #9 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (15195): #10 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (15195): #11 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (15195): #12 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (15195): #13 Future._completeWithValue (dart:async/future_impl.dart:477:5)
E/flutter (15195): #14 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507:7)
E/flutter (15195): #15 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (15195): #16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
I/flutter (15195): Another exception was thrown: type '() => Future<dynamic>' is not a subtype of type '() => Future<Null>'
E/flutter (15195): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (15195): type '() => Type' is not a subtype of type '(Object) => FutureOr<Object>'
E/flutter (15195): #0 _FutureListener.handleError (dart:async/future_impl.dart:145:11)
E/flutter (15195): #1 Future._propagateToListeners.handleError (dart:async/future_impl.dart:645:47)
E/flutter (15195): #2 Future._propagateToListeners (dart:async/future_impl.dart:666:24)
E/flutter (15195): #3 Future._completeError (dart:async/future_impl.dart:485:5)
E/flutter (15195): #4 _SyncCompleter._completeError (dart:async/future_impl.dart:55:12)
E/flutter (15195): #5 _Completer.completeError (dart:async/future_impl.dart:27:5)
E/flutter (15195): #6 MIDApi.getItems.<anonymous closure> (file:///D:/Development/appli/lib/libraries/api.dart)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #7 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (15195): #8 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (15195): #9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (15195): #10 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (15195): #11 Future._complete (dart:async/future_impl.dart:467:7)
E/flutter (15195): #12 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (15195): #13 ajaxGet (file:///D:/Development/appli/lib/libraries/ajax.dart)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #14 MIDApi.getItems (file:///D:/Development/appli/lib/libraries/api.dart:21:12)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #15 _ItemsPageState.request (file:///D:/Development/appli/lib/pages/items.dart:30:39)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #16 PagedGridViewState.onRefresh (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:160:38)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #17 PagedGridViewState.Clear (file:///D:/Development/appli/lib/widgets/paged_grid_view.dart:85:11)
E/flutter (15195): <asynchronous suspension>
E/flutter (15195): #18 _ItemsPageState._onSortOrderChanged.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:67:29)
E/flutter (15195): #19 State.setState (package:flutter/src/widgets/framework.dart:1108:30)
E/flutter (15195): #20 _ItemsPageState._onSortOrderChanged (file:///D:/Development/appli/lib/pages/items.dart:65:5)
E/flutter (15195): #21 _ItemsPageState.build.<anonymous closure> (file:///D:/Development/appli/lib/pages/items.dart:114:9)
E/flutter (15195): #22 _PopupMenuButtonState.showButtonMenu.<anonymous closure> (package:flutter/src/material/popup_menu.dart)
E/flutter (15195): #23 _RootZone.runUnary (dart:async/zone.dart:1381:54)
E/flutter (15195): #24 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (15195): #25 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633:45)
E/flutter (15195): #26 Future._propagateToListeners (dart:async/future_impl.dart:662:32)
E/flutter (15195): #27 Future._completeWithValue (dart:async/future_impl.dart:477:5)
E/flutter (15195): #28 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507:7)
E/flutter (15195): #29 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (15195): #30 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)