FlutterArtist Code Flow Viewer
Debug Code Flow Viewer is one of the most critical and unique debugging features of FlutterArtist. This tool is designed with two primary objectives:
- For Platform Developers: Helps observe the "flow" of source code in detail. With the Line-Code-Id identification system (e.g., #11111, #22222), you can instantly trace the exact location of the executed line of code within tens of thousands of platform code lines.
- For the Application Developer: It provides a visual insight into how FlutterArtist operates under the hood, helping you understand the data processing logic without getting lost in traditional Logs.


1. Code Flow Viewer
FlutterArtist's strength lies in its sequential execution of TaskUnit(s) placed in an Execution Queue. During execution, a TaskUnit can generate subsequent TaskUnit(s) and add them to the queue. This process continues until the queue is completely empty.
Hãy xem điều gì xảy ra khi bạn mở ví dụ Currency01a trong ứng dụng FlutterArtist Demo:

No ADS
Hãy nhìn xem trên màn hình ví dụ Currency01a có một vài thành phần giao diện đặc biệt như BlockItemsView, BlockItemDetailView, BlockSectionView và BlockControlBar. Ban đầu không có bất kỳ một dữ liệu nào được hiển thị, nhưng sự xuất hiện của các thành phần giao diện trên sẽ kích hoạt cơ chế "Natural Load" (tải tự nhiên). FlutterArtist xác định được rằng các thành phần giao diện trên có liên quan tới Currency01aBlock của Currency01aShelf. Một _BlockQueryTaskUnit sẽ được tạo ra làm nhiệm vụ truy vấn dữ liệu cho Block này, sau đó nó được đặt vào hàng đợi. Có thể có nhiều _BlockQueryTaskUnit(s) được tạo ra tương ứng với mỗi Block đang hiển thị trên màn hình.

_BlockQueryTaskUnit trên sẽ truy vấn dữ liệu cho Currency01aBlock. Kết quả bạn nhận được một danh sách các CurrencyInfo(s). Nếu đó là một danh sách không rỗng, một _BlockSetItemAsCurrentTaskUnit sẽ được tạo ra và thêm vào hàng đợi, TaskUnit này sẽ xác định một CurrencyInfo nào đó để thiết đặt thành phần tử hiện thời. Sau khi tất cả các TaskUnit(s) được thực thi và không còn bất kỳ một TaskUnit(s) nào trên hàng đợi, màn hình sẽ được làm mới lại.
Chú ý rằng: Quy trình trên đã được giải thích một cách đơn giản nhất có thể, về cơ bản nó phức tạp hơn một chút. Nếu quan tâm bạn có thể xem thêm các bài viết dưới đây:
- FlutterArtist Natural Load example 1 (***)
- FlutterArtist Queue (***)
FlutterArtist.navigatorObserver
FlutterArtist sử dụng FlutterArtist.navigatorObserver như một RouteObserver để quan sát các thành phần giao diện nào vừa xuất hiện hoặc biến mất khỏi màn hình, từ đó xác định các Block(s) hoặc Scalar(s) nào cần phải truy vấn. Để FlutterArtist có thể hoạt động bạn cần phải đăng ký RouteObserver nói trên với MaterialApp của bạn.
main.dart (*)
GetMaterialApp(
title: 'Flutter Artist Demo',
debugShowCheckedModeBanner: false,
scrollBehavior: const MaterialScrollBehavior().copyWith(
dragDevices: {PointerDeviceKind.mouse, PointerDeviceKind.touch},
),
navigatorObservers: [FlutterArtist.navigatorObserver], // <---
...
)
- FlutterArtist Starter (***)
2. ExecutionTrace(s)

ExecutionTrace chính là một ListItem mà bạn nhìn thấy bên trái của CodeFlowViewerDialog. Một ExecutionTrace chứa nhiều TraceStep(s).
codeFlowRetentionPeriodInSeconds
Theo mặc định, các ExecutionTrace(s) được giữ lại trong danh sách ít nhất 20 giây cho tới khi có thêm các ExecutionTrace(s) mới được thêm vào danh sách. Điều này có nghĩa là khi có thêm ExecutionTrace(s) được thêm vào danh sách các phần tử cũ hơn 20 giây sẽ bị loại bỏ, ngược lại chúng vẫn được giữ lại trong danh sách. Bạn có thể cấu hình giá trị này thông qua phương thức FlutterArtist.config() (được gọi trong file main.dart).
main.dart (*)
await FlutterArtist.config(
...
codeFlowRetentionPeriodInSeconds: 20,
...
);No ADS
Startup

Startup là một ExecutionTrace ghi lại nhật ký những gì xẩy ra khi người dùng vừa bắt đầu truy cập vào ứng dụng. Có rất nhiều bước được thực thi ở nền của ứng dụng tại thời điểm này.
- Ghi lại nhật ký những gì đã xẩy ra khi phương thức FlutterArtist.config() được gọi trong file main.dart. Sau bước này cấu trúc ứng dụng của bạn đã được xác định, và bạn có thể xem nó trên Storage Viewer.
- Đọc các thông tin người dùng đăng nhập trước đó đã được lưu lại tại thiết bị của người dùng (Username, AccessToken,.), các thông tin này có thể giúp người dùng bỏ qua việc phải đăng nhập lại.
- Tải thông tin toàn cục từ máy chủ cho người dùng vừa tự động đăng nhập.
- Đọc thông tin Locale (ngôn ngữ, vùng miền) mà người dùng ưa thích trong lần sử dụng ứng dụng trước đó và áp dụng cho lần sử dụng này.
- Đọc thông tin Theme mà người dùng ưa thích trong lần sử dụng ứng dụng trước đó và áp dụng cho lần sử dụng này.
User-Method-Call

User-Method-Call là một ExecutionTrace đánh dấu vị trí một hàm hoặc một phương thức nào đó của bạn. Một khi phương thức này được gọi, một ExecutionTrace (User-Method-Call) sẽ được tạo ra, điều này giúp bạn biết chính xác mã của bạn được viết tại file nào và dòng nào.
class ExampleBox extends StatelessWidget {
...
void _showExample() {
FlutterArtist.codeFlowLogger.addMethodCall(
ownerClassInstance: this,
currentStackTrace: StackTrace.current,
parameters: {},
);
// Other code...
}
...
}No ADS

Lib-Method-Call

ExecutionTrace này ghi lại một vài thông tin khi một hàm hoặc một phương thức nào đó của thư viện FlutterArtist được gọi. Các thông tin này bao gồm tên phương thức và các tham số đã được truyền vào.
Natural Load

"Natural Load" đã được giải thích ở phía trên của bài viết.
TaskUnit-Execution

Nhật ký ghi lại những gì đã xẩy ra khi một TaskUnit được thực thi. Có rất nhiều loại TaskUnit khác nhau:
- blockQuery (_BlockQueryTaskUnit)
- blockSetItemAsCurrent (_BlockSetItemAsCurrentTaskUnit)
- formModelLoadData (_FormModelLoadDataTaskUnit)
- formModelSaveForm (_FormModelSaveFormTaskUnit)
- ...
QueuedEvent Processing

Khi người dùng sửa đổi dữ liệu của một ITEM nào đó của BlockA (ShelfA). Một sự kiện sẽ được tạo ra và được đặt vào hàng đợi. Khi sự kiện này được xử lý nó sẽ gửi tới các Block(s) và Scalar(s) của các Shelf(s) khác và kích hoạt các phản ứng của chúng, chẳng hạn như truy vấn lại.
Tóm lại: ExecutionTrace này sẽ ghi lại nhật ký về sự kiện đó một cách chi tiết bao gồm cả các Block(s) hoặc các Scalar(s) nào sẽ nhận thông báo và cách mà chúng phản ứng. Quá trình này sẽ tạo ra hàng loạt các TaskUnit(s) khác, giống như một chuỗi phản ứng.
No ADS
FlutterArtist
- Basic concepts in Flutter Artist
- FlutterArtist Block ex1
- FlutterArtist Form ex1
- FlutterArtist FormModel.patchFormFields() Ex1
- FlutterArtist BlockQuickItemUpdateAction Ex1
- FlutterArtist BlockNumberPagination Ex1
- FlutterArtist BlockQuickMultiItemCreationAction Ex1
- FlutterArtist ListView Infinite Scroll Pagination Example
- FlutterArtist Pagination
- FlutterArtist Sort DropdownSortPanel Example
- FlutterArtist Dio
- FlutterArtist BackgroundWebDownloadAction ex1
- FlutterArtist Block External Shelf Event ex1
- FlutterArtist Master-detail Blocks ex1
- FlutterArtist Scalar ex1
- FlutterArtist Pagination Davi table Infinite Scroll Ex1
- FlutterArtist Filter FormBuilderField ex1
- FlutterArtist Form Parent-child MultiOptFormProp ex1
- FlutterArtist Manual Sorting ReorderableGridView Example
- FlutterArtist Manual Sorting ReorderableListView
- FlutterArtist Scalar External Shelf Event ex1
- FlutterArtist Code Flow Viewer
- FlutterArtist Log Viewer
- FlutterArtist config
- FlutterArtist StorageStructure
- FlutterArtist Debug Storage Viewer
- FlutterArtist DebugMenu
- FlutterArtist Context Provider Views
- FlutterArtist Internal Shelf Event ex1
- FlutterArtist Deferring External Shelf Events (Ex1)
- FlutterArtist DropdownSortPanel
Show More