How can i fix the bottom navigator error in dart - java

I was making a BottonNavigation bar in flutter dart and i am getting an error
the code is
This the code
the error is
And this the error pls help
I want a solution for this error if someone can help me i will thank them a lot
The console version is this

you need to pass NavigationDestination instead of NavigationDrawerDestination in the destinations params
** sample code snippet **
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
},
selectedIndex: currentPageIndex,
destinations: const <Widget>[
NavigationDestination(
icon: Icon(Icons.explore),
label: 'Explore',
),
NavigationDestination(
icon: Icon(Icons.commute),
label: 'Commute',
),
NavigationDestination(
selectedIcon: Icon(Icons.bookmark),
icon: Icon(Icons.bookmark_border),
label: 'Saved',
),
],
),
follow official documentation https://api.flutter.dev/flutter/material/NavigationBar-class.html (material you/3)
or If you are using other package for it check its documentation
or you can also use
https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html (material 2)

Related

How to retrieve text value from RichText in flutter?

Here's the Flutter code:
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(bottom: LuminaSpacing.extraTiny),
child: RichText(
key: Key('last_updated'),
textAlign: TextAlign.end,
text: TextSpan(
text: '${_localize.last_updated}: ',
style: wldTheme.textTheme.display1,
children: <TextSpan>[
TextSpan(
text: '${settingStore.lastCheckinTime}',
style: wldTheme.textTheme.body1),
],
),
),
),
I'm using appium with java to automate my test cases
Here's my code:
FlutterFinder ele = new FlutterFinder(driver);
System.out.println("Last update: "+ele.byValueKey("last_update"));
// System.out.println("Last update: "+ele.byValueKey("last_update").getText()); // It waits for long duration
The output I get is
Last update: [pro.truongsinh.appium_flutter.finder.FlutterElement#870fb657 -> unknown locator]
you need to create a controller like this: var textController = TextEditingController(); and aggregate the controller to your RichText widget, with this controller you can get the value of the text like this: textController.text

Create sheet and update data with one request

I want to implement Google sheets api request with one api call.
I managed to implement this code:
List<Request> requests = new ArrayList<>();
List<CellData> values = new ArrayList<>();
values.add(new CellData()
.setUserEnteredValue(new ExtendedValue()
.setStringValue("Hello World!")));
requests.add(new Request().setAddSheet(new AddSheetRequest()
.setProperties(new SheetProperties()
.setTitle("scstc")))
.setUpdateCells(new UpdateCellsRequest()
.setStart(new GridCoordinate()
.setSheetId(0)
.setRowIndex(0)
.setColumnIndex(0))
.setRows(Arrays.asList(
new RowData().setValues(values)))
.setFields("userEnteredValue,userEnteredFormat.backgroundColor"))
);
BatchUpdateSpreadsheetRequest body = new BatchUpdateSpreadsheetRequest().setRequests(requests);
BatchUpdateSpreadsheetResponse response = service.spreadsheets().batchUpdate(spreadsheetId, body).execute();
But I get error:
400 Bad Request
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid value at 'requests[0]' (oneof), oneof field 'kind' is already set. Cannot set 'updateCells'",
"reason" : "badRequest"
} ],
"message" : "Invalid value at 'requests[0]' (oneof), oneof field 'kind' is already set. Cannot set 'updateCells'",
"status" : "INVALID_ARGUMENT"
}
at com.google.sheet.impl.GoogleSheetBasicTest1_____1.hello(GoogleSheetBasicTest1_____1.java:133)
Do you how how I can fix this issue?
Each Request object is intended to have just a single value set within it. You are setting two values:
requests.add(new Request()
.setAddSheet(...)
.setUpdateCells(...));
Instead of doing the above, you need to use two request objects:
requests.add(new Request().setAddSheet(...));
requests.add(new Request().setUpdateCells(...));
#Sam is correct, however if you are using the JSON representation make sure that your formatting is set correctly in the dictionaries you are making. I found the following formating helpfull, found in the Google Devs' Formatting cells with the Google Sheets API
blogpost:
reqs = {'requests': [
# frozen row 1, request #1
{'updateSheetProperties': {
'properties': {'gridProperties': {'frozenRowCount': 1}},
'fields': 'gridProperties.frozenRowCount',
}},
# embolden row 1, request #2
{'repeatCell': {
'range': {'endRowIndex': 1},
'cell': {'userEnteredFormat': {'textFormat': {'bold': True}}},
'fields': 'userEnteredFormat.textFormat.bold',
}},
]}
*I am new to adding information to this site. Sorry if this is not he best way to add the information but I just want to help out. I had this problem while using python instead of java and found that it was a simple error of were the brackets where.

