Could it be ok to using lv_draw_line() not in the callback function?

Description

Hi, I want to draw a line. The code likes below, I know I could using the lv_line widget to do that. But what I want is to test if lv_draw_line works well. In some of case, I see the lv_draw_line() are in the event callback function, I want to using it not in the callback funciton. would it be works?
Thanks for your kindly help!

What MCU/Processor/Board and compiler are you using?

simulator

What LVGL version are you using?

V8.0

What do you want to achieve?

draw a line using lv_draw_line() not in the callback function

What have you tried so far?

search in forum

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

	lv_obj_t * black_bg = lv_obj_create(m_lvObj);
    //lv_obj_remove_style_all(black_bg);

    lv_obj_set_size(black_bg,  black_bg_w, black_bg_h);
    lv_obj_set_pos(black_bg, 5, y_offset);

    lv_obj_set_style_bg_color(black_bg, lv_color_hex(0x000000), 0);
    lv_obj_set_style_bg_opa(black_bg, LV_OPA_COVER, 0);

    lv_obj_refr_size(black_bg);

    //lv_obj_invalidate(black_bg);

    lv_draw_line_dsc_t line_dsc_default;
    lv_draw_line_dsc_init(&line_dsc_default);
    lv_obj_init_draw_line_dsc(black_bg, LV_PART_MAIN, &line_dsc_default);

    // //first line
    lv_area_t com_area = black_bg->coords;
    lv_point_t p1;
    lv_point_t p2;
    p1.x = com_area.x1 + 0;
    p1.y = com_area.y1 + 30;

    p2.x = p1.x + lv_area_get_width(&com_area);
    p2.y = p1.y ;

    //line_dsc_default.color.full = 0x0000FF00;
    line_dsc_default.color = lv_color_hex(0xAFB5BF);
    line_dsc_default.width = 20;
    lv_draw_line(&p1, &p2, &com_area, &line_dsc_default);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.