Flutter Cross‑Platform Implementation Practices at Kaiyan Kuaichuang
This article introduces Kaiyan Kuaichuang's Flutter‑based cross‑platform architecture, covering component layering, state‑management strategies (BLoC, Provider, Redux, Built_redux), data communication via gRPC/ProtoBuf, and a custom URL‑based routing solution, while sharing practical code snippets and lessons learned.
The article presents the first installment of a Flutter series, describing how Kaiyan Kuaichuang builds a fully Flutter‑based product for commercial advertising creation, outlining its layered architecture (platform embed layer, communication layer, and app layer) and the benefits of a pure Flutter approach.
Overall Architecture – The project adopts a componentized, multi‑layered structure with Android/iOS embed layers at the bottom, a communication layer that bridges platform and Flutter via Platform Channels, Dart FFI, and a top‑level app layer containing business logic and UI components. Over 10 reusable components have been published to a mobile developer center, and more than 90% of the codebase is pure Flutter.
State Management – Two categories are discussed: page‑internal state managed with BLoC (using Streams and optionally RxDart) and cross‑page state handled by Redux (store, immutable state, reducers) or Provider/InheritedWidget for simpler cases. The article notes limitations of BLoC for inter‑page sharing and highlights Redux’s ability to decouple logic and view.
Code example for a typical Redux state update in JavaScript (shown for reference): newState = { ...oldState, someKey:newValue }
In Dart, a manual copyWith method is often required; an example implementation is provided: class AppState { final int counter; final String name; AppState({this.counter = 0, this.name = "John"}); AppState copyWith({counter, name}) { return new AppState(counter: counter ?? this.counter, name: name ?? this.name); } }
Built_redux can generate similar functionality automatically. Example snippet: @override AppState rebuild(void Function(AppStateBuilder) updates) => (toBuilder()..update(updates)).build();
Communication – Data communication is realized through a centralized Bridge that abstracts Platform Channels, and for complex scenarios the team uses gRPC with Protocol Buffers. ProtoBuf ensures type‑safe, binary‑efficient serialization across Dart, Java, and Objective‑C, while gRPC provides high‑performance RPC with full‑duplex capabilities (GrpcX). The article includes diagrams of the data flow.
Page navigation is handled by a custom URL‑based router (KRoute) generated via build_runner, offering type‑safe parameters, unified transition animations, and fallback to H5 when needed.
Conclusion – The pure Flutter implementation yields unified UI, functionality, and logic across platforms, reduces maintenance overhead, and improves performance. Future articles will dive deeper into audio‑video use cases and further optimization techniques.
Kuaishou Tech
Official Kuaishou tech account, providing real-time updates on the latest Kuaishou technology practices.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.