ST3 Can't write dot ["."] while "Java syntax" is on

I am using Sublime Text 3 and I can't (that means when I press the key nothing happens) . while I have active java syntax. When I switch to another syntax (f.e. Javascript) problem is gone. Do anyone solved had/solved this problem?
[Installed packages]
{
"installed_packages":
[
"AngularJS",
"Better JavaScript",
"Display Functions (Java)",
"DocBlockr",
"EditorConfig",
"Emmet",
"Format SQL",
"Git",
"Goto Documentation",
"Grunt",
"HexViewer",
"HTML Boilerplate",
"HTML5",
"JavaPropertiesEditor",
"Javascript Beautify",
"jQuery",
"JsFormat",
"LESS",
"LineEndings",
"MoveTab",
"Nette",
"Nunjucks Syntax",
"Package Control",
"PHP Namespace Command",
"PHP-Twig",
"Phpcs",
"PhpDoc",
"Quick File Move",
"SideBarEnhancements",
"SJSON",
"SublimeLinter",
"SublimeLinter-csslint",
"SublimeLinter-html-tidy",
"SublimeLinter-jshint",
"SublimeLinter-json",
"SublimeLinter-php",
"Theme - Phoenix",
"VCS Gutter",
"WordCount"
]
}
[User settings]
{
"color_scheme": "Packages/User/Monokai (SL).tmTheme",
"default_line_endings": "unix",
"detect_slow_plugins": false,
"draw_white_space": "selection",
"ensure_newline_at_eof_on_save": true,
"font_face": "Consolas",
"font_size": 10,
"highlight_line": true,
"ignored_packages":
[
"JavaScript",
"Vintage",
"tern_for_sublime"
],
"show_encoding": true,
"show_line_endings": true,
"translate_tabs_to_spaces": true
}
According to sergioFC comment I did sublime.log_commands(True) and it showed up that package Display Functions (Java) is "blocking" the . key. Disabling the package solved my problem.

jqgrid search with loadonce

i'm having a problem with jqgrid searching. my code works perfectly with add, edit, delete except searching. Once I load it the data shown fine, but if I click find button, it never does anything.
I have been looking for it everywhere but I can't find what's wrong. If I use loadonce : true then searching works but now having problem with paging and sorting the grid. I wanna make it work perfectly with paging, sorting, and searching.
here's my code.
$("#material_list").jqGrid({
url:"MY URL",
editurl:"MY URL",
mtype:"post",
caption:"LIST",
datatype:"json",
height:"auto",
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: true
},
rowNum:10,
rowList:[5,10,15],
colNames:["PROD_CODE","PROD_NAME","COMP_CODE","UNIT","STANDARD","USEFLAG"],
colModel:[
{name:"PROD_CODE", index:"PROD_CODE", editable:true},
{name:"PROD_NAME", index:"PROD_NAME", editable:true},
{name:"COMP_CODE", index:"COMP_CODE", editable:true},
{name:"UNIT", index:"UNIT", editable:true},
{name:"STANDARD", index:"STANDARD", editable:true},
{name:"USEFLAG", index:"USEFLAG", editable:true}
],
pager:"#pager",
autowidth:true,
viewrecords:true,
//loadonce:true,
});
$("#material_list").jqGrid(
"navGrid",
"#pager",
{search:true, edit:true, add:true, del:true},
{closeAfterEdit:true, reloadAfterSubmit:true},
{closeAfterAdd:true, reloadAfterSubmit:true},
{reloadAfterSubmit:true}
);

jQuery access java Map of string object where the object is a map of strings

I am trying to return two json sets from java which each contain key/value pairs. I can get the data to return as expected but once I have the data I can not access it properly. Here is what my data coming from the java looks like
{"RESULTS":
{"MAP_1":
[
{"value":"1","display":"output text","type":"type a"},
{"value":"2","display":"more output text","type":"type a"}
],
"MAP_2":
[
{"value":"1","display":"output text","type":"type b"},
{"value":"2","display":"more output text","type":"type b"}
]
}
}
I have tried using $.map and $.each but I can not seem to drill into the data any help would be greatly appeciated.
Here is my latest attempt:
$.ajax({
url: url,
dataType: "text",
data: {
searchString: request.term
},
success: function( data ) {
response( $.map( data.MAP_1, function( item ) {
label: item.value + ", " + item.type
value: item.display
}));
}
});
Thanks in advance!
The format of the data returned by java is text, not json. So you should specify the dataType as json. In addition the following code are not right, I think.
data.MAP_1
should be
data.RESULTS.MAP_1

Categories