How to create custom flutter sdk widget, rebuild flutter and use new widget - flutter

I'm trying to figure out how to build a custom flutter sdk with a widget that I added.
background: I realized that the PaginatedDataTable requires a header (per this: https://github.com/flutter/flutter/issues/38604) and I'd like to update that widget to make it optional.
Github user wolfcro1984 has a pull request to do the same thing here: https://github.com/flutter/flutter/pull/26352/files
and I'd like to use that code in my current flutter version. However, I'm not sure how to actually build flutter again after that change so that I can use that widget.
How do you build the flutter sdk in order to make a custom flutter version? Is there documentation out there somewhere?

The best way is to copy the code in your own dart file and do the modification. You can go to paginated_data_table.dart, grab all the code and put it in your own .dart file.
How to remove the header :
Go to paginated_data_table.dart (equivalent)
Remove #required before 'header' parameter.
Remove assert(header != null)
Go to Widget build method and remove Semantics. This is under CARD section in comments.
I took a sample from here, did the modification and the result is :
The edits I made are here.
Note : You'll need to change the import part when you copy the standard code in your custom widget.

Related

Build connection between flame and flutter

I have a flutter widget ProgressBar, which needs to be notified when a change happens to a value in Flame,
I followed a tutorial which is using overlays.notifyListeners(); to update the StatelessWidget progressBar, but after I updated to the newest Flame version (v1.6.0), this method can not be used anymore, what is the correct way of doing this now?
There are a few different ways to do this, either you can use state management libraries like flame_riverpod or flame_bloc to achieve this, or you can wrap your value in a ChangeNotifier/ValueNotifier and update the state once the value updates.

How to use localisation with Flutter PDF package since PDF Page has no BuildContext?

I'm using Flutter pdf package inside my project (https://pub.dev/packages/pdf). The package generates a document which I show on the screen. I want to add localisation (localised Text fields) into my generated pdf document but AppLocalizations.of(context) requires BuildContext, not just a Context.
As I understood, generated pdf file is not a part of material Scaffold, so there is no way to access BuildContext.
Page constructor
Any ideas how to get access to BuildContext when I configure localised Text strings in my pdf Page?
I tried to find the answer on package page and package repo, but I have not found any solution so far.
instead of passing the context, try to call AppLocalizations as a singleton without passing the context. some intl libraries provide singlton, if you couldn't find any, try to store the instance in GetIt , or build your own technique and store it in main widget.

Flutter: how get all properties for all widgets's objects in my flutter app by dart Code to use it in Test?

Flutter: how get all properties for all widgets's objects in my flutter app by dart Code to use it in Automated Testing ?
I know exist three types from testing :
1. Unit tests.
2. Widget tests.
3. Integration tests.
But I just want to know all the details about each Widget and also Write it in a text file?
for Example this image explain an example in Dev tool But I neet it by codeing
Thanks in advance
In your tests you could use this code to access the properties of a widget in the current tree:
final FloatingActionButton fab = tester.widget(find.byType(FloatingActionButton));
expect(fab.tooltip, ...);
Here you tell the WidgetTester to find a widget in the current widget tree, when a widget is found you can access its properties.
Important, that your 'First A, Arrange' is correctly setup, thus a widget tree is build and the widget you're looking for is available.
When you are searching for a more generic widget which occures more then once in the widget tree I suggest using the find.byKey method, like so:
tester.widget(find.byKey(Key('exampleKey')));
Ofcourse, the Finder widget has more than two methods, thus any of the other find methods could be used.
Greetz

How access to value of a variable in flutter package from other widget?

I wrote a package for Flutter and added it to the main.dart and it works well but How can I access the value of one of the variables in the package? or how return a variables from it ? For example, in the slider widget, we have access to the value of the slider with on change .
You want to learn how to manage state in flutter.
There are couple of good state management tools:
provider seems to be the easiest one.
Here is a nice tutorial on provider:
https://blog.codemagic.io/flutter-tutorial-app-arhitecture-beginners/

Const variables and instances storing

I just have read about "const" widget allocation in build method, so in this scenario, widgets get allocated when the app starts, how they stores and where?. Do they increase apps size?
How compiled Flutter widgets are stored and where?
Flutter application is AOT-compiled (ahead-of-time) to native platform code. Each Flutter widget is compiled to native widgets and they are rendered to Skia canvas which is shown to the end user platform. Platform sends back all events which are than handled by compiled Flutter code.
I do highly recommend to check those articles:
https://github.com/flutter/flutter/wiki/The-Engine-architecture
https://medium.com/47billion/flutter-how-does-it-works-6e4c73842e67
When to use const widgets in Flutter?
Use const widgets where possible in StatefullWidget
Why? Simply remember that calling StatefullWidget setState will rebuild the whole widget. By specifying const for the child widgets of StatefullWidget you'll say that they do not need to be rebuilt on setState call.
Here is the link to official documentation:
https://api.flutter.dev/flutter/widgets/StatefulWidget-class.html#performance-considerations
Regarding whether they increase app size:
I believe Dart 2.0 made const optional, that is, the compiler will mark it as const on its own given the right context. Here are a few resources that point to this:
"Don't use const redundantly" - Effective Dart Usage
"Dart 2 introduces optional new and const" - Announcing Dart 2.0
So, if the compiler does this automatically, I think it's safe to assume that there won't be a compromise on app/size performance. I hope this answers your question.