├── .github └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── README.zh.md ├── analysis_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── sample │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ ├── app.dart │ ├── main.dart │ ├── pages │ │ ├── count │ │ │ ├── action.dart │ │ │ ├── page.dart │ │ │ ├── reducer.dart │ │ │ └── state.dart │ │ └── todos │ │ │ ├── edit │ │ │ ├── action.dart │ │ │ ├── effect.dart │ │ │ ├── page.dart │ │ │ └── state.dart │ │ │ ├── page │ │ │ ├── adapter.dart │ │ │ ├── page.dart │ │ │ └── state.dart │ │ │ ├── report │ │ │ ├── component.dart │ │ │ └── state.dart │ │ │ └── todo │ │ │ ├── action.dart │ │ │ ├── component.dart │ │ │ ├── effect.dart │ │ │ ├── reducer.dart │ │ │ └── state.dart │ ├── routes.dart │ └── sample.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ ├── main.cc │ ├── my_application.cc │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── flying-redux.png ├── lib ├── flying_redux.dart └── src │ ├── _readme.dart │ ├── component │ ├── basic.dart │ ├── component.dart │ ├── connector.dart │ ├── index.dart │ ├── page.dart │ └── route.dart │ └── redux │ ├── basic.dart │ ├── create_store.dart │ ├── index.dart │ └── middleware.dart ├── logo-mini.png ├── logo.jpeg ├── pubspec.yaml ├── qq.jpg ├── test ├── .gitignore ├── analysis_options.yaml ├── flying_redux_test.dart ├── lib │ ├── all_test.dart │ ├── component │ │ ├── adapter_test.dart │ │ ├── component_test.dart │ │ ├── index_test.dart │ │ ├── lifecycle_test.dart │ │ ├── page_test.dart │ │ └── route_test.dart │ ├── instrument.dart │ ├── redux │ │ ├── index_test.dart │ │ └── store_test.dart │ ├── test_widgets │ │ ├── component │ │ │ ├── action.dart │ │ │ ├── component.dart │ │ │ ├── page.dart │ │ │ └── state.dart │ │ ├── main.dart │ │ ├── page │ │ │ ├── action.dart │ │ │ ├── exception.dart │ │ │ ├── page.dart │ │ │ └── state.dart │ │ └── test_base.dart │ └── track.dart └── pubspec.yaml └── wechat.jpg /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: subosito/flutter-action@v2 15 | with: 16 | flutter-version: 3.0.0 17 | channel: stable 18 | - run: flutter doctor 19 | - run: flutter pub get 20 | - run: flutter test --coverage #--coverage-path=lcov.info 21 | - name: Upload coverage reports to Codecov 22 | uses: codecov/codecov-action@v3 23 | with: 24 | files: ./coverage/lcov.info 25 | verbose: true 26 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: '>> Dart package <<' 13 | uses: k-paxian/dart-package-publisher@master 14 | with: 15 | accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }} 16 | refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }} 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .packages 30 | build/ 31 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.1.0] 2 | 3 | * code test 4 | * fix bug. 5 | 6 | ## [0.0.3-pre] 7 | 8 | * fix lints. 9 | 10 | ## [0.0.2-pre] 11 | 12 | * fix bug. 13 | 14 | ## [0.0.1-pre] 15 | 16 | * support flutter 3.x. 17 | * state management. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 |

flying-redux

