What does external keyword mean in Dart? [duplicate] - flutter

This question already has answers here:
What does external mean in Dart?
(6 answers)
Closed 2 years ago.
For example: this is a private named constructor of DateTime class from date_time library :
external DateTime._now();

I found a stack overflow post asking the same question:
What does external mean in Dart?
9.4 External Functions An external function is a function whose body is provided separately from its declaration. An external function may
be a top-level function (17), a method
The body of the function is defined somewhere else. As far as I know
this is used to fix different implementations for Dart VM in the
browser and Dart VM on the Server.
-Günter Zöchbauer

Related

Catalyst FormFu DBIC error - using dot notation in a resultset [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 29 days ago.
Improve this question
I've inherited a Perl Catalyst application that I'm trying to port to a new server. The application uses FormFu with the HTML::FormFu::Model::DBIC module used to load data from a result set.
I have a DBIx table, say MyTable, with an auto-generated Result implementation and a custom ResultSet implementation. In the custom ResultSet implementation there are some subroutines, e.g. sub my_sub, that return filtered subsets of data.
In a FormFu YAML file, the following will fetch all the records from MyTable:
elements:
- type: Select
model_config:
resultset: MyTable
This is equivalent to fetching, in a Controller, $schema->resultset('MyTable'). This executes correctly on both the old server and the new server.
On the old server, I can use dot notation to call the subroutine to fetch the subset of records it returns like so:
elements:
- type: Select
model_config:
resultset: MyTable.my_sub
This is equivalent to fetching in a Controller, $schema->resultset('MyTable')->my_sub. This executes correctly on the old server. On the new server, in FormFu, this throws the error:
Can't find source for MyTable.my_sub at /[...]/HTML/FormFu/Model/DBIC.pm
I've added debugging to the FormFu DBIC.pm module to see if it's doing anything special. The code it calls is $schema->resultset($rs_name); where rs_name is the name given in the resultset parameter, "MyTable.my_sub", and $schema is of type Moose::Meta::Class::__ANON__::SERIAL, which I assume is some kind of wrapper. Within a Catalyst controller, a schema is of type myapp::Schema.
What am I missing? Is there some configuration option I need to set? Some module I need to install? I can't find any documentation or examples that show a FormFu resultset with dot notation, yet on the old server it works.
When I attempted to add logging to the working DBIC.pm file, I discovered that the developer from whom I inherited this application symlinked the module's DBIC.pm file to a custom DBIC.pm file in his own home folder with the extended functionality.

Dart - How to access global scope? [duplicate]

This question already has answers here:
How can I call a function from a method of the same name?
(3 answers)
Closed 12 months ago.
The simple actual question is
How to access GLOBAL scope in Dart?
Below is just the answer why I'm looking for it.
I have a problem which requires me to learn about Dart's scope resolution from here but unfortunately I can't find the solution for my problem, not even from Google or here, which was surprising me to have to open this question.
Dart allows user to exclude the this. on member variable access within class's scope so if two potentially conflicted variables need to share the same name, they need to be differentiated with scope operator and reference.
I need to define a class with member variable print where there is also global function print being called somewhere within the class. Of course print() => print(...) will returns error so I'm expecting something as simple as print() => global.print(..) but neither that is working.
I know there's workaround to solve it but please I need a straightforward one if any. Thank you.
you could add this line at the top of your file:
import 'dart:core' as core;
Then you would be able to refer to print as core.print(...);
The problem is that now you would have to use core. for every primitives like int, example:
core.int variable = 1;
I think this is not worth it and it's better to use another name for your print method.

What is the point of adding 'new' in front of a widget in Flutter? [duplicate]

This question already has answers here:
Do you need to use the "new" keyword in Dart?
(3 answers)
Closed 2 years ago.
For instance,
return new Container(child: new Text('Hello'),);
VS
return Container(child: Text('Hello'),);
I see people use both and was just wondering what the point is. Is it possible to use the same widget again somewhere or something?
the "new" keyword was once required in dart (the language used for flutter) for object instantiation, but this requirement was removed.
In order to prevent breaking old code, the keyword remains but is now optional. There is no difference between using it or not using it.
You may choose to use it if you want to make it clear that you are intending to do object instantiation and not call a function, as attempting to do new somefunction() //not a constructor will fail, though this is optional.

How to call a helper function from a library class [duplicate]

This question already has answers here:
How do you load a helper within a library in codeigniter?
(2 answers)
Closed 12 months ago.
I have a library class "Weekprint.php" (libraries/Weekprint.php) and in a helper file (calendar_helper.php) I have function like
print_calendar($start, $events, $cal_type).
I can use them separately,
I wonder if/how I can call print_calendar from Weekprint.
I use Codeigniter 3.1.5
You can call the helper from the library. The helper needs to be loaded before it can be used. Pick the logical spot in Weekprint.php to do that in the usual way.
$this->load->helper('calendar_helper');
After that, you can call it in the usual way when needed.
print_calendar($start, $events, $cal_type);
Obviously, the various arguments to the helper function need to be assigned values.
I could do it,
$CI = &get_instance();
$CI->load->helper('calendar_helper');
Inside the library Weekprint.php

Durable variable in powershell [duplicate]

This question already has answers here:
Permanent PowerShell variable
(7 answers)
Closed 9 years ago.
I wrote a powershell module in c# which allows me to call some webservices.
Before I can use them, I have to specify where the service is located. For example:
Set-ServiceUrl 'http://myService.cloudapp.net/'
Create-Something ...
Get-Something ...
The test functions Create-Something and Get-Something accessing a static variable "serviceurl" which is set within the Set-ServiceUrl function.
This is similar to the Azure module where you have to call Set-AzureSubscription before you can query the services.
The diffrent between my and the Azure module is, that I have to specifiy the service url for my module for each time I start the powershell whereas I have to set the AzureSubscription only once.
Is there any mechanism in powershell to store such information "forever"? Or do I have to use a file-based / registry or environment-variable solution? What would you suggest?
PowerShell has no built-in method for persisting data across sessions; you must come up with a way to store & retrieve it yourself.
One way would be to store it in a global variable and check it from other functions or even assign the value of the variable to the required parameter.
There's no "forever" mechanism, even the Azure team saves their information to disk.