This study proposes a berth-flow network modeling approach to deal with the dynamic berth allocation problem (DBAP) with stochastic vessel arrival times. In this approach, uncertain vessel arrival times are represented using discrete probability distributions and a flexible berth allocation scheme based on the blocking plan concept is incorporated into the model to effectively utilize wharf space. This new model is referred to as the stochastic dynamic (vessel arrival) and flexible (berth space) berth allocation problem (SDFBAP) model. The aim is to minimize the sum of the expected values of unanticipated schedule delay costs and the penalties for being unable to service all vessels within the planning horizon. The proposed model is formulated as an integer multi-commodity network flow problem which can be solved with off-the-shelf solvers. Computational experiments are conducted using a real example to demonstrate the effectiveness and efficiency of the SDFBAP model. A simulation-based approach is adopted to evaluate the SDFBAP model. A number of scenario analyses are also conducted to gain insight into important model parameters.