15 | 16 | 17 | [![pub package](https://img.shields.io/pub/v/flying_redux.svg?label=pub&color=blue)](https://pub.dev/packages/flying_redux) 18 | [![build](https://github.com/GavinHome/flying-redux/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/GavinHome/flying-redux/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/gavinhome/flying-redux/branch/master/graph/badge.svg)](https://codecov.io/gh/gvinhome/flying-redux) 19 | [![popularity](https://img.shields.io/pub/popularity/flying_redux?logo=dart)](https://pub.dev/packages/flying_redux/score) 20 | [![likes](https://img.shields.io/pub/likes/flying_redux?logo=dart)](https://pub.dev/packages/flying_redux/score) 21 | [![pub points](https://img.shields.io/pub/points/flying_redux?logo=dart)](https://pub.dev/packages/flying_redux/score) 22 | [![size](https://img.shields.io/badge/size-35KB-blue)](https://github.com/GavinHome/flying-redux/tree/master/lib) 23 | [![code](https://img.shields.io/badge/LOC-1278-blue)](https://github.com/GavinHome/flying-redux/tree/master/lib) 24 | 25 | 26 | 27 | ## What is Flying Redux? 28 | 29 | Flying Redux is also an assembled flutter application framework based on Redux state management. 30 | 31 |

flying-redux-framework

32 | 33 | ## Features 34 | 35 | It has four characteristics: 36 | 37 | > 1. Functional Programming 38 | > 2. Predictable state container 39 | > 3. Pluggable componentization 40 | > 4. Support null safety and flutter 3.x 41 | 42 | ## Getting started 43 | 44 | There are five steps to use the counter as an example: 45 | 46 | > 1. Import flying_redux package 47 | > 2. Create State and InitState 48 | > 3. Define Action and ActionCreator 49 | > 4. Create Reducer that modifies state 50 | > 5. Create Page or Component 51 | 52 | ```dart 53 | import 'package:flying_redux/flying_redux.dart'; 54 | 55 | /// [State] 56 | class PageState extends Cloneable { 57 | late int count; 58 | 59 | @override 60 | PageState clone() { 61 | return PageState()..count = count; 62 | } 63 | } 64 | 65 | /// [InitState] 66 | PageState initState(Map? args) { 67 | //just do nothing here... 68 | return PageState()..count = 0; 69 | } 70 | 71 | /// [Action] 72 | enum CounterAction { increment } 73 | 74 | /// [ActionCreator] 75 | class CounterActionCreator { 76 | static Action increment() { 77 | return const Action(CounterAction.increment, payload: 1); 78 | } 79 | } 80 | 81 | /// [Reducer] 82 | buildReducer() { 83 | return asReducer(>{ 84 | CounterAction.increment: _increment, 85 | }); 86 | } 87 | 88 | PageState _increment(PageState state, Action action) { 89 | final int num = action.payload; 90 | return state.clone()..count = (state.count + num); 91 | } 92 | 93 | /// [Page] 94 | class CountPage extends Page> { 95 | CountPage() 96 | : super( 97 | initState: initState, 98 | reducer: buildReducer(), 99 | view: (PageState state, Dispatch dispatch, ComponentContext ctx) { 100 | return Scaffold( 101 | body: Center( 102 | child: Column( 103 | mainAxisAlignment: MainAxisAlignment.center, 104 | children: [ 105 | const Text( 106 | 'You have pushed the button this many times:', 107 | ), 108 | Text(state.count.toString()), 109 | ], 110 | ), 111 | ), 112 | floatingActionButton: FloatingActionButton( 113 | onPressed: () => dispatch(CounterActionCreator.increment()), 114 | tooltip: 'Increment', 115 | child: const Icon(Icons.add), 116 | ), // This trailing comma makes auto-formatting nicer for build methods. 117 | ); 118 | }); 119 | } 120 | ``` 121 | 122 | ## Usage 123 | 124 | If you want to know specific usage examples, please refer to the todo list code in the example project and in the `/example` folder. 125 | 126 | - [todo list](example) - a simple todo list demo. 127 | - run it: 128 | 129 | ``` dart 130 | cd ./example 131 | flutter run 132 | ``` 133 | 134 | ## Code Template 135 | 136 | - [Flying Redux Template For VSCode](https://github.com/GavinHome/flying-redux-template-for-vscode). 137 | - [Flying Redux Template For AndroidStudio](https://github.com/GavinHome/flying-redux-template-for-as). 138 | 139 | ## Additional information 140 | 141 | In particular, the code of flying-redux has the same naming and implementation as fish-redux. 142 | Because [fish-redux](https://github.com/alibaba/fish-redux) has not been updated for a long time. 143 | I have done a lot of refactoring and modification based on fish_redux, and simplified some concepts, 144 | and finally renamed it. 145 | If you have any questions, please scan the qq QR code below to enter the group communication. 146 | 147 |

qq

148 | -------------------------------------------------------------------------------- /README.zh.md: -------------------------------------------------------------------------------- 1 |

flying-redux

2 | 3 | 4 | [![pub package](https://img.shields.io/pub/v/flying_redux.svg?label=pub&color=blue)](https://pub.dev/packages/flying_redux) 5 | [![build](https://github.com/GavinHome/flying-redux/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/GavinHome/flying-redux/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/gavinhome/flying-redux/branch/master/graph/badge.svg)](https://codecov.io/gh/gvinhome/flying-redux) 6 | [![popularity](https://img.shields.io/pub/popularity/flying_redux?logo=dart)](https://pub.dev/packages/flying_redux/score) 7 | [![likes](https://img.shields.io/pub/likes/flying_redux?logo=dart)](https://pub.dev/packages/flying_redux/score) 8 | [![pub points](https://img.shields.io/pub/points/flying_redux?logo=dart)](https://pub.dev/packages/flying_redux/score) 9 | [![size](https://img.shields.io/badge/size-35KB-blue)](https://github.com/GavinHome/flying-redux/tree/master/lib) 10 | [![code](https://img.shields.io/badge/LOC-1278-blue)](https://github.com/GavinHome/flying-redux/tree/master/lib) 11 | 12 | 13 | ## 简介 14 | 15 | Flying Redux 是一个基于Redux状态管理的组装式flutter应用框架。 16 | 17 |

flying-redux-framework

18 | 19 | 它有四个特性: 20 | 21 | > 1. 函数式编程 22 | > 2. 可预测的状态 23 | > 3. 插拔式的组件化 24 | > 4. 支持null safety 和 flutter 3.x 25 | 26 | ## 如何开始 27 | 28 | 以计数器为例,仅需要5步即可使用flying redux构建应用: 29 | 30 | > 1. 引入 flying_redux 31 | > 2. 创建状态类和初始化状态 32 | > 3. 定义 Action 和 ActionCreator 33 | > 4. 创建修改状态的 Reducer 34 | > 5. 创建组件或页面视图以显示 35 | 36 | ```dart 37 | import 'package:flying_redux/flying_redux.dart'; 38 | 39 | /// [State] 40 | class PageState extends Cloneable { 41 | late int count; 42 | 43 | @override 44 | PageState clone() { 45 | return PageState()..count = count; 46 | } 47 | } 48 | 49 | /// [InitState] 50 | PageState initState(Map? args) { 51 | //just do something here... 52 | return PageState()..count = 0; 53 | } 54 | 55 | /// [Action] 56 | enum CounterAction { increment } 57 | 58 | /// [ActionCreator] 59 | class CounterActionCreator { 60 | static Action increment() { 61 | return const Action(CounterAction.increment, payload: 1); 62 | } 63 | } 64 | 65 | /// [Reducer] 66 | buildReducer() { 67 | return asReducer(>{ 68 | CounterAction.increment: _increment, 69 | }); 70 | } 71 | 72 | PageState _increment(PageState state, Action action) { 73 | final int num = action.payload; 74 | return state.clone()..count = (state.count + num); 75 | } 76 | 77 | /// [Page] 78 | class CountPage extends Page> { 79 | CountPage() 80 | : super( 81 | initState: initState, 82 | reducer: buildReducer(), 83 | view: (PageState state, Dispatch dispatch, ComponentContext ctx) { 84 | return Scaffold( 85 | body: Center( 86 | child: Column( 87 | mainAxisAlignment: MainAxisAlignment.center, 88 | children: [ 89 | const Text( 90 | 'You have pushed the button this many times:', 91 | ), 92 | Text(state.count.toString()), 93 | ], 94 | ), 95 | ), 96 | floatingActionButton: FloatingActionButton( 97 | onPressed: () => dispatch(CounterActionCreator.increment()), 98 | tooltip: 'Increment', 99 | child: const Icon(Icons.add), 100 | ), // This trailing comma makes auto-formatting nicer for build methods. 101 | ); 102 | }); 103 | } 104 | ``` 105 | 106 | ## 示例 107 | 108 | 如果你需要一个完整的使用例子,请参考 `/example` 文件夹中的 todo-list 示例。 109 | 110 | - [todo list](example) - 一个简单的待办列表示例 111 | - 在命令行中运行: 112 | 113 | ``` dart 114 | cd ./example 115 | flutter run 116 | ``` 117 | 118 | ## 模板插件 119 | 120 | - [Flying Redux Template For VSCode](https://github.com/GavinHome/flying-redux-template-for-vscode). 121 | - [Flying Redux Template For AndroidStudio](https://github.com/GavinHome/flying-redux-template-for-as). 122 | 123 | ## 其他 124 | 125 | 实际上,flying-redux的源码在命名和实现上与fish-redux基本类似,但是[fish-redux](https://github.com/alibaba/fish-redux) 126 | 太长时间不更新了,所以我基于它做了大量重构和修改,精简了很多概念,最后重新命名了它。假如你有任何问题,可以扫描下面qq二维码进去群中一起讨论。 127 | 128 |

qq

129 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 17 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 18 | - platform: android 19 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 20 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 21 | - platform: ios 22 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 23 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 24 | - platform: linux 25 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 26 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 27 | - platform: macos 28 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 29 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 30 | - platform: web 31 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 32 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 33 | - platform: windows 34 | create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 35 | base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # sample 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | 31 | analyzer: 32 | errors: 33 | unnecessary_null_comparison: ignore 34 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | namespace "com.example.sample" 30 | compileSdkVersion flutter.compileSdkVersion 31 | ndkVersion flutter.ndkVersion 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | kotlinOptions { 39 | jvmTarget = '1.8' 40 | } 41 | 42 | sourceSets { 43 | main.java.srcDirs += 'src/main/kotlin' 44 | } 45 | 46 | defaultConfig { 47 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 48 | applicationId "com.example.sample" 49 | // You can update the following values to match your application needs. 50 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 51 | minSdkVersion flutter.minSdkVersion 52 | targetSdkVersion flutter.targetSdkVersion 53 | versionCode flutterVersionCode.toInteger() 54 | versionName flutterVersionName 55 | } 56 | 57 | buildTypes { 58 | release { 59 | // TODO: Add your own signing config for the release build. 60 | // Signing with the debug keys for now, so `flutter run --release` works. 61 | signingConfig signingConfigs.debug 62 | } 63 | } 64 | } 65 | 66 | flutter { 67 | source '../..' 68 | } 69 | 70 | dependencies { 71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 72 | } 73 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 14 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.sample 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.3.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Sample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | sample 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'routes.dart'; 3 | 4 | Widget createApp() { 5 | return const _App(); 6 | } 7 | 8 | class _App extends StatelessWidget { 9 | const _App(); 10 | 11 | // This widget is the root of your application. 12 | @override 13 | Widget build(BuildContext context) { 14 | return MaterialApp( 15 | title: 'Flying Redux Demo', 16 | theme: ThemeData( 17 | colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), 18 | useMaterial3: true, 19 | ), 20 | home: routes.home, 21 | onGenerateRoute: (RouteSettings settings) { 22 | return MaterialPageRoute( 23 | builder: (BuildContext context) => 24 | routes.buildPage(settings.name, settings.arguments)); 25 | }, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'app.dart'; 4 | 5 | void main() { 6 | runApp(createApp()); 7 | } 8 | -------------------------------------------------------------------------------- /example/lib/pages/count/action.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | enum CounterAction { increment } 4 | 5 | class CounterActionCreator { 6 | static Action increment() { 7 | return const Action(CounterAction.increment, payload: 1); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/pages/count/page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Page, Action; 3 | import 'action.dart'; 4 | import 'reducer.dart'; 5 | import 'state.dart'; 6 | 7 | class CountPage extends Page> { 8 | CountPage() 9 | : super( 10 | initState: initState, 11 | reducer: buildReducer(), 12 | middleware: >[ 13 | logMiddleware( 14 | tag: 'CounterPage', 15 | monitor: (PageState? state) { 16 | return state == null ? '' : state.toString(); 17 | }) 18 | ], 19 | view: (PageState state, Dispatch dispatch, ComponentContext ctx) { 20 | return Scaffold( 21 | body: Center( 22 | child: Column( 23 | mainAxisAlignment: MainAxisAlignment.center, 24 | children: [ 25 | const Text( 26 | 'You have pushed the button this many times:', 27 | ), 28 | Text(state.count.toString()), 29 | ], 30 | ), 31 | ), 32 | floatingActionButton: FloatingActionButton( 33 | onPressed: () => dispatch(CounterActionCreator.increment()), 34 | tooltip: 'Increment', 35 | child: const Icon(Icons.add), 36 | ), // This trailing comma makes auto-formatting nicer for build methods. 37 | ); 38 | }); 39 | } 40 | -------------------------------------------------------------------------------- /example/lib/pages/count/reducer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | import 'action.dart'; 4 | import 'state.dart'; 5 | 6 | buildReducer() { 7 | return asReducer(>{ 8 | CounterAction.increment: _increment, 9 | }); 10 | } 11 | 12 | PageState _increment(PageState state, Action action) { 13 | final int num = action.payload; 14 | return state.clone()..count = (state.count + num); 15 | } 16 | -------------------------------------------------------------------------------- /example/lib/pages/count/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | class PageState extends Cloneable { 4 | late int count; 5 | 6 | @override 7 | PageState clone() { 8 | return PageState()..count = count; 9 | } 10 | 11 | @override 12 | String toString() { 13 | return 'count: ${count.toString()}'; 14 | } 15 | } 16 | 17 | PageState initState(Map? args) { 18 | //just do something here... 19 | return PageState()..count = 99; 20 | } 21 | -------------------------------------------------------------------------------- /example/lib/pages/todos/edit/action.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | enum ToDoEditAction { onDone, onChangeTheme } 4 | 5 | class ToDoEditActionCreator { 6 | static Action onDone() { 7 | return const Action(ToDoEditAction.onDone); 8 | } 9 | 10 | static Action onChangeTheme() { 11 | return const Action(ToDoEditAction.onChangeTheme); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/lib/pages/todos/edit/effect.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page; 3 | 4 | import '../todo/state.dart'; 5 | import 'action.dart'; 6 | import 'state.dart'; 7 | 8 | buildEffect() { 9 | return combineEffects(>{ 10 | ToDoEditAction.onDone: _onDone, 11 | }); 12 | } 13 | 14 | void _onDone(Action action, ComponentContext ctx) { 15 | Navigator.of(ctx.context).pop( 16 | ctx.state.toDo.clone() 17 | ..desc = ctx.state.descEditController.text 18 | ..title = ctx.state.nameEditController.text, 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /example/lib/pages/todos/edit/page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page; 3 | 4 | import '../todo/state.dart'; 5 | import 'action.dart'; 6 | import 'effect.dart'; 7 | import 'state.dart'; 8 | 9 | class TodoEditPage extends Page { 10 | TodoEditPage() 11 | : super( 12 | initState: initState, 13 | effect: buildEffect(), 14 | view: buildView, 15 | 16 | /// AOP 17 | middleware: >[ 18 | logMiddleware(tag: 'TodoEditPage'), 19 | ], 20 | ); 21 | } 22 | 23 | Widget buildView(TodoEditState state, Dispatch dispatch, 24 | ComponentContext context) { 25 | return Scaffold( 26 | appBar: AppBar( 27 | title: const Text('Todo'), 28 | ), 29 | body: Container( 30 | padding: const EdgeInsets.all(16.0), 31 | child: Column( 32 | children: [ 33 | Row( 34 | children: [ 35 | Container( 36 | width: 56.0, 37 | alignment: AlignmentDirectional.topEnd, 38 | child: const Text('title:', 39 | style: TextStyle(color: Colors.black, fontSize: 20.0)), 40 | ), 41 | Expanded( 42 | child: Container( 43 | color: const Color(0xFFE0E0E0), 44 | padding: const EdgeInsets.all(8.0), 45 | margin: const EdgeInsets.only(left: 8.0), 46 | child: EditableText( 47 | controller: state.nameEditController, 48 | focusNode: state.focusNodeName, 49 | autofocus: true, 50 | style: const TextStyle(color: Colors.black, fontSize: 16.0), 51 | cursorColor: Colors.yellow, 52 | backgroundCursorColor: const Color(0xFFFFF59D), 53 | ), 54 | )) 55 | ], 56 | ), 57 | // ElevatedButton( 58 | // style: ElevatedButton.styleFrom( 59 | // padding: const EdgeInsets.only( left: 20.0, top: 10.0, right: 20.0, bottom: 10.0), 60 | // foregroundColor: Colors.blue 61 | // ), 62 | // child: const Text('Change theme', 63 | // style: TextStyle(fontSize: 18), 64 | // overflow: TextOverflow.ellipsis), 65 | // onPressed: () { 66 | // dispatch(ToDoEditActionCreator.onChangeTheme()); 67 | // }), 68 | Expanded( 69 | child: Container( 70 | margin: const EdgeInsets.only(top: 32.0), 71 | alignment: AlignmentDirectional.topStart, 72 | child: Row( 73 | crossAxisAlignment: CrossAxisAlignment.start, 74 | children: [ 75 | Container( 76 | width: 56.0, 77 | alignment: AlignmentDirectional.topEnd, 78 | child: const Text('desc:', 79 | style: TextStyle(color: Colors.black, fontSize: 20.0)), 80 | ), 81 | Expanded( 82 | child: Container( 83 | color: const Color(0xFFE0E0E0), 84 | padding: const EdgeInsets.all(8.0), 85 | margin: const EdgeInsets.only(left: 8.0), 86 | child: EditableText( 87 | controller: state.descEditController, 88 | backgroundCursorColor: const Color(0xFFE0E0E0), 89 | maxLines: 10, 90 | focusNode: state.focusNodeDesc, 91 | style: 92 | const TextStyle(color: Colors.black, fontSize: 16.0), 93 | cursorColor: Colors.yellow), 94 | )) 95 | ], 96 | ), 97 | )) 98 | ], 99 | ), 100 | ), 101 | floatingActionButton: FloatingActionButton( 102 | onPressed: () => dispatch(ToDoEditActionCreator.onDone()), 103 | tooltip: 'Done', 104 | child: const Icon(Icons.done), 105 | ), 106 | floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, 107 | ); 108 | } 109 | -------------------------------------------------------------------------------- /example/lib/pages/todos/edit/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page; 3 | 4 | import '../todo/state.dart'; 5 | 6 | class TodoEditState implements Cloneable { 7 | late ToDoState toDo; 8 | 9 | late TextEditingController nameEditController; 10 | late TextEditingController descEditController; 11 | 12 | late FocusNode focusNodeName; 13 | late FocusNode focusNodeDesc; 14 | 15 | @override 16 | TodoEditState clone() { 17 | return TodoEditState() 18 | ..nameEditController = nameEditController 19 | ..descEditController = descEditController 20 | ..focusNodeName = focusNodeName 21 | ..focusNodeDesc = focusNodeDesc 22 | ..toDo = toDo; 23 | } 24 | } 25 | 26 | TodoEditState initState(ToDoState? arg) { 27 | final TodoEditState state = TodoEditState(); 28 | state.toDo = arg?.clone() ?? ToDoState(); 29 | state.nameEditController = TextEditingController(text: arg?.title); 30 | state.descEditController = TextEditingController(text: arg?.desc); 31 | state.focusNodeName = FocusNode(); 32 | state.focusNodeDesc = FocusNode(); 33 | 34 | return state; 35 | } 36 | -------------------------------------------------------------------------------- /example/lib/pages/todos/page/adapter.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'state.dart'; 3 | import '../report/state.dart'; 4 | import '../todo/component.dart'; 5 | import '../todo/state.dart'; 6 | import '../todo/action.dart'; 7 | 8 | // Dependents dependentBuilder(PageState state) => state.toDos 9 | // .asMap() 10 | // .keys 11 | // .map((index) => 12 | // TodoConnector(toDos: state.toDos, index: index) + TodoComponent()) 13 | // .toList(); 14 | 15 | // class PageAdapter extends BasicAdapter { 16 | // PageAdapter() : super( 17 | // builder: dependentBuilder 18 | // ); 19 | // } 20 | 21 | BasicAdapter get adapter => BasicAdapter( 22 | builder: (PageState state) => state.toDos 23 | .asMap() 24 | .keys 25 | .map((index) => 26 | TodoConnector(toDos: state.toDos, index: index) + TodoComponent()) 27 | .toList()); 28 | 29 | class TodoConnector extends ConnOp { 30 | TodoConnector({required this.toDos, required this.index}) : super(); 31 | 32 | final List toDos; 33 | final int index; 34 | 35 | @override 36 | ToDoState get(PageState state) { 37 | return toDos[index]; 38 | } 39 | 40 | @override 41 | void set(PageState state, ToDoState subState) { 42 | state.toDos[index] = subState; 43 | } 44 | 45 | @override 46 | bool shouldReducer(PageState state, Action action) { 47 | if (action.type is ToDoAction) { 48 | if (action.payload is ToDoState) { 49 | ToDoState? todo = action.payload; 50 | var eq = get(state).uniqueId == todo?.uniqueId; 51 | return eq; 52 | } else if (action.payload is String) { 53 | var eq = get(state).uniqueId == action.payload; 54 | return eq; 55 | } 56 | } 57 | 58 | return false; 59 | } 60 | } 61 | 62 | class ReportConnector extends ConnOp { 63 | @override 64 | ReportState get(PageState state) { 65 | return ReportState() 66 | ..total = state.toDos.length 67 | ..done = state.toDos.where((e) => e.isDone).length; 68 | } 69 | 70 | @override 71 | void set(PageState state, ReportState subState) {} 72 | } 73 | -------------------------------------------------------------------------------- /example/lib/pages/todos/page/page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Page, Action; 3 | import '../todo/action.dart'; 4 | import '../report/component.dart'; 5 | // import '../todo/component.dart'; 6 | import '../todo/state.dart'; 7 | import 'adapter.dart'; 8 | import 'state.dart'; 9 | 10 | class ToDoListPage extends Page> { 11 | ToDoListPage() 12 | : super( 13 | initState: initState, 14 | reducer: asReducer( 15 | >{ 16 | 'initToDos': _init, 17 | 'add': _add, 18 | ToDoAction.remove: _remove 19 | }, 20 | ), 21 | middleware: >[ 22 | logMiddleware( 23 | tag: 'ToDoListPage', 24 | monitor: (PageState? state) { 25 | return state == null ? '' : state.toString(); 26 | }) 27 | ], 28 | effect: combineEffects(>{ 29 | Lifecycle.initState: _onInit, 30 | 'onAdd': _onAdd 31 | }), 32 | dependencies: Dependencies( 33 | // adapter: const NoneConn() + 34 | // BasicAdapter( 35 | // builder: (PageState state) => state.toDos 36 | // .asMap() 37 | // .keys 38 | // .map((index) => 39 | // TodoConnector(toDos: state.toDos, index: index) + 40 | // TodoComponent()) 41 | // .toList()), 42 | 43 | // adapter: const NoneConn() + 44 | // BasicAdapter(builder: dependentBuilder), 45 | // adapter: const NoneConn() + PageAdapter(), 46 | 47 | adapter: const NoneConn() + adapter, 48 | slots: >{ 49 | 'report': ReportConnector() + ReportComponent(), 50 | }, 51 | ), 52 | view: (PageState state, Dispatch dispatch, 53 | ComponentContext ctx) { 54 | final List ws = ctx.buildComponents(); 55 | return Scaffold( 56 | body: Stack(children: [ 57 | ListView.builder( 58 | itemBuilder: (BuildContext context, int index) => ws[index], 59 | itemCount: ws.length, 60 | ), 61 | Positioned( 62 | bottom: 0, 63 | left: 0, 64 | right: 0, 65 | child: ctx.buildComponent('report'), 66 | ) 67 | ]), 68 | floatingActionButton: FloatingActionButton( 69 | onPressed: () => dispatch(const Action("onAdd")), 70 | tooltip: 'Increment', 71 | child: const Icon(Icons.add), 72 | ), 73 | ); 74 | }, 75 | ); 76 | } 77 | 78 | /// effects 79 | void _onInit(Action action, ComponentContext ctx) { 80 | final List initToDos = [ 81 | ToDoState( 82 | uniqueId: '0', 83 | title: 'Hello world', 84 | desc: 'Learn how to program.', 85 | isDone: true, 86 | ), 87 | ToDoState( 88 | uniqueId: '1', 89 | title: 'Hello Flutter', 90 | desc: 'Learn how to build a flutter application.', 91 | isDone: true, 92 | ), 93 | ToDoState( 94 | uniqueId: '2', 95 | title: 'How Flying Redux', 96 | desc: 'Learn how to use Flying Redux in a flutter application.', 97 | isDone: false, 98 | ) 99 | ]; 100 | 101 | ctx.dispatch(Action('initToDos', payload: initToDos)); 102 | } 103 | 104 | void _onAdd(Action action, ComponentContext ctx) { 105 | Navigator.of(ctx.context) 106 | .pushNamed('todo_edit', arguments: null) 107 | .then((dynamic toDo) { 108 | if (toDo != null && 109 | (toDo.title?.isNotEmpty == true || toDo.desc?.isNotEmpty == true)) { 110 | ctx.dispatch(Action('add', payload: toDo)); 111 | } 112 | }); 113 | } 114 | 115 | /// reducers 116 | PageState _init(PageState state, Action action) { 117 | final List toDos = action.payload ?? []; 118 | final PageState newState = state.clone(); 119 | newState.toDos = toDos; 120 | return newState; 121 | } 122 | 123 | PageState _add(PageState state, Action action) { 124 | final ToDoState? toDo = action.payload; 125 | final PageState newState = state.clone(); 126 | if (toDo != null) { 127 | newState.toDos.add(toDo); 128 | } 129 | 130 | return newState; 131 | } 132 | 133 | PageState _remove(PageState state, Action action) { 134 | final String unique = action.payload; 135 | return state.clone() 136 | ..toDos = (state.toDos.toList() 137 | ..removeWhere((ToDoState state) => state.uniqueId == unique)); 138 | } 139 | -------------------------------------------------------------------------------- /example/lib/pages/todos/page/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | import '../todo/state.dart'; 4 | 5 | class PageState implements Cloneable { 6 | late List toDos = []; 7 | 8 | @override 9 | PageState clone() { 10 | return PageState()..toDos = toDos; 11 | } 12 | 13 | @override 14 | String toString() { 15 | return 'toDos${toDos.toString()}'; 16 | } 17 | } 18 | 19 | PageState initState(Map? args) { 20 | //just demo, do something here... 21 | return PageState()..toDos = []; 22 | } 23 | -------------------------------------------------------------------------------- /example/lib/pages/todos/report/component.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'state.dart'; 4 | 5 | class ReportComponent extends Component { 6 | ReportComponent() 7 | : super( 8 | view: (ReportState state, Dispatch dispatch, 9 | ComponentContext ctx) { 10 | return Container( 11 | margin: const EdgeInsets.all(8.0), 12 | padding: const EdgeInsets.all(8.0), 13 | color: Colors.blue, 14 | child: Row( 15 | children: [ 16 | Container( 17 | margin: const EdgeInsets.only(right: 8.0), 18 | child: const Icon(Icons.report), 19 | ), 20 | Text( 21 | 'Total ${state.total} tasks, ${state.done} done.', 22 | style: 23 | const TextStyle(fontSize: 18.0, color: Colors.white), 24 | ) 25 | ], 26 | )); 27 | }, 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /example/lib/pages/todos/report/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | class ReportState implements Cloneable { 4 | int total; 5 | int done; 6 | 7 | ReportState({this.total = 0, this.done = 0}); 8 | 9 | @override 10 | ReportState clone() { 11 | return ReportState() 12 | ..total = total 13 | ..done = done; 14 | } 15 | 16 | @override 17 | String toString() { 18 | return 'ReportState{total: $total, done: $done}'; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/lib/pages/todos/todo/action.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'state.dart'; 3 | 4 | enum ToDoAction { onEdit, edit, done, onRemove, remove } 5 | 6 | class ToDoActionCreator { 7 | static Action onEditAction(String uniqueId) { 8 | return Action(ToDoAction.onEdit, payload: uniqueId); 9 | } 10 | 11 | static Action editAction(ToDoState toDo) { 12 | return Action(ToDoAction.edit, payload: toDo); 13 | } 14 | 15 | static Action doneAction(String uniqueId) { 16 | return Action(ToDoAction.done, payload: uniqueId); 17 | } 18 | 19 | static Action onRemoveAction(String uniqueId) { 20 | return Action(ToDoAction.onRemove, payload: uniqueId); 21 | } 22 | 23 | static Action removeAction(String uniqueId) { 24 | return Action(ToDoAction.remove, payload: uniqueId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /example/lib/pages/todos/todo/component.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action; 3 | import 'effect.dart'; 4 | import 'action.dart'; 5 | import 'reducer.dart'; 6 | import 'state.dart'; 7 | 8 | class TodoComponent extends Component { 9 | TodoComponent() 10 | : super( 11 | reducer: buildReducer(), 12 | effect: buildEffect(), 13 | view: (ToDoState state, Dispatch dispatch, 14 | ComponentContext ctx) { 15 | return Container( 16 | padding: const EdgeInsets.all(8.0), 17 | child: GestureDetector( 18 | child: Column( 19 | children: [ 20 | GestureDetector( 21 | child: Container( 22 | height: 36.0, 23 | color: state.isDone ? Colors.green : Colors.red, 24 | alignment: AlignmentDirectional.centerStart, 25 | child: Row( 26 | children: [ 27 | Container( 28 | margin: const EdgeInsets.all(8.0), 29 | child: const Icon(Icons.label_outline), 30 | ), 31 | Expanded( 32 | child: Text( 33 | state.title ?? '', 34 | maxLines: 1, 35 | style: const TextStyle( 36 | color: Colors.white, fontSize: 18.0), 37 | )), 38 | GestureDetector( 39 | child: Container( 40 | margin: const EdgeInsets.only(right: 16.0), 41 | child: (() => state.isDone 42 | ? const Icon(Icons.check_box) 43 | : const Icon( 44 | Icons.check_box_outline_blank))(), 45 | ), 46 | onTap: () { 47 | dispatch(ToDoActionCreator.doneAction( 48 | state.uniqueId)); 49 | }, 50 | ) 51 | ], 52 | ), 53 | ), 54 | ), 55 | Container( 56 | padding: 57 | const EdgeInsets.fromLTRB(16.0, 24.0, 16.0, 24.0), 58 | color: const Color(0xFFE0E0E0), 59 | child: Row( 60 | children: [ 61 | Expanded( 62 | child: Text( 63 | state.desc ?? '', 64 | style: const TextStyle( 65 | color: Colors.black, fontSize: 16.0), 66 | )), 67 | GestureDetector( 68 | child: const Icon(Icons.edit), 69 | onTap: () { 70 | dispatch(ToDoActionCreator.onEditAction( 71 | state.uniqueId)); 72 | }, 73 | ) 74 | ], 75 | ), 76 | ) 77 | ], 78 | ), 79 | onLongPress: () { 80 | dispatch(ToDoActionCreator.onRemoveAction(state.uniqueId)); 81 | }, 82 | ), 83 | ); 84 | }, 85 | ); 86 | } 87 | -------------------------------------------------------------------------------- /example/lib/pages/todos/todo/effect.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart' hide Action, Page; 2 | import 'package:flying_redux/flying_redux.dart'; 3 | 4 | import 'action.dart'; 5 | import 'state.dart'; 6 | 7 | buildEffect() { 8 | return combineEffects(>{ 9 | ToDoAction.onEdit: _onEdit, 10 | ToDoAction.onRemove: _onRemove, 11 | }); 12 | } 13 | 14 | void _onEdit(Action action, ComponentContext ctx) { 15 | if (action.payload == ctx.state.uniqueId) { 16 | Navigator.of(ctx.context) 17 | // .push(MaterialPageRoute( 18 | // builder: (BuildContext buildCtx) => 19 | // edit_page.TodoEditPage().buildPage(ctx.state))) 20 | .pushNamed('todo_edit', arguments: ctx.state) 21 | .then((dynamic toDo) { 22 | if (toDo != null) { 23 | ctx.dispatch(ToDoActionCreator.editAction(toDo)); 24 | } 25 | }); 26 | } 27 | } 28 | 29 | void _onRemove(Action action, ComponentContext ctx) async { 30 | if (action.payload == ctx.state.uniqueId) { 31 | final String? select = await showDialog( 32 | context: ctx.context, 33 | builder: (BuildContext buildContext) { 34 | return AlertDialog( 35 | title: Text('Are you sure to delete "${ctx.state.title}"?'), 36 | actions: [ 37 | GestureDetector( 38 | child: const Text( 39 | 'Cancel', 40 | style: TextStyle(fontSize: 16.0), 41 | ), 42 | onTap: () => Navigator.of(buildContext).pop(), 43 | ), 44 | GestureDetector( 45 | child: const Text('Yes', style: TextStyle(fontSize: 16.0)), 46 | onTap: () => Navigator.of(buildContext).pop('Yes'), 47 | ) 48 | ], 49 | ); 50 | }); 51 | 52 | if (select == 'Yes') { 53 | ctx.dispatch(ToDoActionCreator.removeAction(ctx.state.uniqueId)); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /example/lib/pages/todos/todo/reducer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'action.dart'; 3 | import 'state.dart'; 4 | 5 | buildReducer() { 6 | return asReducer(>{ 7 | ToDoAction.edit: _edit, 8 | ToDoAction.done: _markDone, 9 | }); 10 | } 11 | 12 | ToDoState _edit(ToDoState state, Action action) { 13 | final ToDoState toDo = action.payload; 14 | if (state.uniqueId == toDo.uniqueId) { 15 | return state.clone() 16 | ..title = toDo.title 17 | ..desc = toDo.desc; 18 | } 19 | return state; 20 | } 21 | 22 | ToDoState _markDone(ToDoState state, Action action) { 23 | final String uniqueId = action.payload; 24 | if (state.uniqueId == uniqueId) { 25 | return state.clone()..isDone = !state.isDone; 26 | } 27 | return state; 28 | } 29 | -------------------------------------------------------------------------------- /example/lib/pages/todos/todo/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | class ToDoState implements Cloneable { 4 | String uniqueId; 5 | String? title; 6 | String? desc; 7 | bool isDone; 8 | 9 | static int _seed = 202103051044; 10 | 11 | ToDoState({this.uniqueId = '', this.title, this.desc, this.isDone = false}) { 12 | uniqueId = uniqueId.isEmpty ? '${_seed++}' : uniqueId; 13 | } 14 | 15 | @override 16 | ToDoState clone() { 17 | return ToDoState() 18 | ..uniqueId = uniqueId 19 | ..title = title 20 | ..desc = desc 21 | ..isDone = isDone; 22 | } 23 | 24 | @override 25 | String toString() { 26 | return 'ToDoState{uniqueId: $uniqueId, title: $title, desc: $desc, isDone: $isDone}'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example/lib/routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | import 'pages/count/page.dart'; 4 | import 'pages/todos/edit/page.dart'; 5 | import 'pages/todos/page/page.dart'; 6 | 7 | final AbstractRoutes routes = PageRoutes( 8 | initialRoute: 'todo_list', 9 | pages: >{ 10 | /// Register TodoList main page 11 | 'todo_list': ToDoListPage(), 12 | 13 | /// Register Todo edit page 14 | 'todo_edit': TodoEditPage(), 15 | 16 | /// Register Count page 17 | 'count': CountPage(), 18 | }); 19 | -------------------------------------------------------------------------------- /example/lib/sample.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | Widget createApp() { 4 | return const MyApp(); 5 | } 6 | 7 | class MyApp extends StatelessWidget { 8 | const MyApp({super.key}); 9 | 10 | // This widget is the root of your application. 11 | @override 12 | Widget build(BuildContext context) { 13 | return MaterialApp( 14 | title: 'Flutter Demo', 15 | theme: ThemeData( 16 | // This is the theme of your application. 17 | // 18 | // TRY THIS: Try running your application with "flutter run". You'll see 19 | // the application has a blue toolbar. Then, without quitting the app, 20 | // try changing the seedColor in the colorScheme below to Colors.green 21 | // and then invoke "hot reload" (save your changes or press the "hot 22 | // reload" button in a Flutter-supported IDE, or press "r" if you used 23 | // the command line to start the app). 24 | // 25 | // Notice that the counter didn't reset back to zero; the application 26 | // state is not lost during the reload. To reset the state, use hot 27 | // restart instead. 28 | // 29 | // This works for code too, not just values: Most code changes can be 30 | // tested with just a hot reload. 31 | colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), 32 | useMaterial3: true, 33 | ), 34 | home: const MyHomePage(title: 'Flutter Demo Home Page'), 35 | ); 36 | } 37 | } 38 | 39 | class MyHomePage extends StatefulWidget { 40 | const MyHomePage({super.key, required this.title}); 41 | 42 | // This widget is the home page of your application. It is stateful, meaning 43 | // that it has a State object (defined below) that contains fields that affect 44 | // how it looks. 45 | 46 | // This class is the configuration for the state. It holds the values (in this 47 | // case the title) provided by the parent (in this case the App widget) and 48 | // used by the build method of the State. Fields in a Widget subclass are 49 | // always marked "final". 50 | 51 | final String title; 52 | 53 | @override 54 | State createState() => _MyHomePageState(); 55 | } 56 | 57 | class _MyHomePageState extends State { 58 | int _counter = 0; 59 | 60 | void _incrementCounter() { 61 | setState(() { 62 | // This call to setState tells the Flutter framework that something has 63 | // changed in this State, which causes it to rerun the build method below 64 | // so that the display can reflect the updated values. If we changed 65 | // _counter without calling setState(), then the build method would not be 66 | // called again, and so nothing would appear to happen. 67 | _counter++; 68 | }); 69 | } 70 | 71 | @override 72 | Widget build(BuildContext context) { 73 | // This method is rerun every time setState is called, for instance as done 74 | // by the _incrementCounter method above. 75 | // 76 | // The Flutter framework has been optimized to make rerunning build methods 77 | // fast, so that you can just rebuild anything that needs updating rather 78 | // than having to individually change instances of widgets. 79 | return Scaffold( 80 | appBar: AppBar( 81 | // TRY THIS: Try changing the color here to a specific color (to 82 | // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar 83 | // change color while the other colors stay the same. 84 | backgroundColor: Theme.of(context).colorScheme.inversePrimary, 85 | // Here we take the value from the MyHomePage object that was created by 86 | // the App.build method, and use it to set our appbar title. 87 | title: Text(widget.title), 88 | ), 89 | body: Center( 90 | // Center is a layout widget. It takes a single child and positions it 91 | // in the middle of the parent. 92 | child: Column( 93 | // Column is also a layout widget. It takes a list of children and 94 | // arranges them vertically. By default, it sizes itself to fit its 95 | // children horizontally, and tries to be as tall as its parent. 96 | // 97 | // Column has various properties to control how it sizes itself and 98 | // how it positions its children. Here we use mainAxisAlignment to 99 | // center the children vertically; the main axis here is the vertical 100 | // axis because Columns are vertical (the cross axis would be 101 | // horizontal). 102 | // 103 | // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" 104 | // action in the IDE, or press "p" in the console), to see the 105 | // wireframe for each widget. 106 | mainAxisAlignment: MainAxisAlignment.center, 107 | children: [ 108 | const Text( 109 | 'You have pushed the button this many times:', 110 | ), 111 | Text( 112 | '$_counter', 113 | style: Theme.of(context).textTheme.headlineMedium, 114 | ), 115 | ], 116 | ), 117 | ), 118 | floatingActionButton: FloatingActionButton( 119 | onPressed: _incrementCounter, 120 | tooltip: 'Increment', 121 | child: const Icon(Icons.add), 122 | ), // This trailing comma makes auto-formatting nicer for build methods. 123 | ); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies.dart. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "sample"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "sample"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /example/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | 9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 10 | } 11 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = sample 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.sample 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: sample 2 | description: A new Flutter project. 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: '>=2.17.0 <4.0.0' 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies.dart to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies.dart can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies.dart have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flying_redux: 32 | path: ../ 33 | flutter: 34 | sdk: flutter 35 | 36 | 37 | # The following adds the Cupertino Icons font to your application. 38 | # Use with the CupertinoIcons class for iOS style icons. 39 | cupertino_icons: ^1.0.2 40 | 41 | dev_dependencies: 42 | flutter_test: 43 | sdk: flutter 44 | 45 | # The "flutter_lints" package below contains a set of recommended lints to 46 | # encourage good coding practices. The lint set provided by the package is 47 | # activated in the `analysis_options.yaml` file located at the root of your 48 | # package. See that file for information about deactivating specific lint 49 | # rules and activating additional ones. 50 | flutter_lints: ^2.0.0 51 | 52 | # For information on the generic Dart part of this file, see the 53 | # following page: https://dart.dev/tools/pub/pubspec 54 | 55 | # The following section is specific to Flutter packages. 56 | flutter: 57 | 58 | # The following line ensures that the Material Icons font is 59 | # included with your application, so that you can use the icons in 60 | # the material Icons class. 61 | uses-material-design: true 62 | 63 | # To add assets to your application, add an assets section, like this: 64 | # assets: 65 | # - images/a_dot_burr.jpeg 66 | # - images/a_dot_ham.jpeg 67 | 68 | # An image asset can refer to one or more resolution-specific "variants", see 69 | # https://flutter.dev/assets-and-images/#resolution-aware 70 | 71 | # For details regarding adding assets from package dependencies.dart, see 72 | # https://flutter.dev/assets-and-images/#from-packages 73 | 74 | # To add custom fonts to your application, add a fonts section here, 75 | # in this "flutter" section. Each entry in this list should have a 76 | # "family" key with the font family name, and a "fonts" key with a 77 | # list giving the asset and other descriptors for the font. For 78 | # example: 79 | # fonts: 80 | # - family: Schyler 81 | # fonts: 82 | # - asset: fonts/Schyler-Regular.ttf 83 | # - asset: fonts/Schyler-Italic.ttf 84 | # style: italic 85 | # - family: Trajan Pro 86 | # fonts: 87 | # - asset: fonts/TrajanPro.ttf 88 | # - asset: fonts/TrajanPro_Bold.ttf 89 | # weight: 700 90 | # 91 | # For details regarding fonts from package dependencies.dart, 92 | # see https://flutter.dev/custom-fonts/#from-packages 93 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | import 'package:sample/sample.dart'; 11 | 12 | void main() { 13 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 14 | // Build our app and trigger a frame. 15 | await tester.pumpWidget(const MyApp()); 16 | 17 | // Verify that our counter starts at 0. 18 | expect(find.text('0'), findsOneWidget); 19 | expect(find.text('1'), findsNothing); 20 | 21 | // Tap the '+' icon and trigger a frame. 22 | await tester.tap(find.byIcon(Icons.add)); 23 | await tester.pump(); 24 | 25 | // Verify that our counter has incremented. 26 | expect(find.text('0'), findsNothing); 27 | expect(find.text('1'), findsOneWidget); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | sample 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample", 3 | "short_name": "sample", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(sample LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "sample") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Fully re-copy the assets directory on each build to avoid having stale files 91 | # from a previous install. 92 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 93 | install(CODE " 94 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 95 | " COMPONENT Runtime) 96 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 97 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 98 | 99 | # Install the AOT library on non-Debug builds only. 100 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 101 | CONFIGURATIONS Profile;Release 102 | COMPONENT Runtime) 103 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void RegisterPlugins(flutter::PluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies.dart here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "sample" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "sample" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "sample.exe" "\0" 98 | VALUE "ProductName", "sample" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"sample", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /flying-redux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/flying-redux.png -------------------------------------------------------------------------------- /lib/flying_redux.dart: -------------------------------------------------------------------------------- 1 | library flying_redux; 2 | 3 | export 'src/redux/index.dart'; 4 | export 'src/component/index.dart'; 5 | -------------------------------------------------------------------------------- /lib/src/_readme.dart: -------------------------------------------------------------------------------- 1 | /// 1.简单使用Redux概念 2 | /// [Store] 3 | /// [getState] page state tree 4 | /// [dispatch] 5 | /// [subscribe] 6 | /// [Reducer] 7 | /// [Effect] 8 | /// [Reducer] 9 | /// [Middleware] 10 | /// 11 | /// [组件间的通讯] 12 | /// 1. 数据状态通信 13 | /// 同一个[Store]下的[组件]|[组件组], 持有并订阅了同一个[Store], 使得数据流转变得非常天然. 14 | /// 15 | /// 2. 副作用通信 16 | /// 同一个[Store]下的[组件]|[组件组]之间的存在[Effect]事件总线. 17 | /// 18 | /// 备注: 设计不具备跨[Store]之间[组件]的通信能力. 19 | ///} 20 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 21 | /// 组件层 22 | /// [Page]: 基于Component封装的Page层,页面级别 23 | /// 24 | /// [BasicComponent]: 组件单元模块, 25 | /// [Dependencies]: 组件依赖部分 26 | /// [Effect]: [副作用]部分 27 | /// [Reducer]; [数据状态管理]部分 28 | /// [View]: render 部分处理 29 | /// 30 | /// [Component]: 单组件模式实现,单个RenderWidget绘制处理, [child]模式处理。 31 | /// [Adapter]: 多组件模式实现,虚拟组组件,[children]模式处理。 32 | /// 33 | /// [Dependencies] 34 | /// [Dependent] 35 | /// [Connector] + [Component] 36 | /// 三. [子组件]和[依赖] 37 | /// [子组件] = [连接器] + [组件] 38 | /// [子组件组] = [连接器] + [组件组] 39 | /// [依赖] = [子组件表](插槽) + [子组件组] 40 | /// 41 | /// 1. 依赖的描述性和可编排性. 42 | /// 2. 依赖为[组件上下文]提供了,构建子[Widget]和[Widgets]的能力. 43 | /// 44 | /// [ComponentWidget] 45 | /// [Context] 46 | /// 0. [状态] 获取当前状态的能力 47 | /// 1. [UI] 构建Widget或Widgets的能力 48 | /// 2. [逻辑] 处理自身副作用[Effect]的能力, 及触发[Store]和广播到[EffectBus]的能力 49 | /// 3. [依赖] 通过声明的[依赖], 获得构建子[组件]或子[组件组]的能力 50 | /// 4. [子上下文] 任何的子[组件组]的上下文, 都附着于它的父组件组的上下文上. 51 | -------------------------------------------------------------------------------- /lib/src/component/component.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart' hide ViewBuilder, Action; 2 | 3 | import '../redux/index.dart'; 4 | import 'basic.dart'; 5 | 6 | /// [Component] 7 | /// Implementation of Component 8 | class Component extends BasicComponent { 9 | Component({ 10 | Effect? effect, 11 | Reducer? reducer, 12 | Dependencies? dependencies, 13 | required ViewBuilder view, 14 | ShouldUpdate? shouldUpdate, 15 | }) : super( 16 | dependencies: dependencies, 17 | reducer: reducer ?? (T state, Action _) => state, 18 | effect: effect, 19 | view: view, 20 | shouldUpdate: shouldUpdate, 21 | ); 22 | 23 | @override 24 | Widget buildComponent( 25 | Store store, 26 | Get getter, { 27 | DispatchBus? dispatchBus, 28 | }) { 29 | return _ComponentWidget( 30 | component: this, 31 | store: store, 32 | bus: dispatchBus, 33 | getter: getter, 34 | dependencies: dependencies, 35 | ); 36 | } 37 | 38 | @override 39 | List buildComponents( 40 | Store store, 41 | Get getter, { 42 | DispatchBus? dispatchBus, 43 | }) { 44 | return [ 45 | buildComponent( 46 | store, 47 | getter, 48 | dispatchBus: dispatchBus, 49 | ) 50 | ]; 51 | } 52 | } 53 | 54 | class _ComponentWidget extends StatefulWidget { 55 | final BasicComponent component; 56 | final Store store; 57 | final Get getter; 58 | final DispatchBus? bus; 59 | final Dependencies? dependencies; 60 | 61 | const _ComponentWidget({ 62 | required this.component, 63 | required this.store, 64 | required this.getter, 65 | this.dependencies, 66 | this.bus, 67 | Key? key, 68 | }) : super(key: key); 69 | 70 | @override 71 | _ComponentState createState() => _ComponentState(); 72 | } 73 | 74 | class _ComponentState extends State<_ComponentWidget> { 75 | late ComponentContext _ctx; 76 | BasicComponent get component => widget.component; 77 | late Function() subscribe; 78 | 79 | @override 80 | void initState() { 81 | super.initState(); 82 | _ctx = component.createContext( 83 | widget.store, 84 | widget.getter, 85 | buildContext: context, 86 | bus: widget.bus, 87 | markNeedsBuild: () { 88 | if (mounted) { 89 | setState(() {}); 90 | } 91 | Log.doPrint('${component.runtimeType} do reload'); 92 | }, 93 | ); 94 | _ctx.onLifecycle(LifecycleCreator.initState()); 95 | subscribe = _ctx.store.subscribe(_ctx.onNotify); 96 | } 97 | 98 | @override 99 | Widget build(BuildContext context) => _ctx.buildView(); 100 | 101 | @mustCallSuper 102 | @override 103 | void didChangeDependencies() { 104 | super.didChangeDependencies(); 105 | _ctx.onLifecycle(LifecycleCreator.didChangeDependencies()); 106 | } 107 | 108 | @mustCallSuper 109 | @override 110 | void deactivate() { 111 | super.deactivate(); 112 | _ctx.onLifecycle(LifecycleCreator.deactivate()); 113 | } 114 | 115 | @override 116 | @protected 117 | @mustCallSuper 118 | void reassemble() { 119 | super.reassemble(); 120 | _ctx.clearCache(); 121 | _ctx.onLifecycle(LifecycleCreator.reassemble()); 122 | } 123 | 124 | @mustCallSuper 125 | @override 126 | void didUpdateWidget(_ComponentWidget oldWidget) { 127 | super.didUpdateWidget(oldWidget); 128 | _ctx.didUpdateWidget(); 129 | _ctx.onLifecycle(LifecycleCreator.didUpdateWidget()); 130 | } 131 | 132 | @mustCallSuper 133 | void disposeCtx() { 134 | _ctx 135 | ..onLifecycle(LifecycleCreator.dispose()) 136 | ..dispose(); 137 | } 138 | 139 | @mustCallSuper 140 | @override 141 | void dispose() { 142 | disposeCtx(); 143 | subscribe(); 144 | super.dispose(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /lib/src/component/connector.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart' hide Action; 2 | 3 | import '../redux/index.dart'; 4 | import 'basic.dart'; 5 | 6 | /// [Connector] 7 | /// Definition of Connector for page and component(s). 8 | abstract class MutableConn { 9 | const MutableConn(); 10 | 11 | void set(T state, P subState); 12 | 13 | P get(T state); 14 | 15 | bool shouldReducer(T state, Action action) => true; 16 | 17 | /// For mutable state, there are three abilities needed to be met. 18 | /// 1. get: (S) => P 19 | /// 2. set: (S, P) => void 20 | /// 3. shallow copy: s.clone() 21 | /// 22 | /// For immutable state, there are two abilities needed to be met. 23 | /// 1. get: (S) => P 24 | /// 2. set: (S, P) => S 25 | /// 26 | /// See in [connector]. 27 | SubReducer? subReducer(Reducer

reducer) { 28 | return (T state, Action action, bool isStateCopied) { 29 | final P props = get(state); 30 | if (props == null) { 31 | return state; 32 | } 33 | final P newProps = 34 | shouldReducer(state, action) ? reducer(props, action) : props; 35 | final bool hasChanged = newProps != props; 36 | final T copy = (hasChanged && !isStateCopied) ? _clone(state) : state; 37 | if (hasChanged) { 38 | set(copy, newProps); 39 | } 40 | return copy; 41 | }; 42 | } 43 | } 44 | 45 | /// [NoneConn] 46 | /// The implementation of connector. 47 | class NoneConn extends ConnOp { 48 | const NoneConn(); 49 | 50 | @override 51 | T get(T state) => state; 52 | 53 | @override 54 | T set(T state, T subState) => subState; 55 | } 56 | 57 | /// [ConnOp] 58 | /// The implementation of connector, it needs getter and setter of state and

. 59 | class ConnOp extends MutableConn with ConnOpMixin { 60 | final P Function(T)? _getter; 61 | final void Function(T, P)? _setter; 62 | 63 | const ConnOp({ 64 | P Function(T)? get, 65 | void Function(T, P)? set, 66 | }) : _getter = get, 67 | _setter = set; 68 | 69 | @override 70 | P get(T state) => _getter != null ? _getter!(state) : Object() as P; 71 | 72 | @override 73 | void set(T state, P subState) => 74 | _setter != null ? _setter!(state, subState) : {}; 75 | } 76 | 77 | /// 78 | SubReducer? _conn( 79 | Reducer? reducer, MutableConn connector) { 80 | return reducer == null 81 | ? null 82 | : connector.subReducer( 83 | (P state, Action action) => reducer(state as Object, action) as P); 84 | } 85 | 86 | /// [_Dependent] 87 | /// Implementation of Dependent 88 | class _Dependent extends Dependent { 89 | final MutableConn connector; 90 | SubReducer? _subReducer; 91 | final Reducer

_reducer; 92 | final BasicComponent

_component; 93 | 94 | _Dependent({ 95 | required BasicComponent

component, 96 | required this.connector, 97 | }) : _reducer = component.createReducer(), 98 | _component = component { 99 | _subReducer = _conn((Object state, Action action) { 100 | return _reducer(state as P, action) as Object; 101 | }, connector); 102 | } 103 | 104 | // @override 105 | // bool isComponent() => _component is Component; 106 | // 107 | // @override 108 | // bool isAdapter() => _component is ComposedComponent; 109 | 110 | @override 111 | Widget buildComponent( 112 | Store store, 113 | Get getter, { 114 | DispatchBus? bus, 115 | }) { 116 | return _component.buildComponent( 117 | store, 118 | () => connector.get(getter()), 119 | dispatchBus: bus, 120 | ); 121 | } 122 | 123 | @override 124 | SubReducer createSubReducer() => 125 | _subReducer ?? (T state, Action _, bool __) => state; 126 | 127 | @override 128 | List buildComponents( 129 | Store store, 130 | Get getter, { 131 | DispatchBus? bus, 132 | }) { 133 | return _component.buildComponents( 134 | store, 135 | () => connector.get(getter()), 136 | dispatchBus: bus, 137 | ); 138 | } 139 | 140 | @override 141 | BasicComponent get component => _component as BasicComponent; 142 | } 143 | 144 | /// create a dependent 145 | Dependent createDependent( 146 | MutableConn connector, 147 | BasicComponent component, 148 | ) => 149 | (_Dependent( 150 | connector: connector, 151 | component: component, 152 | )); 153 | 154 | /// [ConnOpMixin] 155 | /// Mixin of Connector for Component 156 | mixin ConnOpMixin on MutableConn { 157 | Dependent operator +(BasicComponent

component) => createDependent( 158 | this, 159 | component, 160 | ); 161 | } 162 | 163 | /// how to clone an object 164 | dynamic _clone(T state) { 165 | if (state is Cloneable) { 166 | return state.clone(); 167 | } else if (state is List) { 168 | return state.toList(); 169 | } else if (state is Map) { 170 | return {}..addAll(state); 171 | } else if (state == null) { 172 | return null; 173 | } else { 174 | throw ArgumentError( 175 | 'Could not clone this state of type ${state.runtimeType}.'); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /lib/src/component/index.dart: -------------------------------------------------------------------------------- 1 | export 'basic.dart'; 2 | export 'component.dart'; 3 | export 'connector.dart'; 4 | export 'page.dart'; 5 | export 'route.dart'; 6 | -------------------------------------------------------------------------------- /lib/src/component/page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart' hide Action, Page; 2 | 3 | import '../redux/index.dart'; 4 | import 'basic.dart'; 5 | import 'component.dart'; 6 | 7 | typedef InitState = T Function(P? params); 8 | 9 | /// [Page] 10 | /// Implementation of Page component 11 | abstract class Page extends Component { 12 | Page({ 13 | required this.initState, 14 | this.middleware, 15 | Effect? effect, 16 | Reducer? reducer, 17 | Dependencies? dependencies, 18 | required ViewBuilder view, 19 | ShouldUpdate? shouldUpdate, 20 | }) : super( 21 | effect: effect, 22 | dependencies: dependencies, 23 | reducer: reducer, 24 | view: view, 25 | shouldUpdate: shouldUpdate, 26 | ); 27 | 28 | final InitState initState; 29 | final List>? middleware; 30 | 31 | /// build page 32 | Widget buildPage(P? param) => _PageWidget( 33 | param: param, 34 | page: this, 35 | ); 36 | } 37 | 38 | class _PageWidget extends StatefulWidget { 39 | final P? param; 40 | final Page page; 41 | 42 | const _PageWidget({ 43 | Key? key, 44 | this.param, 45 | required this.page, 46 | }) : super(key: key); 47 | 48 | @override 49 | State createState() => _PageState(); 50 | } 51 | 52 | class _PageState extends State<_PageWidget> { 53 | late Store _store; 54 | DispatchBus? _pageBus; 55 | late T state; 56 | 57 | final Map extra = {}; 58 | 59 | @override 60 | void initState() { 61 | super.initState(); 62 | state = widget.page.initState(widget.param); 63 | _pageBus = DispatchBusDefault(); 64 | _store = createStore(state, widget.page.createReducer(), 65 | middleware: widget.page.middleware); 66 | _pageBus?.registerReceiver(_store.dispatch); 67 | } 68 | 69 | @override 70 | void didChangeDependencies() { 71 | super.didChangeDependencies(); 72 | } 73 | 74 | @override 75 | Widget build(BuildContext context) { 76 | return widget.page.buildComponent(_store as Store, _store.getState, 77 | dispatchBus: _pageBus); 78 | } 79 | 80 | @override 81 | void dispose() { 82 | super.dispose(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /lib/src/component/route.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart' hide Page; 2 | import 'page.dart'; 3 | 4 | /// Define a basic behavior of routes. 5 | abstract class AbstractRoutes { 6 | Widget get home; 7 | Widget buildPage(String? path, dynamic arguments); 8 | } 9 | 10 | /// Each page has a unique store. 11 | @immutable 12 | class PageRoutes implements AbstractRoutes { 13 | final Map> pages; 14 | final String? initialRoute; 15 | 16 | const PageRoutes({ 17 | this.initialRoute, 18 | required this.pages, 19 | }); 20 | 21 | @override 22 | Widget buildPage(String? path, dynamic arguments) { 23 | assert(path != null && path.isNotEmpty && pages.keys.contains(path), 24 | "The path is empty or the element cannot be found, the page cannot be displayed"); 25 | return pages[path]!.buildPage(arguments); 26 | } 27 | 28 | String? get initialRoutePath => 29 | initialRoute ?? pages.keys.toList(growable: false)[0]; 30 | 31 | @override 32 | Widget get home => buildPage(initialRoutePath, {}); 33 | } 34 | -------------------------------------------------------------------------------- /lib/src/redux/basic.dart: -------------------------------------------------------------------------------- 1 | import 'package:collection/collection.dart'; 2 | 3 | /// [Action] 4 | /// Effect or Reducer message action 5 | class Action { 6 | const Action(this.type, {this.payload}); 7 | final Object type; 8 | final dynamic payload; 9 | } 10 | 11 | /// [Store] 12 | /// Definition of the standard Store. 13 | class Store { 14 | late Get getState; 15 | late Dispatch dispatch; 16 | late Subscribe subscribe; 17 | late Observable observable; 18 | late ReplaceReducer replaceReducer; 19 | late Future Function() teardown; 20 | } 21 | 22 | /// [Get] 23 | /// Definition of the function type that returns type R. 24 | typedef Get = R Function(); 25 | 26 | /// [Dispatch] patch action function 27 | typedef Dispatch = dynamic Function(Action action); 28 | 29 | /// [Subscribe] 30 | /// Definition of a standard subscription function. 31 | /// input a subscriber and output an unsubscription function. 32 | typedef Subscribe = void Function() Function(void Function() callback); 33 | 34 | /// [Observable] 35 | /// Definition of the standard observable flow. 36 | typedef Observable = Stream Function(); 37 | 38 | /// [ReplaceReducer] 39 | /// Definition of a standard ReplaceReducer function. 40 | typedef ReplaceReducer = void Function(Reducer reducer); 41 | 42 | /// [Middleware] 43 | /// Definition of the standard Middleware. 44 | typedef Middleware = Composable Function({ 45 | required Dispatch dispatch, 46 | required Get getState, 47 | }); 48 | 49 | /// Definition of synthesize functions. 50 | typedef Composable = T Function(T next); 51 | 52 | /// [Reducer] 53 | /// Definition of the state change function 54 | /// If there is a modification to the state, a new object containing 55 | /// the modification needs to be returned. 56 | typedef Reducer = T Function(T, Action); 57 | 58 | /// [SubReducer] 59 | /// Definition of the sub-state change function 60 | typedef SubReducer = T Function(T state, Action action, bool isStateCopied); 61 | 62 | /// [asReducer] 63 | /// combine & as 64 | /// for action.type which override it's == operator 65 | Reducer asReducer(Map>? map) => 66 | (map == null || map.isEmpty) 67 | ? (T state, Action action) => state 68 | : (T state, Action action) => 69 | map.entries 70 | .firstWhereOrNull((MapEntry> entry) => 71 | action.type == entry.key) 72 | ?.value(state, action) ?? 73 | state; 74 | 75 | /// [CombineReducers] 76 | /// Combine an iterable of SubReducer into one Reducer 77 | Reducer? combineSubReducers(Iterable> subReducers) { 78 | final List> notNullReducers = 79 | subReducers.toList(growable: false); 80 | 81 | if (notNullReducers.isEmpty) { 82 | return null; 83 | } 84 | 85 | if (notNullReducers.length == 1) { 86 | final SubReducer single = notNullReducers.single; 87 | return (T state, Action action) => single(state, action, false); 88 | } 89 | 90 | return (T state, Action action) { 91 | T copy = state; 92 | bool hasChanged = false; 93 | for (SubReducer subReducer in notNullReducers) { 94 | copy = subReducer(copy, action, hasChanged); 95 | hasChanged = hasChanged || copy != state; 96 | } 97 | assert(copy != null); 98 | return copy; 99 | }; 100 | } 101 | 102 | /// Combine an iterable of Reducer into one Reducer 103 | Reducer? combineReducers(Iterable> reducers) { 104 | final List> notNullReducers = reducers.toList(growable: false); 105 | 106 | if (notNullReducers.isEmpty) { 107 | return null; 108 | } 109 | 110 | if (notNullReducers.length == 1) { 111 | return notNullReducers.single; 112 | } 113 | 114 | return (T state, Action action) { 115 | T nextState = state; 116 | for (Reducer reducer in notNullReducers) { 117 | nextState = reducer(nextState, action); 118 | } 119 | assert(nextState != null); 120 | return nextState; 121 | }; 122 | } 123 | -------------------------------------------------------------------------------- /lib/src/redux/create_store.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'basic.dart'; 4 | 5 | Reducer _noop() => (T state, Action action) => state; 6 | 7 | typedef _VoidCallback = void Function(); 8 | 9 | void _throwIfNot(bool condition, [String? message]) { 10 | if (!condition) { 11 | throw ArgumentError(message); 12 | } 13 | } 14 | 15 | Store _createStore(final T preloadedState, final Reducer? reducer, 16 | {List>? middleware}) { 17 | _throwIfNot( 18 | preloadedState != null, 19 | 'Expected the preloadedState to be non-null value.', 20 | ); 21 | 22 | final List<_VoidCallback> listeners = <_VoidCallback>[]; 23 | final StreamController notifyController = 24 | StreamController.broadcast(sync: true); 25 | 26 | T state = preloadedState; 27 | Reducer storeReducer = reducer ?? _noop(); 28 | bool isDispatching = false; 29 | bool isDisposed = false; 30 | 31 | Dispatch dispatch = (Action action) { 32 | _throwIfNot(!isDispatching, 'Reducers may not dispatch actions.'); 33 | 34 | if (isDisposed) { 35 | return; 36 | } 37 | 38 | try { 39 | isDispatching = true; 40 | state = storeReducer(state, action); 41 | } finally { 42 | isDispatching = false; 43 | } 44 | 45 | final List<_VoidCallback> notifyListeners = listeners.toList( 46 | growable: false, 47 | ); 48 | for (_VoidCallback listener in notifyListeners) { 49 | listener(); 50 | } 51 | 52 | notifyController.add(state); 53 | }; 54 | final Get getState = (() => state); 55 | 56 | dispatch = (middleware?.isNotEmpty ?? false) 57 | ? middleware! 58 | .map((Middleware middleware) => middleware( 59 | dispatch: (Action action) => dispatch(action), 60 | getState: getState, 61 | )) 62 | .fold( 63 | dispatch, 64 | (Dispatch previousValue, Dispatch Function(Dispatch) element) => 65 | element(previousValue), 66 | ) 67 | : dispatch; 68 | 69 | replaceReducer(Reducer? replaceReducer) { 70 | storeReducer = replaceReducer ?? _noop(); 71 | } 72 | 73 | subscribe(_VoidCallback listener) { 74 | _throwIfNot( 75 | !isDispatching, 76 | 'You may not call store.subscribe() while the reducer is executing.', 77 | ); 78 | 79 | listeners.add(listener); 80 | 81 | return () { 82 | _throwIfNot( 83 | !isDispatching, 84 | 'You may not unsubscribe from a store listener while the reducer is executing.', 85 | ); 86 | listeners.remove(listener); 87 | }; 88 | } 89 | 90 | final Observable observable = (() => notifyController.stream); 91 | return Store() 92 | ..getState = getState 93 | ..dispatch = dispatch 94 | ..replaceReducer = replaceReducer 95 | ..subscribe = subscribe 96 | ..observable = observable 97 | ..teardown = () { 98 | isDisposed = true; 99 | listeners.clear(); 100 | return notifyController.close(); 101 | }; 102 | } 103 | 104 | /// create a store with enhancer 105 | Store createStore( 106 | T preloadedState, 107 | Reducer? reducer, { 108 | List>? middleware, 109 | }) => 110 | _createStore(preloadedState, reducer, middleware: middleware); 111 | -------------------------------------------------------------------------------- /lib/src/redux/index.dart: -------------------------------------------------------------------------------- 1 | export 'basic.dart'; 2 | export 'create_store.dart'; 3 | export 'middleware.dart'; 4 | -------------------------------------------------------------------------------- /lib/src/redux/middleware.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | 3 | import 'basic.dart'; 4 | 5 | /// Middleware for print action dispatch. 6 | /// It works on debug mode. 7 | Middleware logMiddleware({ 8 | String tag = 'redux', 9 | String Function(T?)? monitor, 10 | }) { 11 | return ({Dispatch? dispatch, Get? getState}) { 12 | return (Dispatch next) { 13 | return (Action action) { 14 | _doPrint('---------- [$tag] ----------'); 15 | _doPrint('[$tag] ${action.type} ${action.payload}'); 16 | 17 | final T? prevState = getState?.call(); 18 | if (monitor != null) { 19 | _doPrint('[$tag] prev-state: ${monitor(prevState)}'); 20 | } 21 | 22 | next(action); 23 | 24 | final T? nextState = getState?.call(); 25 | if (monitor != null) { 26 | _doPrint('[$tag] next-state: ${monitor(nextState)}'); 27 | } 28 | 29 | _doPrint('========== [$tag] ================'); 30 | }; 31 | }; 32 | }; 33 | } 34 | 35 | void _doPrint([String? message]) { 36 | if (kDebugMode) { 37 | print('[FlyingRedux]: $message'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /logo-mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/logo-mini.png -------------------------------------------------------------------------------- /logo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/logo.jpeg -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flying_redux 2 | description: Flying Redux is an assembled flutter application framework based on Redux state management. 3 | version: 0.1.0 4 | homepage: https://github.com/GavinHome/flying-redux 5 | 6 | environment: 7 | sdk: '>=2.17.0 <4.0.0' 8 | flutter: ">=3.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | collection: ^1.16.0 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | flutter_lints: ^2.0.0 19 | 20 | # For information on the generic Dart part of this file, see the 21 | # following page: https://dart.dev/tools/pub/pubspec 22 | 23 | # The following section is specific to Flutter packages. 24 | flutter: 25 | 26 | # To add assets to your package, add an assets section, like this: 27 | # assets: 28 | # - images/a_dot_burr.jpeg 29 | # - images/a_dot_ham.jpeg 30 | # 31 | # For details regarding assets in packages, see 32 | # https://flutter.dev/assets-and-images/#from-packages 33 | # 34 | # An image asset can refer to one or more resolution-specific "variants", see 35 | # https://flutter.dev/assets-and-images/#resolution-aware 36 | 37 | # To add custom fonts to your package, add a fonts section here, 38 | # in this "flutter" section. Each entry in this list should have a 39 | # "family" key with the font family name, and a "fonts" key with a 40 | # list giving the asset and other descriptors for the font. For 41 | # example: 42 | # fonts: 43 | # - family: Schyler 44 | # fonts: 45 | # - asset: fonts/Schyler-Regular.ttf 46 | # - asset: fonts/Schyler-Italic.ttf 47 | # style: italic 48 | # - family: Trajan Pro 49 | # fonts: 50 | # - asset: fonts/TrajanPro.ttf 51 | # - asset: fonts/TrajanPro_Bold.ttf 52 | # weight: 700 53 | # 54 | # For details regarding fonts in packages, see 55 | # https://flutter.dev/custom-fonts/#from-packages 56 | -------------------------------------------------------------------------------- /qq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/qq.jpg -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | .packages 4 | .pub/ 5 | build/ 6 | .flutter-plugins 7 | pubspec.lock 8 | /pubspec.lock 9 | -------------------------------------------------------------------------------- /test/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | 31 | analyzer: 32 | errors: 33 | unnecessary_null_comparison: ignore 34 | avoid_print: ignore 35 | unnecessary_this: ignore 36 | hash_and_equals: ignore 37 | avoid_function_literals_in_foreach_calls: ignore 38 | -------------------------------------------------------------------------------- /test/flying_redux_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | /// A Calculator. 4 | class Calculator { 5 | /// Returns [value] plus 1. 6 | int addOne(int value) => value + 1; 7 | } 8 | 9 | void main() { 10 | test('adds one to input values', () { 11 | final calculator = Calculator(); 12 | expect(calculator.addOne(2), 3); 13 | expect(calculator.addOne(-7), -6); 14 | expect(calculator.addOne(0), 1); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /test/lib/all_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | import 'redux/index_test.dart' as redux; 4 | import 'component/index_test.dart' as component; 5 | 6 | void main() { 7 | group('all_test', () { 8 | redux.main(); 9 | component.main(); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /test/lib/component/index_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | import 'component_test.dart' as component; 4 | import 'lifecycle_test.dart' as lifecycle; 5 | import 'page_test.dart' as page; 6 | import 'route_test.dart' as route; 7 | 8 | void main() { 9 | group('redux_component_test', () { 10 | component.main(); 11 | lifecycle.main(); 12 | page.main(); 13 | route.main(); 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /test/lib/component/route_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page; 3 | import 'package:flutter_test/flutter_test.dart'; 4 | import '../test_widgets/page/page.dart'; 5 | import '../test_widgets/page/state.dart'; 6 | import '../test_widgets/test_base.dart'; 7 | 8 | void main() { 9 | group('routes_test', () { 10 | test('create pageRoutes', () { 11 | TestPage toDoListPage = TestPage( 12 | initState: initState, 13 | view: toDoListView, 14 | ); 15 | TestPage countPage = TestPage( 16 | initState: (Map? map) => ToDoList.fromMap(map ?? {}), 17 | view: ( 18 | Object state, 19 | Dispatch dispatch, 20 | ComponentContext ctx, 21 | ) => 22 | const Text("Counter App"), 23 | ); 24 | 25 | final AbstractRoutes routes = PageRoutes( 26 | initialRoute: 'todo_list', 27 | pages: >{ 28 | 'todo_list': toDoListPage, 29 | 'count_page': countPage, 30 | }); 31 | 32 | expect(routes, isNotNull); 33 | expect(routes, const TypeMatcher()); 34 | expect(routes.home, isNotNull); 35 | expect(routes.home, const TypeMatcher()); 36 | 37 | final toDoListWidget = routes.buildPage('todo_list', null); 38 | expect(toDoListWidget, isNotNull); 39 | expect(toDoListWidget, const TypeMatcher()); 40 | }); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /test/lib/instrument.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | typedef ViewInstrument = void Function( 4 | T state, Dispatch dispatch, ComponentContext viewService); 5 | 6 | ViewBuilder instrumentView( 7 | ViewBuilder builder, ViewInstrument? pre) => 8 | ( 9 | T state, 10 | Dispatch dispatch, 11 | ComponentContext viewService, 12 | ) { 13 | if (pre != null) { 14 | pre(state, dispatch, viewService); 15 | } 16 | 17 | return builder(state, dispatch, viewService); 18 | }; 19 | 20 | typedef InitStateInstrumentPre

= void Function(P); 21 | typedef InitStateInstrumentSuf> = void Function(T); 22 | 23 | InitState instrumentInitState, P>( 24 | InitState initState, 25 | {InitStateInstrumentPre? pre, 26 | InitStateInstrumentSuf? suf}) => 27 | (P? params) { 28 | if (pre != null) { 29 | pre(params); 30 | } 31 | final T state = initState(params); 32 | 33 | if (suf != null) { 34 | suf(state); 35 | } 36 | 37 | return state; 38 | }; 39 | 40 | typedef ReducerInstrument = void Function(T state, Action action); 41 | 42 | Reducer instrumentReducer(Reducer reducer, 43 | {ReducerInstrument? pre, 44 | ReducerInstrument? suf, 45 | ReducerInstrument? change}) => 46 | (T state, Action action) { 47 | T newState = state; 48 | if (pre != null) { 49 | pre(state, action); 50 | } 51 | 52 | newState = reducer(state, action); 53 | 54 | if (suf != null) { 55 | suf(newState, action); 56 | } 57 | 58 | if (change != null && newState != state) { 59 | change(newState, action); 60 | } 61 | 62 | return newState; 63 | }; 64 | 65 | typedef EffectInstrument = void Function(Action action, Get getState); 66 | 67 | Effect instrumentEffect(Effect effect, EffectInstrument? pre) => 68 | (Action action, ComponentContext ctx) { 69 | if (pre != null) { 70 | pre(action, () => ctx.state); 71 | } 72 | return effect(action, ctx); 73 | }; 74 | 75 | typedef MiddlewareInstrument = void Function(Action action, Get getState); 76 | 77 | Middleware instrumentMiddleware(Middleware middleware, 78 | {EffectInstrument? pre, EffectInstrument? suf}) => 79 | ({ 80 | required Dispatch dispatch, 81 | required Get getState, 82 | }) { 83 | return (Dispatch next) { 84 | return (Action action) { 85 | if (pre != null) { 86 | pre(action, getState); 87 | } 88 | 89 | middleware(dispatch: dispatch, getState: getState)(next)(action); 90 | 91 | if (suf != null) { 92 | suf(action, getState); 93 | } 94 | }; 95 | }; 96 | }; 97 | 98 | typedef ErrorInstrument = void Function( 99 | Exception exception, ComponentContext ctx); 100 | -------------------------------------------------------------------------------- /test/lib/redux/index_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | import 'store_test.dart' as store; 4 | 5 | void main() { 6 | group('redux_test', () { 7 | store.main(); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /test/lib/test_widgets/component/action.dart: -------------------------------------------------------------------------------- 1 | enum ToDoListAction { onAdd, add, remove, onBroadcast, broadcast } 2 | 3 | enum ToDoAction { onEdit, edit, markDone, onBroadcast, broadcast } 4 | -------------------------------------------------------------------------------- /test/lib/test_widgets/component/component.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page; 3 | 4 | import 'action.dart'; 5 | import 'state.dart'; 6 | 7 | Widget toDoView( 8 | Todo toDo, Dispatch dispatch, ComponentContext viewService) { 9 | return Container( 10 | margin: const EdgeInsets.all(8.0), 11 | color: Colors.grey, 12 | child: Row( 13 | children: [ 14 | Expanded( 15 | child: Column( 16 | children: [ 17 | GestureDetector( 18 | child: Container( 19 | key: ValueKey('remove-${toDo.id}'), 20 | padding: const EdgeInsets.all(8.0), 21 | height: 28.0, 22 | color: Colors.yellow, 23 | alignment: AlignmentDirectional.centerStart, 24 | child: Text( 25 | toDo.title, 26 | style: const TextStyle(fontSize: 16.0), 27 | ), 28 | ), 29 | onTap: () { 30 | print('dispatch remove'); 31 | dispatch(Action(ToDoListAction.remove, payload: toDo.clone())); 32 | }, 33 | ), 34 | GestureDetector( 35 | child: Container( 36 | key: ValueKey('edit-${toDo.id}'), 37 | padding: const EdgeInsets.all(8.0), 38 | height: 60.0, 39 | color: Colors.grey, 40 | alignment: AlignmentDirectional.centerStart, 41 | child: Text(toDo.desc, style: const TextStyle(fontSize: 14.0)), 42 | ), 43 | onTap: () { 44 | print('dispatch onEdit'); 45 | dispatch(Action(ToDoAction.onEdit, payload: toDo.clone())); 46 | }, 47 | ) 48 | ], 49 | )), 50 | GestureDetector( 51 | child: Container( 52 | key: ValueKey('mark-${toDo.id}'), 53 | color: toDo.isDone ? Colors.green : Colors.red, 54 | width: 88.0, 55 | height: 88.0, 56 | alignment: AlignmentDirectional.center, 57 | child: Text(toDo.isDone ? 'done' : 'mark\ndone'), 58 | ), 59 | onTap: () { 60 | if (!toDo.isDone) { 61 | print('dispatch markDone'); 62 | dispatch(Action(ToDoAction.markDone, payload: toDo.clone())); 63 | } 64 | }, 65 | onLongPress: () { 66 | print('dispatch broadcast'); 67 | dispatch(const Action(ToDoAction.onBroadcast)); 68 | }, 69 | ) 70 | ], 71 | ), 72 | ); 73 | } 74 | 75 | bool toDoEffect(Action action, ComponentContext ctx) { 76 | if (action.type == ToDoAction.onEdit) { 77 | print('onEdit'); 78 | 79 | Todo toDo = ctx.state.clone(); 80 | toDo.desc = '${toDo.desc}-effect'; 81 | 82 | ctx.dispatch(Action(ToDoAction.edit, payload: toDo)); 83 | return true; 84 | } else if (action.type == ToDoAction.onBroadcast) { 85 | ctx.broadcastEffect(const Action(ToDoAction.broadcast)); 86 | return true; 87 | } else if (action.type == Lifecycle.initState) { 88 | print('!!! initState ${ctx.state}'); 89 | return true; 90 | } else if (action.type == Lifecycle.dispose) { 91 | print('!!! dispose ${ctx.state}'); 92 | return true; 93 | } 94 | 95 | return false; 96 | } 97 | 98 | dynamic toDoEffectAsync(Action action, ComponentContext ctx) { 99 | if (action.type == ToDoAction.onEdit) { 100 | return Future.delayed( 101 | const Duration(seconds: 1), () => toDoEffect(action, ctx)); 102 | } 103 | 104 | return null; 105 | } 106 | 107 | Dispatch toDoHigherEffect(ComponentContext ctx) => 108 | (Action action) => toDoEffect(action, ctx); 109 | 110 | Todo toDoReducer(Todo state, Action action) { 111 | if (action.payload is! Todo || state.id != action.payload.id) return state; 112 | 113 | print('onReduce:${action.type}'); 114 | 115 | if (action.type == ToDoAction.markDone) { 116 | return state.clone()..isDone = true; 117 | } else if (action.type == ToDoAction.edit) { 118 | return state.clone()..desc = action.payload.desc; 119 | } else { 120 | return state.clone(); 121 | } 122 | } 123 | 124 | bool shouldUpdate(Todo old, Todo now) => old != now; 125 | 126 | bool reducerFilter(Todo toDo, Action action) { 127 | return action.type == ToDoAction.edit || action.type == ToDoAction.markDone; 128 | } 129 | 130 | class ToDoComponent extends Component { 131 | ToDoComponent() 132 | : super( 133 | view: toDoView, 134 | effect: toDoEffect, 135 | reducer: toDoReducer, 136 | ); 137 | } 138 | 139 | class ComponentWrapper extends StatelessWidget { 140 | final Widget child; 141 | 142 | const ComponentWrapper(this.child, {super.key}); 143 | 144 | @override 145 | Widget build(BuildContext context) { 146 | return child; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /test/lib/test_widgets/component/page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page; 3 | 4 | import '../test_base.dart'; 5 | import 'action.dart'; 6 | import 'component.dart'; 7 | import 'state.dart'; 8 | 9 | Widget toDoListView( 10 | ToDoList state, 11 | Dispatch dispatch, 12 | ComponentContext viewService, 13 | ) { 14 | print('build toDoListView'); 15 | return Column( 16 | children: [ 17 | Expanded( 18 | child: ListView.builder( 19 | itemBuilder: (context, index) { 20 | if (index == 0) { 21 | return viewService.buildComponent('toDo0'); 22 | } else if (index == 1) { 23 | return viewService.buildComponent('toDo1'); 24 | } else if (index == 2) { 25 | return viewService.buildComponent('toDo2'); 26 | } else if (index == 3) { 27 | return viewService.buildComponent('toDo3'); 28 | } else { 29 | Todo toDo = state.list[index]; 30 | return Container( 31 | padding: const EdgeInsets.all(8.0), 32 | margin: const EdgeInsets.all(8.0), 33 | color: Colors.grey, 34 | alignment: AlignmentDirectional.center, 35 | child: Text(toDo.desc), 36 | ); 37 | } 38 | }, 39 | itemCount: state.list.length, 40 | )), 41 | Row( 42 | children: [ 43 | Expanded( 44 | child: GestureDetector( 45 | child: Container( 46 | key: const ValueKey('Add'), 47 | height: 68.0, 48 | color: Colors.green, 49 | alignment: AlignmentDirectional.center, 50 | child: const Text('Add'), 51 | ), 52 | onTap: () { 53 | print('dispatch Add'); 54 | dispatch(const Action(ToDoListAction.onAdd)); 55 | }, 56 | )), 57 | ], 58 | ) 59 | ], 60 | ); 61 | } 62 | 63 | bool toDoListEffect(Action action, ComponentContext ctx) { 64 | if (action.type == ToDoListAction.onAdd) { 65 | ctx.dispatch(Action(ToDoListAction.add, payload: Todo.mock())); 66 | return true; 67 | } else if (action.type == ToDoListAction.onBroadcast) { 68 | ctx.broadcastEffect(const Action(ToDoListAction.broadcast)); 69 | return true; 70 | } 71 | 72 | return false; 73 | } 74 | 75 | dynamic toDoListEffectAsync(Action action, ComponentContext ctx) { 76 | if (action.type == ToDoListAction.onAdd) { 77 | return Future.delayed( 78 | const Duration(seconds: 1), () => toDoListEffect(action, ctx)); 79 | } 80 | 81 | return null; 82 | } 83 | 84 | Dispatch toDoListHigherEffect(ComponentContext ctx) => 85 | (Action action) => toDoListEffect(action, ctx); 86 | 87 | ToDoList toDoListReducer(ToDoList state, Action action) { 88 | print('onReduce:${action.type}'); 89 | if (action.payload is! Todo) return state; 90 | 91 | if (action.type == ToDoListAction.add) { 92 | return state.clone()..list.add(action.payload); 93 | } else if (action.type == ToDoListAction.remove) { 94 | Todo toDo = state.list.firstWhere((toDo) => toDo.id == action.payload.id); 95 | int index = state.list.indexOf(toDo); 96 | toDo = toDo.clone()..desc = 'removed'; 97 | return state.clone()..list[index] = toDo; 98 | } else { 99 | return state.clone(); 100 | } 101 | } 102 | 103 | const Map pageInitParams = { 104 | 'list': [ 105 | { 106 | 'id': '0', 107 | 'title': 'title-0', 108 | 'desc': 'desc-0', 109 | 'isDone': false 110 | }, 111 | { 112 | 'id': '1', 113 | 'title': 'title-1', 114 | 'desc': 'desc-1', 115 | 'isDone': false 116 | }, 117 | { 118 | 'id': '2', 119 | 'title': 'title-2', 120 | 'desc': 'desc-2', 121 | 'isDone': false 122 | }, 123 | { 124 | 'id': '3', 125 | 'title': 'title-3', 126 | 'desc': 'desc-3', 127 | 'isDone': true 128 | } 129 | ] 130 | }; 131 | 132 | ToDoList initState(Map? map) => ToDoList.fromMap(map ?? {}); 133 | 134 | class ToDoComponent0 extends ToDoComponent {} 135 | 136 | class ToDoComponent1 extends ToDoComponent {} 137 | 138 | class ToDoComponent2 extends ToDoComponent {} 139 | 140 | class ToDoComponent3 extends ToDoComponent {} 141 | 142 | final toDoListDependencies = Dependencies(slots: { 143 | 'toDo0': ConnOp( 144 | get: (toDoList) => toDoList.list[0], 145 | set: (toDoList, toDo) => toDoList.list[0] = toDo) + 146 | ToDoComponent0(), 147 | 'toDo1': ConnOp( 148 | get: (toDoList) => toDoList.list[1], 149 | set: (toDoList, toDo) => toDoList.list[1] = toDo) + 150 | ToDoComponent1(), 151 | 'toDo2': ConnOp( 152 | get: (toDoList) => toDoList.list[2], 153 | set: (toDoList, toDo) => toDoList.list[2] = toDo) + 154 | ToDoComponent2(), 155 | 'toDo3': ConnOp( 156 | get: (toDoList) => toDoList.list[3], 157 | set: (toDoList, toDo) => toDoList.list[3] = toDo) + 158 | ToDoComponent3(), 159 | }); 160 | 161 | Widget createComponentWidget(BuildContext context) { 162 | return TestPage( 163 | initState: initState, 164 | view: toDoListView, 165 | reducer: toDoListReducer, 166 | effect: toDoListEffect, 167 | dependencies: toDoListDependencies) 168 | .buildPage(pageInitParams); 169 | } 170 | -------------------------------------------------------------------------------- /test/lib/test_widgets/component/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | class Todo implements Cloneable { 4 | String id = ""; 5 | String title = ""; 6 | String desc = ""; 7 | bool isDone = false; 8 | 9 | Todo(); 10 | 11 | factory Todo.mock() => Todo() 12 | ..id = 'id-mock' 13 | ..title = 'title-mock' 14 | ..desc = 'desc-mock' 15 | ..isDone = false; 16 | 17 | @override 18 | Todo clone() => Todo() 19 | ..id = this.id 20 | ..title = this.title 21 | ..desc = this.desc 22 | ..isDone = this.isDone; 23 | 24 | factory Todo.fromMap(Map map) { 25 | return Todo() 26 | ..id = map['id'] ?? 'unique' 27 | ..title = map['title'] ?? '' 28 | ..desc = map['desc'] ?? '' 29 | ..isDone = map['isDone'] ?? false; 30 | } 31 | 32 | @override 33 | bool operator ==(dynamic other) { 34 | if (other is! Todo) return false; 35 | 36 | return id == other.id && 37 | title == other.title && 38 | desc == other.desc && 39 | isDone == other.isDone; 40 | } 41 | 42 | @override 43 | String toString() { 44 | return 'Todo{id: $id, title: $title, desc: $desc, isDone: $isDone}'; 45 | } 46 | } 47 | 48 | class ToDoList implements Cloneable { 49 | List list = []; 50 | 51 | ToDoList(); 52 | 53 | @override 54 | ToDoList clone() => ToDoList()..list.addAll(this.list); 55 | 56 | factory ToDoList.fromMap(Map map) { 57 | return ToDoList() 58 | ..list.addAll( 59 | map['list']?.map((Map map) => Todo.fromMap(map))?.toList()); 60 | } 61 | 62 | @override 63 | bool operator ==(dynamic other) { 64 | if (other is! ToDoList) return false; 65 | 66 | if (list.length != other.list.length) return false; 67 | 68 | for (int index = 0; index < list.length; index++) { 69 | if (list[index] != other.list[index]) return false; 70 | } 71 | 72 | return true; 73 | } 74 | 75 | @override 76 | String toString() { 77 | return '{list: $list}'; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /test/lib/test_widgets/main.dart: -------------------------------------------------------------------------------- 1 | // import 'package:flutter/material.dart' hide Action, Page; 2 | // import '../test_widgets/adapter/page.dart'; 3 | // import '../test_widgets/component/page.dart'; 4 | // import '../test_widgets/dynamic_flow_adapter/page.dart'; 5 | // import '../test_widgets/page/page.dart'; 6 | // import '../test_widgets/static_flow_adapter/page.dart'; 7 | 8 | // import 'test_base.dart'; 9 | 10 | // final Map cases = { 11 | // 'buildPage': createPageWidget, 12 | // 'buildComponent': createComponentWidget, 13 | // 'buildAdapter': createAdapterWidget, 14 | // 'buildStaticAdapter': createStaticAdapterWidget, 15 | // 'buildDynamicAdapter': createDynamicAdapterWidget 16 | // }; 17 | 18 | // void main() { 19 | // runApp(TestStub(ListView.builder( 20 | // itemBuilder: (BuildContext context, int index) { 21 | // final String name = cases.keys.toList()[index]; 22 | // final WidgetBuilder builder = cases.values.toList()[index]; 23 | 24 | // return GestureDetector( 25 | // child: Container( 26 | // height: 86.0, 27 | // margin: const EdgeInsets.all(8.0), 28 | // padding: const EdgeInsets.all(8.0), 29 | // alignment: AlignmentDirectional.center, 30 | // color: Colors.grey, 31 | // child: Text( 32 | // name, 33 | // style: const TextStyle(fontSize: 16, color: Colors.black), 34 | // ), 35 | // ), 36 | // onTap: () { 37 | // Navigator.of(context).push(MaterialPageRoute( 38 | // builder: (BuildContext context) => TestStub(builder(context)))); 39 | // }, 40 | // ); 41 | // }, 42 | // itemCount: cases.length))); 43 | // } 44 | -------------------------------------------------------------------------------- /test/lib/test_widgets/page/action.dart: -------------------------------------------------------------------------------- 1 | enum ToDoListAction { 2 | onAdd, 3 | add, 4 | onEdit, 5 | middlewareEdit, 6 | edit, 7 | markDone, 8 | remove, 9 | onKnowException, 10 | onUnKnowException 11 | } 12 | -------------------------------------------------------------------------------- /test/lib/test_widgets/page/exception.dart: -------------------------------------------------------------------------------- 1 | class KnowException implements Exception { 2 | @override 3 | bool operator ==(dynamic other) => other is KnowException; 4 | } 5 | 6 | class UnKnowException implements Exception { 7 | @override 8 | bool operator ==(dynamic other) => other is UnKnowException; 9 | } 10 | -------------------------------------------------------------------------------- /test/lib/test_widgets/page/state.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | 3 | class Todo implements Cloneable { 4 | String id = ""; 5 | String title = ""; 6 | String desc = ""; 7 | bool isDone = false; 8 | 9 | Todo(); 10 | 11 | factory Todo.mock() => Todo() 12 | ..id = 'id-mock' 13 | ..title = 'title-mock' 14 | ..desc = 'desc-mock' 15 | ..isDone = false; 16 | 17 | @override 18 | Todo clone() => Todo() 19 | ..id = this.id 20 | ..title = this.title 21 | ..desc = this.desc 22 | ..isDone = this.isDone; 23 | 24 | factory Todo.fromMap(Map map) { 25 | return Todo() 26 | ..id = map['id'] ?? 'uniq' 27 | ..title = map['title'] ?? '' 28 | ..desc = map['desc'] ?? '' 29 | ..isDone = map['isDone'] ?? false; 30 | } 31 | 32 | @override 33 | bool operator ==(dynamic other) { 34 | if (other is! Todo) return false; 35 | 36 | return id == other.id && 37 | title == other.title && 38 | desc == other.desc && 39 | isDone == other.isDone; 40 | } 41 | 42 | @override 43 | String toString() { 44 | return 'Todo{id: $id, title: $title, desc: $desc, isDone: $isDone}'; 45 | } 46 | } 47 | 48 | class ToDoList implements Cloneable { 49 | List list = []; 50 | 51 | ToDoList(); 52 | 53 | @override 54 | ToDoList clone() => ToDoList()..list.addAll(this.list); 55 | 56 | factory ToDoList.fromMap(Map map) { 57 | return ToDoList() 58 | ..list.addAll( 59 | map['list']?.map((Map map) => Todo.fromMap(map))?.toList()); 60 | } 61 | 62 | @override 63 | bool operator ==(dynamic other) { 64 | if (other is! ToDoList) return false; 65 | 66 | if (list.length != other.list.length) return false; 67 | 68 | for (int index = 0; index < list.length; index++) { 69 | if (list[index] != other.list[index]) return false; 70 | } 71 | 72 | return true; 73 | } 74 | 75 | @override 76 | String toString() { 77 | return '{list: $list}'; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /test/lib/test_widgets/test_base.dart: -------------------------------------------------------------------------------- 1 | import 'package:flying_redux/flying_redux.dart'; 2 | import 'package:flutter/material.dart' hide Action, Page, ViewBuilder; 3 | 4 | @immutable 5 | class TestStub extends StatefulWidget { 6 | final Widget testWidget; 7 | final String title; 8 | 9 | const TestStub(this.testWidget, {super.key, this.title = 'FlutterTest'}); 10 | 11 | @override 12 | StubState createState() => StubState(); 13 | } 14 | 15 | class StubState extends State { 16 | @override 17 | Widget build(BuildContext context) { 18 | return MaterialApp( 19 | title: widget.title, 20 | home: Scaffold( 21 | appBar: AppBar(title: Text(widget.title)), 22 | body: widget.testWidget)); 23 | } 24 | } 25 | 26 | class TestPage, P> extends Page { 27 | TestPage({ 28 | required InitState initState, 29 | List>? middleware, 30 | required ViewBuilder view, 31 | Reducer? reducer, 32 | Effect? effect, 33 | Dependencies? dependencies, 34 | ShouldUpdate? shouldUpdate, 35 | Key Function(T)? key, 36 | }) : super( 37 | initState: initState, 38 | middleware: middleware, 39 | view: view, 40 | reducer: reducer, 41 | effect: effect, 42 | dependencies: dependencies, 43 | shouldUpdate: shouldUpdate, 44 | ); 45 | } 46 | 47 | class TestComponent> extends Component { 48 | TestComponent({ 49 | required ViewBuilder view, 50 | Reducer? reducer, 51 | Effect? effect, 52 | Dependencies? dependencies, 53 | ShouldUpdate? shouldUpdate, 54 | Key Function(T)? key, 55 | }) : super( 56 | view: view, 57 | reducer: reducer, 58 | effect: effect, 59 | dependencies: dependencies, 60 | shouldUpdate: shouldUpdate, 61 | ); 62 | } 63 | 64 | // class TestAdapter> extends BasicAdapter { 65 | // TestAdapter({ 66 | // Reducer? reducer, 67 | // required Dependents Function(T) builder, 68 | // ShouldUpdate? shouldUpdate, 69 | // }) : super( 70 | // reducer: reducer, 71 | // builder: builder, 72 | // shouldUpdate: shouldUpdate 73 | // ); 74 | // } 75 | -------------------------------------------------------------------------------- /test/lib/track.dart: -------------------------------------------------------------------------------- 1 | class Track { 2 | final List _pins = []; 3 | 4 | Track(); 5 | 6 | factory Track.tags(List? tags) { 7 | tags ??= []; 8 | 9 | final Track tracer = Track(); 10 | tags.forEach((String tag) => tracer.append(tag)); 11 | 12 | return tracer; 13 | } 14 | 15 | factory Track.pins(List? tags) { 16 | tags ??= []; 17 | 18 | final Track tracer = Track(); 19 | tags.forEach((Pin pin) => tracer.append(pin.tag, pin.value)); 20 | 21 | return tracer; 22 | } 23 | 24 | void append(String tag, [Object? value]) { 25 | _pins.add(Pin(tag, value)); 26 | } 27 | 28 | int countOfTag(String tag) => 29 | _pins.fold(0, (count, pin) => pin.tag == tag ? count + 1 : count); 30 | 31 | void remove(String tag) => _pins.retainWhere((pin) => pin.tag == tag); 32 | 33 | @override 34 | String toString() => _pins 35 | .map((node) => node.toString()) 36 | .fold('', (prev, now) => '$prev\n=>$now'); 37 | 38 | @override 39 | bool operator ==(dynamic other) { 40 | if (other is! Track) return false; 41 | 42 | if (_pins.length != other._pins.length) return false; 43 | 44 | for (int index = 0; index < _pins.length; index++) { 45 | if (_pins[index] != other._pins[index]) return false; 46 | } 47 | 48 | return true; 49 | } 50 | 51 | void reset() { 52 | _pins.clear(); 53 | } 54 | } 55 | 56 | class Pin { 57 | String tag; 58 | Object? value; 59 | DateTime timeStamp; 60 | 61 | Pin(this.tag, [Object? value]) 62 | : timeStamp = DateTime.now(), 63 | value = value is Function ? value() : value; 64 | 65 | @override 66 | String toString() => '$tag<${value?.toString()}>'; 67 | 68 | @override 69 | bool operator ==(dynamic other) { 70 | if (other is! Pin) return false; 71 | 72 | return other.tag == tag && other.value == value; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /test/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flying_redux_test 2 | description: A new Flutter package. 3 | version: 0.0.1 4 | publish_to: none 5 | 6 | environment: 7 | sdk: '>=2.17.0 <4.0.0' 8 | 9 | dependencies: 10 | flying_redux: 11 | path: ../ 12 | flutter: 13 | sdk: flutter 14 | flutter_test: 15 | sdk: flutter 16 | collection: ^1.16.0 17 | 18 | dev_dependencies: 19 | flutter_lints: ^2.0.0 20 | 21 | # flutter_driver: 22 | # sdk: flutter 23 | 24 | # For information on the generic Dart part of this file, see the 25 | # following page: https://www.dartlang.org/tools/pub/pubspec 26 | 27 | # The following section is specific to Flutter. 28 | flutter: 29 | # To add assets to your package, add an assets section, like this: 30 | # assets: 31 | # - images/a_dot_burr.jpeg 32 | # - images/a_dot_ham.jpeg 33 | # 34 | # For details regarding assets in packages, see 35 | # https://flutter.io/assets-and-images/#from-packages 36 | # 37 | # An image asset can refer to one or more resolution-specific "variants", see 38 | # https://flutter.io/assets-and-images/#resolution-aware. 39 | # To add custom fonts to your package, add a fonts section here, 40 | # in this "flutter" section. Each entry in this list should have a 41 | # "family" key with the font family name, and a "fonts" key with a 42 | # list giving the asset and other descriptors for the font. For 43 | # example: 44 | # fonts: 45 | # - family: Schyler 46 | # fonts: 47 | # - asset: fonts/Schyler-Regular.ttf 48 | # - asset: fonts/Schyler-Italic.ttf 49 | # style: italic 50 | # - family: Trajan Pro 51 | # fonts: 52 | # - asset: fonts/TrajanPro.ttf 53 | # - asset: fonts/TrajanPro_Bold.ttf 54 | # weight: 700 55 | # 56 | # For details regarding fonts in packages, see 57 | # https://flutter.io/custom-fonts/#from-packages 58 | -------------------------------------------------------------------------------- /wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinHome/flying-redux/7fd4a8404158c30cd338d9736ea602d01063ca78/wechat.jpg --------------------------------------------------------------------------------