├── .vscode └── launch.json ├── README.md ├── jiemian.png ├── jsonformat ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── assets │ └── json_icon.jpeg ├── lib │ ├── main.dart │ ├── models │ │ ├── inner_model.dart │ │ ├── json_file.dart │ │ ├── json_manager.dart │ │ ├── json_repair.dart │ │ ├── log_message.dart │ │ ├── model_convert.dart │ │ ├── output_manager.dart │ │ ├── output_model.dart │ │ ├── output_serializer.dart │ │ ├── string_extension_json.dart │ │ └── textspan_extension.dart │ └── views │ │ ├── filedrag_view.dart │ │ ├── json_input_window.dart │ │ ├── json_output_window.dart │ │ ├── main_style_button.dart │ │ ├── main_toolbar_window.dart │ │ ├── output_toolbar_view.dart │ │ ├── property_wrap_item_widget.dart │ │ └── rich_textediting_controller.dart ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── 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 ├── pubspec.lock ├── 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 ├── submit.rb └── yanshi.gif /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "jsonformat", 9 | "cwd": "jsonformat", 10 | "request": "launch", 11 | "type": "dart" 12 | }, 13 | { 14 | "name": "jsonformat (profile mode)", 15 | "cwd": "jsonformat", 16 | "request": "launch", 17 | "type": "dart", 18 | "flutterMode": "profile" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/README.md -------------------------------------------------------------------------------- /jiemian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jiemian.png -------------------------------------------------------------------------------- /jsonformat/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /jsonformat/.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: 77d935af4db863f6abd0b9c31c7e6df2a13de57b 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /jsonformat/README.md: -------------------------------------------------------------------------------- 1 | # jsonformat 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://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/assets/json_icon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/assets/json_icon.jpeg -------------------------------------------------------------------------------- /jsonformat/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:bitsdojo_window/bitsdojo_window.dart'; 4 | 5 | import 'package:jsonformat/views/json_input_window.dart'; 6 | import 'package:jsonformat/views/main_toolbar_window.dart'; 7 | import 'package:jsonformat/views/json_output_window.dart'; 8 | import 'package:jsonformat/views/output_toolbar_view.dart'; 9 | 10 | void main() { 11 | runApp(const MyApp()); 12 | 13 | doWhenWindowReady(() { 14 | const initialSize = Size(820, 500); 15 | appWindow.minSize = initialSize; 16 | appWindow.size = initialSize; 17 | appWindow.alignment = Alignment.center; 18 | appWindow.title = "Json Format"; 19 | appWindow.show(); 20 | }); 21 | } 22 | 23 | Color _mainColor = Colors.blueGrey; 24 | 25 | class MyApp extends StatelessWidget { 26 | const MyApp({Key? key}) : super(key: key); 27 | 28 | // This widget is the root of your application. 29 | @override 30 | Widget build(BuildContext context) { 31 | Widget jsonTextView = Row( 32 | children: const [ 33 | JsonInputWindow(), 34 | JSONOutputWindow(), 35 | ], 36 | ); 37 | jsonTextView = Expanded(child: jsonTextView); 38 | 39 | return MaterialApp( 40 | title: 'Flutter Demo', 41 | theme: ThemeData( 42 | primarySwatch: Colors.blueGrey, 43 | ), 44 | home: Scaffold( 45 | body: WindowBorder( 46 | child: Column( 47 | children: [ 48 | _WindowTopBox(), 49 | Padding( 50 | padding: const EdgeInsets.only(top: 16), 51 | child: MainToolBarSide(), 52 | ), 53 | Divider(color: _mainColor,), 54 | jsonTextView, 55 | const SizedBox(height: 8,), 56 | BottomOutputLogToolBarView() 57 | ], 58 | ), 59 | color: Colors.blueGrey 60 | ), 61 | ), 62 | ); 63 | } 64 | } 65 | 66 | class _WindowTopBox extends StatelessWidget { 67 | @override 68 | Widget build(BuildContext context) { 69 | Widget current; 70 | 71 | current = WindowTitleBarBox( 72 | child: Row( 73 | children: [ 74 | Expanded( 75 | child: 76 | Container(color: _mainColor, child: MoveWindow(),),), 77 | _WindowButtons(), 78 | ], 79 | ), 80 | ); 81 | 82 | return current; 83 | } 84 | } 85 | 86 | class _WindowButtons extends StatelessWidget { 87 | @override 88 | Widget build(BuildContext context) { 89 | return Row( 90 | children: [ 91 | CloseWindowButton(), 92 | MinimizeWindowButton(), 93 | MaximizeWindowButton(), 94 | ], 95 | ); 96 | 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /jsonformat/lib/models/inner_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:jsonformat/models/json_manager.dart'; 2 | 3 | const String innerModelClassName = 'ReplaceClassModel'; 4 | 5 | class InnerModel { 6 | /// 名称,当为对象时,就是类型 7 | final String name; 8 | 9 | /// 类型,当类型为非对象模型时,如‘String’,那么属性只有一条为这个String 10 | InnerType type = InnerType.nil; 11 | 12 | /// 属性列表 13 | List? propertys; 14 | 15 | InnerModel(this.name, dynamic data, 16 | {String suggestClassName = innerModelClassName}) { 17 | if (data is Map) { 18 | type = InnerType.object; 19 | List propertys = []; 20 | for (var e in data.entries) { 21 | String key = e.key; 22 | dynamic value = e.value; 23 | InnerProperty property = InnerProperty(key, value, 24 | suggestClassName: suggestClassName + '_$key'); 25 | propertys.add(property); 26 | } 27 | this.propertys = propertys; 28 | } else if (data is List) { 29 | type = InnerType.list; 30 | List propertys = []; 31 | for (var e in data) { 32 | InnerProperty property = 33 | InnerProperty('', e, suggestClassName: suggestClassName); 34 | propertys.add(property); 35 | } 36 | this.propertys = propertys; 37 | } else if (data is String) { 38 | propertys = [InnerProperty('', data)]; 39 | } else if (data is num) { 40 | propertys = [InnerProperty('', data)]; 41 | } else if (data is bool) { 42 | propertys = [InnerProperty('', data)]; 43 | } else { 44 | propertys = [InnerProperty('', data)]; 45 | } 46 | } 47 | } 48 | 49 | enum InnerType { 50 | /// null 51 | nil, 52 | bool, 53 | int, 54 | double, 55 | string, 56 | list, 57 | object, 58 | } 59 | 60 | class InnerProperty { 61 | InnerType type = InnerType.nil; 62 | dynamic value; 63 | String name; 64 | bool optional; 65 | InnerModel? subModel; 66 | 67 | InnerProperty(this.name, dynamic value, 68 | {String suggestClassName = innerModelClassName, this.optional = true}) { 69 | if (value is Map) { 70 | type = InnerType.object; 71 | } else if (value is List) { 72 | type = InnerType.list; 73 | } else if (value is String) { 74 | type = InnerType.string; 75 | } else if (value is num) { 76 | num n = value; 77 | if (n.toInt() == n) { 78 | type = InnerType.int; 79 | } else { 80 | type = InnerType.double; 81 | } 82 | } else if (value is bool) { 83 | type = InnerType.bool; 84 | } else { 85 | // null 86 | type = InnerType.nil; 87 | } 88 | this.value = _parseValue(value, suggestClassName: suggestClassName); 89 | 90 | // optional suggest 91 | switch (type) { 92 | case InnerType.bool: 93 | optional = JSONManager().boolOptional; 94 | break; 95 | case InnerType.int: 96 | optional = JSONManager().numOptional; 97 | break; 98 | case InnerType.double: 99 | optional = JSONManager().numOptional; 100 | break; 101 | case InnerType.list: 102 | optional = JSONManager().arrayOptional; 103 | break; 104 | case InnerType.string: 105 | optional = JSONManager().stringOptional; 106 | break; 107 | case InnerType.object: 108 | optional = JSONManager().objectOptional; 109 | break; 110 | default: 111 | } 112 | 113 | // search sub model is exists 114 | if (type == InnerType.list) { 115 | dynamic innerItem = this.value; 116 | while (innerItem is List && innerItem.isNotEmpty) { 117 | innerItem = innerItem.first; 118 | } 119 | if (innerItem is InnerModel) { 120 | subModel = innerItem; 121 | } 122 | } else if (type == InnerType.object) { 123 | subModel = this.value; 124 | } 125 | // print("submodel--- ${subModel?.name}"); 126 | } 127 | 128 | dynamic _parseValue(dynamic value, 129 | {String suggestClassName = innerModelClassName}) { 130 | if (value is Map) { 131 | return InnerModel(suggestClassName, value, 132 | suggestClassName: suggestClassName); 133 | } else if (value is List) { 134 | List arr = value; 135 | if (arr.isNotEmpty) { 136 | dynamic first = arr.first; 137 | if (first is Map || first is List) { 138 | List values = []; 139 | for (var item in arr) { 140 | dynamic itemValue = 141 | _parseValue(item, suggestClassName: suggestClassName); 142 | values.add(itemValue); 143 | } 144 | return values; 145 | } else { 146 | return value; 147 | } 148 | } else { 149 | return value; 150 | } 151 | } else { 152 | return value; 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /jsonformat/lib/models/json_file.dart: -------------------------------------------------------------------------------- 1 | import 'package:cross_file/cross_file.dart'; 2 | import 'package:file_picker/file_picker.dart'; 3 | 4 | class JSONFile { 5 | JSONFile(this.path, {this.mimeType, this.name}); 6 | 7 | JSONFile.xfile(XFile file) 8 | : path = file.path, 9 | mimeType = file.mimeType, 10 | name = file.name; 11 | 12 | JSONFile.pickFile(PlatformFile file) 13 | : path = file.path ?? "", 14 | mimeType = null, 15 | name = file.name; 16 | 17 | final String path; 18 | final String? mimeType; 19 | String? name; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /jsonformat/lib/models/json_manager.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: your name 3 | * @Date: 2022-02-18 22:28:06 4 | * @LastEditTime: 2022-02-20 10:54:49 5 | * @LastEditors: Please set LastEditors 6 | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 | * @FilePath: /jsonformat/lib/models/json_manager.dart 8 | */ 9 | import 'dart:convert'; 10 | 11 | import 'package:flutter/material.dart'; 12 | 13 | import 'package:jsonformat/models/json_file.dart'; 14 | import 'package:jsonformat/models/model_convert.dart'; 15 | import 'output_serializer.dart'; 16 | import 'string_extension_json.dart'; 17 | import 'output_manager.dart'; 18 | import 'package:jsonformat/models/output_manager.dart'; 19 | import 'package:jsonformat/models/output_model.dart'; 20 | import 'json_repair.dart'; 21 | 22 | // dart json转换文档 23 | // https://dart.cn/guides/libraries/library-tour#dartconvert---decoding-and-encoding-json-utf-8-and-more 24 | 25 | enum JsonProperty { 26 | num, 27 | bool, 28 | string, 29 | array, 30 | map, 31 | object, 32 | } 33 | 34 | /// json管理类(单利) 35 | class JSONManager with ChangeNotifier { 36 | JSONManager._instance(); 37 | static final JSONManager _manager = JSONManager._instance(); 38 | factory JSONManager() => _manager; 39 | 40 | final FormatJSONOutputSerializer _outputSerializer = 41 | FormatJSONOutputSerializer(); 42 | final ModelConvert _convert = ModelConvert(); 43 | 44 | // json文件操作 45 | JSONFile? _file; 46 | 47 | /// 设置新文件 48 | void setFile(JSONFile? file) => _file = file; 49 | JSONFile? get file => _file; 50 | void deleteFile() => _file = null; 51 | 52 | /// 输入框中的json 53 | String? inputJSON; 54 | 55 | /// 更新数据源 56 | void reloadData() => notifyListeners(); 57 | 58 | final JSONRepair _repair = JSONRepair(); 59 | 60 | /// 是否有输入json 61 | bool get hasInputJSON { 62 | return inputJSON?.isNotEmpty ?? false; 63 | } 64 | 65 | /// 输入的是否为json格式 66 | bool get isJSON { 67 | bool hasJson = hasInputJSON; 68 | if (!hasJson) return false; 69 | return inputJSON.isJSON; 70 | } 71 | 72 | /// 自动修正JSON 73 | bool autoFixJSON = false; 74 | 75 | /// 格式化 76 | bool format() { 77 | if (inputJSON == null) return false; 78 | 79 | String? _formatJson; 80 | String? _inputJson; 81 | if (!autoFixJSON) { 82 | if (!isJSON) return false; 83 | _inputJson = inputJSON; 84 | } else { 85 | _inputJson = _fixJSON(inputJSON); 86 | } 87 | _formatJson = _outputSerializer.format(_inputJson); 88 | 89 | // 将格式化之后的数据传递给输出窗口 90 | OutputManager().inputJSON = _inputJson; 91 | OutputManager().write(_formatJson); 92 | return true; 93 | } 94 | 95 | FormatLanguage la = FormatLanguage.dart; 96 | 97 | /// 转模型 98 | bool convert() { 99 | if (JSONManager().hasInputJSON) { 100 | OutputModel? model = 101 | _convert.convert(JSONManager().la, JSONManager().inputJSON); 102 | if (model != null) { 103 | OutputManager().writeModel(model); 104 | return true; 105 | } 106 | } 107 | return false; 108 | } 109 | 110 | /// 是否可以转成模型 111 | bool get canConvertModel { 112 | if (isJSON) { 113 | dynamic json = jsonDecode(inputJSON!); 114 | if (json is Map) return true; 115 | } 116 | return false; 117 | } 118 | 119 | bool numOptional = true; 120 | bool boolOptional = true; 121 | bool stringOptional = true; 122 | bool arrayOptional = true; 123 | bool mapOptional = true; 124 | bool objectOptional = true; 125 | 126 | // 是否所有类型可选 127 | bool get allOptional => 128 | numOptional && 129 | boolOptional && 130 | stringOptional && 131 | arrayOptional && 132 | mapOptional && 133 | objectOptional; 134 | 135 | // 所有的[int]和[double]都是用[num]类型 136 | bool allNumUseNumType = true; 137 | } 138 | 139 | extension JSONHelper on JSONManager { 140 | /// 修正输入json格式 141 | String? _fixJSON(String? json) { 142 | String? fixJson = _repair.repair(json); 143 | return fixJson; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /jsonformat/lib/models/json_repair.dart: -------------------------------------------------------------------------------- 1 | import 'string_extension_json.dart'; 2 | 3 | class JSONRepair { 4 | String? repair(String? badJson) { 5 | bool isJSON = badJson.isJSON; 6 | if (isJSON) return badJson; 7 | // TODO: 8 | String? ret = badJson; 9 | 10 | return ret; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /jsonformat/lib/models/log_message.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | enum LogLevel { 4 | debug, 5 | normal, 6 | warn, 7 | error, 8 | } 9 | 10 | /// 日志输出端口 11 | class LogMessage { 12 | const LogMessage(this.message, {this.level = LogLevel.normal}); 13 | 14 | final String message; 15 | final LogLevel level; 16 | 17 | @override 18 | bool operator ==(other) { 19 | if (other is! LogMessage) { 20 | return false; 21 | } 22 | return message == other.message && level == other.level; 23 | } 24 | 25 | @override 26 | int get hashCode { 27 | var ret = 0; 28 | ret += message.hashCode; 29 | ret += level.hashCode; 30 | return ret; 31 | } 32 | } 33 | 34 | /// 日志写入类 35 | class LogManager with ChangeNotifier { 36 | LogManager._instance(); 37 | static final LogManager _manager = LogManager._instance(); 38 | factory LogManager() => _manager; 39 | 40 | /// 最近的一条日志 41 | LogMessage? lastMessage; 42 | 43 | void writeMessage(String text) { 44 | write(LogMessage(text)); 45 | } 46 | 47 | /// 写日志 48 | void write(LogMessage message) { 49 | if (lastMessage != null && lastMessage == message) { 50 | return; 51 | } 52 | lastMessage = message; 53 | updateMessageShow(); 54 | } 55 | 56 | bool hasMessage() { 57 | return lastMessage != null; 58 | } 59 | 60 | void cleanMessage() { 61 | lastMessage = null; 62 | updateMessageShow(); 63 | } 64 | 65 | void updateMessageShow() { 66 | notifyListeners(); 67 | } 68 | } 69 | 70 | class LogMessageWidget extends StatefulWidget { 71 | final String defaultMessage; 72 | 73 | const LogMessageWidget(this.defaultMessage, {Key? key}) : super(key: key); 74 | 75 | @override 76 | State createState() { 77 | return LogMessageState(); 78 | } 79 | } 80 | 81 | class LogMessageState extends State { 82 | @override 83 | Widget build(BuildContext context) { 84 | Widget current; 85 | 86 | String message = widget.defaultMessage; 87 | if (LogManager().hasMessage()) { 88 | message = LogManager().lastMessage!.message; 89 | } 90 | current = Text( 91 | message, 92 | style: const TextStyle( 93 | color: Colors.white, 94 | fontSize: 16, 95 | overflow: TextOverflow.ellipsis 96 | ), 97 | maxLines: 1, 98 | ); 99 | 100 | if (LogManager().hasMessage()) { 101 | LogMessage message = LogManager().lastMessage!; 102 | 103 | List children = [Flexible(child: current)]; 104 | if (message.level == LogLevel.warn) { 105 | children.insert(0, const Icon(Icons.warning, color: Colors.white,)); 106 | } 107 | if (message.level == LogLevel.error) { 108 | children.insert(0, const Icon(Icons.error, color: Colors.white,)); 109 | } 110 | if (children.length > 1) { 111 | children.insert(1, const SizedBox(width: 6,)); 112 | } 113 | current = Row( 114 | mainAxisAlignment: MainAxisAlignment.start, 115 | children: children 116 | ); 117 | } 118 | 119 | LogManager().addListener(() { 120 | setState(() {}); 121 | }); 122 | 123 | return current; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /jsonformat/lib/models/model_convert.dart: -------------------------------------------------------------------------------- 1 | import 'package:jsonformat/models/json_manager.dart'; 2 | 3 | import 'output_model.dart'; 4 | import 'string_extension_json.dart'; 5 | import 'dart:convert'; 6 | 7 | import 'inner_model.dart'; 8 | 9 | class ModelConvert { 10 | OutputModel? convert(FormatLanguage la, String? json) { 11 | if (!json.isJSON) return null; 12 | 13 | var data = jsonDecode(json!); 14 | 15 | OutputModel model = _convertOutput(la, data); 16 | // print(model.toString()); 17 | return model; 18 | } 19 | 20 | InnerModel? convertInnerModel(FormatLanguage la, String? json) { 21 | if (!json.isJSON) return null; 22 | 23 | var data = jsonDecode(json!); 24 | if (data is Map) { 25 | InnerModel model = InnerModel(innerModelClassName, data); 26 | return model; 27 | } else { 28 | return null; 29 | } 30 | } 31 | 32 | OutputModel _convertOutput(FormatLanguage la, dynamic data) { 33 | if (data is Map) { 34 | InnerModel model = InnerModel(innerModelClassName, data); 35 | _Reader reader = _createReader(model, la); 36 | String? header = reader.readHeader(); 37 | String impl = reader.readImpl(); 38 | return OutputModel(la, impl, header: header); 39 | } else { 40 | return OutputModel(la, data.toString()); 41 | } 42 | } 43 | 44 | _Reader _createReader(InnerModel model, FormatLanguage la) { 45 | _Reader reader; 46 | if (la == FormatLanguage.dart) { 47 | reader = _DartReader(model); 48 | } else if (la == FormatLanguage.swift) { 49 | reader = _SwiftReader(model); 50 | } else { 51 | reader = _ObjectiveCReader(model); 52 | } 53 | return reader; 54 | } 55 | } 56 | 57 | enum FormatLanguage { dart, objectiveC, swift } 58 | 59 | String languageEnumToString(FormatLanguage la) { 60 | String ret = ""; 61 | switch (la) { 62 | case FormatLanguage.dart: 63 | ret = "dart"; 64 | break; 65 | case FormatLanguage.objectiveC: 66 | ret = "OC"; 67 | break; 68 | case FormatLanguage.swift: 69 | ret = "swift"; 70 | break; 71 | } 72 | return ret; 73 | } 74 | 75 | abstract class _Reader { 76 | final InnerModel _model; 77 | final FormatLanguage _la; 78 | 79 | FormatLanguage get language => _la; 80 | 81 | _Reader(this._model, this._la); 82 | 83 | String? readHeader(); 84 | String readImpl(); 85 | } 86 | 87 | class _DartReader extends _Reader { 88 | _DartReader(InnerModel model) : super(model, FormatLanguage.dart); 89 | 90 | @override 91 | String? readHeader() => null; 92 | 93 | /// \n 94 | static String wrap = '\n'; 95 | 96 | /// \t 97 | static String space = '\t'; 98 | 99 | @override 100 | String readImpl() { 101 | String output = ''; 102 | if (_model.type == InnerType.object) { 103 | output = _parseModel(_model); 104 | } 105 | return output; 106 | } 107 | 108 | String _parseModel(InnerModel model) { 109 | String output = ''; 110 | output += 'class ${model.name} {'; 111 | // 嵌套的模型 112 | List nestModels = []; 113 | if (model.propertys != null) { 114 | for (var property in model.propertys!) { 115 | if (property.subModel != null) { 116 | nestModels.add(property.subModel!); 117 | } 118 | output += wrap; 119 | String writePro = _parseProperty(property); 120 | output += writePro; 121 | } 122 | } 123 | output += wrap * 2; 124 | // constructor api 125 | output += '${model.name}();'; 126 | // json api 127 | output += wrap * 2; 128 | output += _parseFromJsonApi(model); 129 | output += wrap * 2; 130 | output += _parseToJsonApi(model); 131 | output += wrap; 132 | output += '}'; 133 | if (nestModels.isNotEmpty) { 134 | for (var model in nestModels) { 135 | output += wrap * 2; 136 | output += _parseModel(model); 137 | } 138 | } 139 | return output; 140 | } 141 | 142 | String _parseProperty(InnerProperty property) { 143 | String output = ''; 144 | switch (property.type) { 145 | case InnerType.bool: 146 | { 147 | output += space; 148 | if (property.optional) { 149 | output += 'bool? ${property.name};'; 150 | } else { 151 | output += 'bool ${property.name} = false;'; 152 | } 153 | } 154 | break; 155 | case InnerType.int: 156 | { 157 | output += space; 158 | String _type = JSONManager().allNumUseNumType ? 'num' : 'int'; 159 | if (property.optional) { 160 | output += '$_type? ${property.name};'; 161 | } else { 162 | output += '$_type ${property.name} = 0;'; 163 | } 164 | } 165 | break; 166 | case InnerType.double: 167 | { 168 | output += space; 169 | String _type = JSONManager().allNumUseNumType ? 'num' : 'double'; 170 | if (property.optional) { 171 | output += '$_type? ${property.name};'; 172 | } else { 173 | output += '$_type ${property.name} = 0.0;'; 174 | } 175 | } 176 | break; 177 | case InnerType.string: 178 | { 179 | output += space; 180 | if (property.optional) { 181 | output += 'String? ${property.name};'; 182 | } else { 183 | output += "String ${property.name} = '';"; 184 | } 185 | } 186 | break; 187 | case InnerType.list: 188 | { 189 | output += space; 190 | List arr = property.value; 191 | String nameT = ''; 192 | if (arr.isNotEmpty) { 193 | dynamic first = arr.first; 194 | String t; 195 | if (property.subModel != null) { 196 | t = property.subModel!.name; 197 | } else { 198 | t = arr.first.runtimeType.toString(); 199 | } 200 | dynamic inner = first; 201 | while (inner is List) { 202 | t = 'List<$t>'; 203 | if (inner.isNotEmpty) { 204 | inner = inner.first; 205 | } 206 | } 207 | nameT = '<$t>'; 208 | } 209 | if (property.optional) { 210 | output += 'List$nameT? ${property.name};'; 211 | } else { 212 | output += 'List$nameT ${property.name} = [];'; 213 | } 214 | } 215 | break; 216 | case InnerType.object: 217 | { 218 | output += space; 219 | InnerModel _model = property.value; 220 | if (property.optional) { 221 | output += '${_model.name}? ${property.name};'; 222 | } else { 223 | output += "${_model.name} ${property.name} = ${_model.name}();"; 224 | } 225 | } 226 | break; 227 | case InnerType.nil: 228 | { 229 | output += space; 230 | output += "dynamic ${property.name};"; 231 | } 232 | break; 233 | default: 234 | break; 235 | } 236 | return output; 237 | } 238 | 239 | /* 240 | class MyTestModel { 241 | String? aa; 242 | int a = 0; 243 | SubModel? sub; 244 | List? ss; 245 | List>? subs; 246 | 247 | MyTestModel(); 248 | 249 | void fromJson(Map? json) { 250 | if (json == null) return; 251 | 252 | aa = json['aa']; 253 | a = json['a'] ?? 0; 254 | sub = SubModel()..fromJson(json['a']); 255 | ss = (json[ss] as List).map((e) => SubModel()..fromJson(e)).toList(); 256 | subs = (json[subs] as List) 257 | .map((e) => (e as List).map((e) => SubModel()..fromJson(e)).toList()) 258 | .toList(); 259 | } 260 | 261 | Map toJson() { 262 | return { 263 | 'aa': aa, 264 | 'a': a, 265 | 'sub': sub?.toJson(), 266 | 'ss': ss?.map((e) => e.toJson()).toList(), 267 | 'subs': subs?.map((e) => e.map((e) => e.toJson()).toList()).toList() 268 | }; 269 | } 270 | } 271 | 272 | class SubModel { 273 | void fromJson(Map? json) {} 274 | Map toJson() => {}; 275 | } 276 | */ 277 | 278 | String _parseFromJsonApi(InnerModel model) { 279 | String output = 'void fromJson(Map? json) {'; 280 | output += wrap; 281 | output += space + 'if (json == null) return;'; 282 | if (model.propertys != null) { 283 | for (var property in model.propertys!) { 284 | output += wrap; 285 | output += space; 286 | if (property.type == InnerType.object) { 287 | assert(property.subModel != null); 288 | output += 289 | "${property.name} = ${property.subModel?.name}()..fromJson(Map.from(json['${property.name}']));"; 290 | } else if (property.type == InnerType.list) { 291 | if (property.subModel != null) { 292 | List _list = property.value; 293 | if (_list.isNotEmpty) { 294 | output += 295 | "if (json['${property.name}'] != null && json['${property.name}'] is List) {"; 296 | output += wrap; 297 | output += "${property.name} = (json['${property.name}'] as List)"; 298 | output += '.map((e) => '; 299 | dynamic first = _list.first; 300 | String append = ''; 301 | while (first is List) { 302 | output += '(e as List).map((e) => '; 303 | append += ').toList()'; 304 | first = first.first; 305 | } 306 | if (first is InnerModel) { 307 | output += '${first.name}()..fromJson(e)'; 308 | } 309 | output += append; 310 | output += ').toList();'; 311 | output += wrap; 312 | output += '} else {'; 313 | output += wrap; 314 | output += "${property.name} = [];"; 315 | output += wrap; 316 | output += '}'; 317 | } 318 | } else { 319 | // 基本类型的数组 320 | // 转换方式有两种 321 | // ints = (json['ints'] as List).cast(); 322 | // ints = (json['ints'] as List).isEmpty ? [] : json['ints']; 323 | // output += "${property.name} = json['${property.name}']" + (property.optional ? '' : ' ?? ') + ';'; 324 | output += 325 | "if (json['${property.name}'] != null && json['${property.name}'] is List) {"; 326 | output += wrap; 327 | output += 328 | "${property.name} = (json['${property.name}'] as List).isEmpty ? [] : json['${property.name}'];"; 329 | output += wrap; 330 | output += '} else {'; 331 | output += wrap; 332 | output += "${property.name} = [];"; 333 | output += wrap; 334 | output += '}'; 335 | } 336 | } else { 337 | output += "${property.name} = json['${property.name}']"; 338 | if (!property.optional) { 339 | switch (property.type) { 340 | case InnerType.bool: 341 | { 342 | output += ' ?? false'; 343 | } 344 | break; 345 | case InnerType.int: 346 | case InnerType.double: 347 | { 348 | output += ' ?? 0'; 349 | } 350 | break; 351 | case InnerType.string: 352 | { 353 | output += " ?? ''"; 354 | } 355 | break; 356 | case InnerType.list: 357 | { 358 | output += ' ?? []'; 359 | } 360 | break; 361 | default: 362 | break; 363 | } 364 | } 365 | output += ';'; 366 | } 367 | } 368 | } 369 | output += wrap; 370 | output += '}'; 371 | return output; 372 | } 373 | 374 | String _parseToJsonApi(InnerModel model) { 375 | String output = 'Map toJson() {'; 376 | output += wrap; 377 | output += 'return {'; 378 | if (model.propertys != null) { 379 | for (var property in model.propertys!) { 380 | output += wrap; 381 | output += space; 382 | switch (property.type) { 383 | case InnerType.object: 384 | { 385 | output += 386 | "'${property.name}': ${property.name}${property.optional ? '?' : ''}.toJson(),"; 387 | } 388 | break; 389 | case InnerType.list: 390 | { 391 | if (property.subModel != null) { 392 | output += 393 | "'${property.name}': ${property.name}${property.optional ? '?' : ''}.map((e) => "; 394 | List arr = property.value; 395 | if (arr.isNotEmpty) { 396 | dynamic first = arr.first; 397 | String append = ''; 398 | while (first is List) { 399 | first = first.first; 400 | output += 'e.map((e) => '; 401 | append += ').toList()'; 402 | } 403 | if (first is InnerModel) { 404 | output += 'e.toJson()'; 405 | } 406 | output += append; 407 | } 408 | output += ').toList(),'; 409 | } else { 410 | output += "'${property.name}': ${property.name},"; 411 | } 412 | } 413 | break; 414 | default: 415 | { 416 | output += "'${property.name}': ${property.name},"; 417 | } 418 | break; 419 | } 420 | } 421 | output += wrap; 422 | } 423 | output += '};'; 424 | output += wrap; 425 | output += '}'; 426 | return output; 427 | } 428 | } 429 | 430 | class _SwiftReader extends _Reader { 431 | _SwiftReader(InnerModel model) : super(model, FormatLanguage.swift); 432 | 433 | @override 434 | String? readHeader() => null; 435 | 436 | @override 437 | String readImpl() { 438 | // TODO: implement readImpl 439 | throw UnimplementedError(); 440 | } 441 | } 442 | 443 | class _ObjectiveCReader extends _Reader { 444 | _ObjectiveCReader(InnerModel model) : super(model, FormatLanguage.objectiveC); 445 | 446 | @override 447 | String? readHeader() { 448 | // TODO: implement readHeader 449 | throw UnimplementedError(); 450 | } 451 | 452 | @override 453 | String readImpl() { 454 | // TODO: implement readImpl 455 | throw UnimplementedError(); 456 | } 457 | } 458 | -------------------------------------------------------------------------------- /jsonformat/lib/models/output_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:jsonformat/models/output_model.dart'; 4 | 5 | /// 输出管理 6 | class OutputManager with ChangeNotifier { 7 | OutputManager._instance(); 8 | static final OutputManager _manager = OutputManager._instance(); 9 | factory OutputManager() => _manager; 10 | 11 | String? _outputText; 12 | String? inputJSON; 13 | OutputModel? _outputModel; 14 | 15 | void write(String? output) { 16 | _outputModel = null; 17 | _outputText = output; 18 | notifyListeners(); 19 | } 20 | void writeModel(OutputModel? model) { 21 | _outputText = null; 22 | _outputModel = model; 23 | notifyListeners(); 24 | } 25 | 26 | List get readOutput { 27 | if (isJSONText) return [_outputText]; 28 | List output = [_outputModel?.impl]; 29 | if (_outputModel?.header != null) { 30 | output.insert(0, _outputModel?.header); 31 | } 32 | return output; 33 | } 34 | 35 | OutputModel? get readModel { 36 | return _outputModel; 37 | } 38 | 39 | bool get isEmpty { 40 | return _outputText == null && _outputModel == null; 41 | } 42 | 43 | bool get isJSONText { 44 | if (isEmpty) return true; 45 | if (_outputText == null) return false; 46 | return true; 47 | } 48 | } -------------------------------------------------------------------------------- /jsonformat/lib/models/output_model.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'model_convert.dart'; 3 | 4 | class OutputModel { 5 | FormatLanguage la; 6 | 7 | /// 有些语言分为头文件和实现文件,如ObjectiveC, 8 | /// 像dart和swift就没有头文件,他们只有一个实现文件 9 | String? header; 10 | String impl; 11 | 12 | OutputModel(this.la, this.impl, {this.header}); 13 | 14 | @override 15 | String toString() { 16 | String output = '============ ${languageEnumToString(la)} =========>\n'; 17 | if (header != null) { 18 | output += 'header =>\n'; 19 | output += header!; 20 | } 21 | output += '\n'; 22 | output += 'impl =>\n'; 23 | output += impl; 24 | output += '\n====================================='; 25 | return output; 26 | } 27 | } -------------------------------------------------------------------------------- /jsonformat/lib/models/output_serializer.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: your name 3 | * @Date: 2022-02-20 10:36:45 4 | * @LastEditTime: 2022-02-22 22:20:21 5 | * @LastEditors: Please set LastEditors 6 | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 | * @FilePath: /jsonformat/lib/models/output_serial.dart 8 | */ 9 | 10 | import 'dart:convert'; 11 | 12 | import 'package:flutter/material.dart'; 13 | import 'package:jsonformat/models/json_manager.dart'; 14 | import 'package:jsonformat/models/output_model.dart'; 15 | 16 | import 'string_extension_json.dart'; 17 | import 'textspan_extension.dart'; 18 | import 'model_convert.dart'; 19 | import 'inner_model.dart'; 20 | 21 | /* 22 | JSON数据类型 23 | 24 | 1. Number:整数或浮点数 25 | 2. String:字符串 26 | 3. Boolean:true 或 false 27 | 4. Array:数组包含在⽅括号[]中 28 | 5. Object:对象包含在⼤括号{}中 29 | 6. Null:空类型 30 | */ 31 | 32 | class FormatJSONOutputSerializer { 33 | final ModelConvert _convert = ModelConvert(); 34 | /* 35 | input: {"s": "hello", "i": 10} 36 | 37 | output: 38 | { 39 | "s": "hello", 40 | "i": 10 41 | } 42 | */ 43 | String? format(String? json) { 44 | if (json.isJSON == false) return null; 45 | 46 | print("========> Start format JSON:\n"); 47 | 48 | var data = jsonDecode(json!); 49 | var output = _formatData(data); 50 | 51 | print("$output\n========> End format JSON:\n"); 52 | return output; 53 | } 54 | 55 | TextSpan? formatRich(String? json) { 56 | if (json.isJSON == false) return null; 57 | 58 | var data = jsonDecode(json!); 59 | var output = _formatRichData(data); 60 | return output; 61 | } 62 | 63 | TextSpan? formatModelRich(String? json) { 64 | if (json.isJSON == false) return null; 65 | 66 | FormatLanguage la = JSONManager().la; 67 | JSONOutputStyle style = const JSONOutputStyle(); 68 | OutputModel? model = _convert.convert(la, json); 69 | if (model == null) return null; 70 | if (la == FormatLanguage.dart) { 71 | return TextSpan( 72 | text: model.impl, 73 | style: TextStyle( 74 | color: Colors.black, 75 | fontSize: style.fontSize, 76 | fontWeight: style.fontWeight, 77 | height: style.height)); 78 | } else if (la == FormatLanguage.swift) { 79 | return TextSpan( 80 | text: model.impl, 81 | style: TextStyle( 82 | color: Colors.black, 83 | fontSize: style.fontSize, 84 | fontWeight: style.fontWeight, 85 | height: style.height)); 86 | } else if (la == FormatLanguage.objectiveC) { 87 | return TextSpan( 88 | text: model.header, 89 | style: TextStyle( 90 | color: Colors.black, 91 | fontSize: style.fontSize, 92 | fontWeight: style.fontWeight, 93 | height: style.height)); 94 | } 95 | 96 | // InnerModel? innerModel = _convert.convertInnerModel(JSONManager().la, json); 97 | // if (innerModel == null) return null; 98 | 99 | // _RichFormater? formater; 100 | // if (la == FormatLanguage.dart) { 101 | // formater = _DartRichFormater(innerModel); 102 | // } else if (la == FormatLanguage.swift) { 103 | // formater = _SwiftRichFormater(innerModel); 104 | // } else if (la == FormatLanguage.objectiveC) { 105 | // formater = _ObjectiveCRichFormater(innerModel); 106 | // } 107 | // return formater?.readTextSpan(); 108 | } 109 | } 110 | 111 | String _lineHeadSpace = " "; 112 | 113 | extension _FormatRich on FormatJSONOutputSerializer { 114 | /// json格式化输出 115 | String _formatData(dynamic data, {String box = '', String space = ''}) { 116 | if (data is Map) { 117 | box += "{"; 118 | String endSpace = space; 119 | space += _lineHeadSpace; 120 | var keys = data.keys.toList(); 121 | for (int i = 0; i < data.length; i++) { 122 | box += "\n"; 123 | var key = keys[i]; 124 | if (i == data.length - 1) { 125 | box += space + "\"$key\": " + _formatData(data[key], space: space); 126 | } else { 127 | box += 128 | space + "\"$key\": " + _formatData(data[key], space: space) + ","; 129 | } 130 | } 131 | box += "\n"; 132 | box += endSpace + "}"; 133 | } else if (data is List) { 134 | box += "["; 135 | String endSpace = space; 136 | space += _lineHeadSpace; 137 | for (int i = 0; i < data.length; i++) { 138 | box += "\n"; 139 | var e = data[i]; 140 | if (i == data.length - 1) { 141 | box += space + _formatData(e, space: space); 142 | } else { 143 | box += space + _formatData(e, space: space) + ","; 144 | } 145 | } 146 | box += "\n"; 147 | box += endSpace + "]"; 148 | } else if (data is String) { 149 | box += "\"$data\""; 150 | } else if (data is num) { 151 | box += "$data"; 152 | } else if (data is bool) { 153 | box += "$data"; 154 | } else { 155 | box += "null"; 156 | } 157 | return box; 158 | } 159 | 160 | TextSpan _formatRichData(dynamic data, 161 | {TextSpan box = const TextSpan(), 162 | String space = '', 163 | JSONOutputStyle style = const JSONOutputStyle()}) { 164 | TextStyle spaceStyle = TextStyle( 165 | fontSize: style.fontSize, 166 | fontWeight: style.fontWeight, 167 | height: style.height); 168 | if (data is Map) { 169 | box += TextSpan( 170 | text: "{", 171 | style: TextStyle( 172 | color: style.braceColor, 173 | fontSize: style.fontSize, 174 | fontWeight: style.fontWeight, 175 | height: style.height)); 176 | String endSpace = space; 177 | space += _lineHeadSpace; 178 | var keys = data.keys.toList(); 179 | for (int i = 0; i < data.length; i++) { 180 | box = box.appendString('\n'); 181 | var key = keys[i]; 182 | TextSpan append = TextSpan(text: space, style: spaceStyle) + 183 | TextSpan( 184 | text: "\"$key\"", 185 | style: TextStyle( 186 | color: style.keyColor, 187 | fontSize: style.fontSize, 188 | fontWeight: style.fontWeight, 189 | height: style.height)) + 190 | TextSpan( 191 | text: ": ", 192 | style: TextStyle( 193 | color: style.colonColor, 194 | fontSize: style.fontSize, 195 | fontWeight: style.fontWeight, 196 | height: style.height)) + 197 | _formatRichData(data[key], space: space); 198 | if (i == data.length - 1) { 199 | box += append; 200 | } else { 201 | box += append + 202 | TextSpan( 203 | text: ",", 204 | style: TextStyle( 205 | color: style.commaColor, 206 | fontSize: style.fontSize, 207 | fontWeight: style.fontWeight, 208 | height: style.height)); 209 | } 210 | } 211 | box = box.appendString('\n'); 212 | box += TextSpan( 213 | text: endSpace + "}", 214 | style: TextStyle( 215 | color: style.braceColor, 216 | fontSize: style.fontSize, 217 | fontWeight: style.fontWeight, 218 | height: style.height)); 219 | } else if (data is List) { 220 | box += TextSpan( 221 | text: "[", 222 | style: TextStyle( 223 | color: style.squareBracketsColor, 224 | fontSize: style.fontSize, 225 | fontWeight: style.fontWeight, 226 | height: style.height)); 227 | String endSpace = space; 228 | space += _lineHeadSpace; 229 | for (int i = 0; i < data.length; i++) { 230 | box = box.appendString('\n'); 231 | var e = data[i]; 232 | if (i == data.length - 1) { 233 | box += TextSpan(text: space, style: spaceStyle) + 234 | _formatRichData(e, space: space); 235 | } else { 236 | box += TextSpan(text: space, style: spaceStyle) + 237 | _formatRichData(e, space: space) + 238 | TextSpan( 239 | text: ",", 240 | style: TextStyle( 241 | color: style.commaColor, 242 | fontSize: style.fontSize, 243 | fontWeight: style.fontWeight, 244 | height: style.height)); 245 | } 246 | } 247 | box = box.appendString('\n'); 248 | box += TextSpan( 249 | text: endSpace + "]", 250 | style: TextStyle( 251 | color: style.squareBracketsColor, 252 | fontSize: style.fontSize, 253 | fontWeight: style.fontWeight, 254 | height: style.height)); 255 | } else if (data is String) { 256 | box += TextSpan( 257 | text: "\"$data\"", 258 | style: TextStyle( 259 | color: style.stringColor, 260 | fontSize: style.fontSize, 261 | fontWeight: style.fontWeight, 262 | height: style.height)); 263 | } else if (data is num) { 264 | box += TextSpan( 265 | text: "$data", 266 | style: TextStyle( 267 | color: style.numColor, 268 | fontSize: style.fontSize, 269 | fontWeight: style.fontWeight, 270 | height: style.height)); 271 | } else if (data is bool) { 272 | box += TextSpan( 273 | text: "$data", 274 | style: TextStyle( 275 | color: style.boolColor, 276 | fontSize: style.fontSize, 277 | fontWeight: style.fontWeight, 278 | height: style.height)); 279 | } else { 280 | box += TextSpan( 281 | text: "null", 282 | style: TextStyle( 283 | color: style.nullColor, 284 | fontSize: style.fontSize, 285 | fontWeight: style.fontWeight, 286 | height: style.height)); 287 | } 288 | return box; 289 | } 290 | } 291 | 292 | class JSONOutputStyle { 293 | const JSONOutputStyle( 294 | {this.commaColor = Colors.black, 295 | this.squareBracketsColor = Colors.black, 296 | this.braceColor = Colors.black, 297 | this.colonColor = Colors.black, 298 | this.keyColor = Colors.pink, 299 | this.stringColor = Colors.green, 300 | this.boolColor = Colors.orange, 301 | this.numColor = Colors.blue, 302 | this.nullColor = Colors.brown, 303 | this.fontSize = 18, 304 | this.fontWeight = FontWeight.w400, 305 | this.quotationColor = Colors.black, 306 | this.height = 1.2}); 307 | 308 | /// 字体大小 309 | final double fontSize; 310 | 311 | /// 字体粗细 312 | final FontWeight fontWeight; 313 | 314 | /// 行高 315 | final double height; 316 | 317 | /// 引号颜色 318 | final Color quotationColor; 319 | 320 | /// 逗号颜色 321 | final Color commaColor; 322 | 323 | /// 中括号颜色 324 | final Color squareBracketsColor; 325 | 326 | /// 花括号颜色 327 | final Color braceColor; 328 | 329 | /// 冒号颜色 330 | final Color colonColor; 331 | 332 | /// 字典key的颜色 333 | final Color keyColor; 334 | 335 | /// 字符串的颜色 336 | final Color stringColor; 337 | 338 | /// 布尔值的颜色 339 | final Color boolColor; 340 | 341 | /// 数值的颜色 342 | final Color numColor; 343 | 344 | /// null的颜色 345 | final Color nullColor; 346 | } 347 | 348 | abstract class _RichFormater { 349 | final InnerModel _model; 350 | final FormatLanguage _la; 351 | 352 | _RichFormater(this._model, this._la); 353 | 354 | TextSpan? readTextSpan(); 355 | } 356 | 357 | class _DartRichFormater extends _RichFormater { 358 | _DartRichFormater(InnerModel model) : super(model, FormatLanguage.dart); 359 | 360 | @override 361 | TextSpan? readTextSpan() { 362 | // TODO: implement readTextSpan 363 | throw UnimplementedError(); 364 | } 365 | } 366 | 367 | class _SwiftRichFormater extends _RichFormater { 368 | _SwiftRichFormater(InnerModel model) : super(model, FormatLanguage.swift); 369 | 370 | @override 371 | TextSpan? readTextSpan() { 372 | // TODO: implement readTextSpan 373 | throw UnimplementedError(); 374 | } 375 | } 376 | 377 | class _ObjectiveCRichFormater extends _RichFormater { 378 | _ObjectiveCRichFormater(InnerModel model) 379 | : super(model, FormatLanguage.objectiveC); 380 | 381 | @override 382 | TextSpan? readTextSpan() { 383 | // TODO: implement readTextSpan 384 | throw UnimplementedError(); 385 | } 386 | } 387 | -------------------------------------------------------------------------------- /jsonformat/lib/models/string_extension_json.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: your name 3 | * @Date: 2022-02-20 10:49:06 4 | * @LastEditTime: 2022-02-20 10:51:09 5 | * @LastEditors: Please set LastEditors 6 | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 | * @FilePath: /jsonformat/lib/models/string_extension_json.dart 8 | */ 9 | 10 | import 'dart:convert'; 11 | 12 | extension JSONHelper on String? { 13 | /// 输入字符串是否是JSON 14 | bool get isJSON { 15 | if (this == null) return false; 16 | try { 17 | jsonDecode(this!); 18 | } catch (error) { 19 | print("input is not json: ${error.toString()}"); 20 | return false; 21 | } 22 | return true; 23 | } 24 | 25 | String? get first { 26 | if (this == null) return null; 27 | if (this!.isEmpty) return ""; 28 | return this![0]; 29 | } 30 | } -------------------------------------------------------------------------------- /jsonformat/lib/models/textspan_extension.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'output_serializer.dart'; 4 | 5 | extension TextSpanHelper on TextSpan { 6 | TextSpan operator +(TextSpan text) { 7 | return TextSpan(children: [this, text]); 8 | } 9 | 10 | TextSpan appendString(String? text) { 11 | if (text == null) return this; 12 | return TextSpan(children: [this, TextSpan(text: text, style: style)]); 13 | } 14 | } -------------------------------------------------------------------------------- /jsonformat/lib/views/filedrag_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:io'; 3 | 4 | import 'package:desktop_drop/desktop_drop.dart'; 5 | import 'package:cross_file/cross_file.dart'; 6 | import 'package:file_picker/file_picker.dart'; 7 | 8 | import 'package:jsonformat/models/json_file.dart'; 9 | import 'package:jsonformat/models/json_manager.dart'; 10 | import 'package:jsonformat/models/log_message.dart'; 11 | import 'main_style_button.dart'; 12 | 13 | /// 文件拖拽区域。拖拽窗口+文件操作的三个按钮 14 | class FileDargView extends StatefulWidget { 15 | bool mouseHover = false; 16 | 17 | @override 18 | State createState() { 19 | return _FileDargViewState(); 20 | } 21 | } 22 | 23 | class _FileDargViewState extends State { 24 | Future readFile(JSONFile? jsonFile) async { 25 | if (jsonFile == null) return null; 26 | try { 27 | File file = File(jsonFile.path); 28 | return await file.readAsString(); 29 | } catch (error) { 30 | if (error.toString().isEmpty) { 31 | LogManager().write(const LogMessage('文件解析错误', level: LogLevel.error)); 32 | } else { 33 | LogManager().write(LogMessage(error.toString(), level: LogLevel.error)); 34 | } 35 | return null; 36 | } 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | Widget current; 42 | 43 | bool existFile = JSONManager().file != null; 44 | // 存在文件时,读取文件内容 45 | if (existFile) { 46 | readFile(JSONManager().file).then((value) { 47 | // print("读取文件内容--->\n$value"); 48 | JSONManager().inputJSON = value; 49 | // 文件读取完毕,需要刷新内容 50 | JSONManager().reloadData(); 51 | }); 52 | } 53 | 54 | TextStyle textStyle = const TextStyle( 55 | color: Colors.white, 56 | fontSize: 12, 57 | ); 58 | 59 | Widget space = const SizedBox( 60 | height: 7, 61 | ); 62 | // 选择文件按钮 63 | Widget selectFileButton = MainStyleButton( 64 | onPressed: () { 65 | Future result = FilePicker.platform.pickFiles(); 66 | result.then((value) { 67 | if (value != null && value.count > 0) { 68 | JSONFile file = JSONFile.pickFile(value.files.first); 69 | JSONManager().setFile(file); 70 | setState(() {}); 71 | } 72 | }); 73 | }, 74 | child: Text( 75 | '选择文件', 76 | style: textStyle, 77 | )); 78 | 79 | // 重新读取文件内容 80 | Widget resetButton = MainStyleButton( 81 | onPressed: () { 82 | if (JSONManager().file != null) { 83 | readFile(JSONManager().file).then((value) { 84 | JSONManager().inputJSON = value; 85 | // 文件读取完毕,需要刷新内容 86 | JSONManager().reloadData(); 87 | LogManager().writeMessage('重新读取数据'); 88 | }); 89 | } 90 | }, 91 | child: Text( 92 | '重新读取', 93 | style: textStyle, 94 | ), 95 | disabled: !existFile, 96 | ); 97 | 98 | // 删除 99 | Widget deleteButton = MainStyleButton( 100 | onPressed: () { 101 | setState(() { 102 | JSONManager().deleteFile(); 103 | }); 104 | }, 105 | child: Text( 106 | '删除文件', 107 | style: textStyle, 108 | ), 109 | disabled: !existFile, 110 | ); 111 | 112 | List buttons = [ 113 | selectFileButton, 114 | space, 115 | resetButton, 116 | space, 117 | deleteButton 118 | ]; 119 | 120 | current = Column( 121 | children: buttons, 122 | ); 123 | 124 | double size = 100; 125 | 126 | Widget fileDectorIcon; 127 | 128 | if (existFile) { 129 | fileDectorIcon = Image.asset('assets/json_icon.jpeg'); 130 | } else { 131 | fileDectorIcon = const Icon( 132 | Icons.undo, 133 | size: 30, 134 | ); 135 | 136 | fileDectorIcon = Column( 137 | mainAxisAlignment: MainAxisAlignment.center, 138 | children: [ 139 | fileDectorIcon, 140 | const Text( 141 | '将文件拖入此处', 142 | style: TextStyle(fontSize: 12), 143 | ) 144 | ], 145 | ); 146 | } 147 | 148 | fileDectorIcon = Container( 149 | child: fileDectorIcon, 150 | width: size, 151 | height: size, 152 | decoration: BoxDecoration( 153 | color: widget.mouseHover ? Colors.black12 : const Color(0xFFFFFAF0), 154 | border: Border.all(width: 2, color: Colors.blueGrey)), 155 | ); 156 | 157 | fileDectorIcon = DropTarget( 158 | child: fileDectorIcon, 159 | onDragDone: (detail) { 160 | // List 161 | List files = detail.files; 162 | if (files.isEmpty) return; 163 | // 读取第一个文件 164 | XFile file = files.first; 165 | // print("file >>>> \npath: ${file.path}\nmimeType: ${file.mimeType}\nname: ${file.name}\nlength: ${file.length()}"); 166 | 167 | JSONFile json = JSONFile.xfile(file); 168 | JSONManager().setFile(json); 169 | 170 | setState(() {}); 171 | }, 172 | onDragEntered: (detail) { 173 | setState(() { 174 | widget.mouseHover = true; 175 | }); 176 | }, 177 | onDragExited: (detail) { 178 | setState(() { 179 | widget.mouseHover = false; 180 | }); 181 | }, 182 | ); 183 | 184 | current = Row( 185 | mainAxisAlignment: MainAxisAlignment.spaceAround, 186 | children: [ 187 | fileDectorIcon, 188 | const SizedBox( 189 | width: 20, 190 | ), 191 | current 192 | ], 193 | ); 194 | 195 | Widget fileName = Text(JSONManager().file?.name ?? '当前没有文件'); 196 | 197 | fileName = SizedBox( 198 | height: 18, 199 | child: fileName, 200 | ); 201 | 202 | fileName = Padding( 203 | padding: const EdgeInsets.only(left: 10), 204 | child: fileName, 205 | ); 206 | 207 | current = Column( 208 | crossAxisAlignment: CrossAxisAlignment.start, 209 | children: [ 210 | current, 211 | const SizedBox( 212 | height: 8, 213 | ), 214 | fileName 215 | ], 216 | ); 217 | 218 | return current; 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /jsonformat/lib/views/json_input_window.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: your name 3 | * @Date: 2022-02-21 22:11:31 4 | * @LastEditTime: 2022-02-22 22:51:32 5 | * @LastEditors: Please set LastEditors 6 | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 | * @FilePath: /flutter_json_format/jsonformat/lib/views/json_input_window.dart 8 | */ 9 | import 'dart:ui'; 10 | 11 | import 'package:flutter/material.dart'; 12 | 13 | import 'package:jsonformat/models/json_manager.dart'; 14 | 15 | /// Json输入框 16 | class JsonInputWindow extends StatelessWidget { 17 | const JsonInputWindow({Key? key}) : super(key: key); 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | var controller = TextEditingController(); 22 | controller.addListener(() { 23 | ParagraphBuilder pb = ParagraphBuilder(ParagraphStyle())..addText(controller.text); 24 | 25 | pb.addText(controller.text); 26 | 27 | List lines = pb.build().computeLineMetrics(); 28 | 29 | 30 | print(lines.length); 31 | JSONManager().inputJSON = controller.text; 32 | }); 33 | JSONManager().addListener(() { 34 | if (JSONManager().inputJSON != null) { 35 | controller.text = JSONManager().inputJSON!; 36 | } 37 | }); 38 | 39 | // json 输入框 40 | Widget current = TextField( 41 | controller: controller, 42 | keyboardType: TextInputType.multiline, 43 | maxLines: 999, 44 | decoration: const InputDecoration( 45 | border: OutlineInputBorder(), contentPadding: EdgeInsets.all(10)), 46 | ); 47 | 48 | current = Container( 49 | padding: const EdgeInsets.only(left: 16, bottom: 0, right: 8), 50 | child: current, 51 | ); 52 | 53 | current = Expanded(child: current); 54 | 55 | return current; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /jsonformat/lib/views/json_output_window.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: your name 3 | * @Date: 2022-02-18 22:28:06 4 | * @LastEditTime: 2022-02-20 11:14:48 5 | * @LastEditors: Please set LastEditors 6 | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 | * @FilePath: /jsonformat/lib/views/json_format_output_window.dart 8 | */ 9 | import 'package:flutter/material.dart'; 10 | 11 | import 'package:jsonformat/models/output_manager.dart'; 12 | import 'rich_textediting_controller.dart'; 13 | 14 | class JSONOutputWindow extends StatelessWidget { 15 | const JSONOutputWindow({Key? key}) : super(key: key); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | var controller = RichTextEditingController(); 20 | 21 | OutputManager().addListener(() { 22 | if (OutputManager().readOutput.isNotEmpty) { 23 | String text = OutputManager().readOutput.first ?? ""; 24 | controller.text = text; 25 | } 26 | }); 27 | 28 | Widget current = TextField( 29 | controller: controller, 30 | readOnly: true, 31 | keyboardType: TextInputType.multiline, 32 | maxLines: 999, 33 | decoration: const InputDecoration( 34 | border: OutlineInputBorder(), contentPadding: EdgeInsets.all(10)), 35 | ); 36 | 37 | current = Container( 38 | padding: const EdgeInsets.only(left: 8, bottom: 0, right: 16), 39 | child: current, 40 | ); 41 | 42 | current = Expanded(child: current); 43 | 44 | return current; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jsonformat/lib/views/main_style_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class MainStyleButton extends StatelessWidget { 4 | const MainStyleButton({ 5 | Key? key, 6 | this.onPressed, 7 | this.child, 8 | this.disabled = false} 9 | ) : super(key: key); 10 | 11 | final VoidCallback? onPressed; 12 | 13 | final Widget? child; 14 | 15 | final bool disabled; 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | 20 | ButtonStyle? style; 21 | 22 | style = ButtonStyle( 23 | backgroundColor: MaterialStateProperty.all(disabled ? Colors.black12 : Colors.blueGrey) 24 | ); 25 | 26 | return ElevatedButton( 27 | onPressed: disabled ? null : onPressed, 28 | child: child, 29 | style: style, 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jsonformat/lib/views/main_toolbar_window.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/gestures.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'package:jsonformat/models/json_manager.dart'; 5 | import 'package:jsonformat/views/filedrag_view.dart'; 6 | import 'package:jsonformat/views/property_wrap_item_widget.dart'; 7 | import 'main_style_button.dart'; 8 | import 'package:jsonformat/models/log_message.dart'; 9 | import 'package:jsonformat/models/model_convert.dart'; 10 | 11 | import 'package:jsonformat/models/json_file.dart'; 12 | 13 | /// 右侧工具菜单栏 14 | class MainToolBarSide extends StatelessWidget { 15 | /// 自动修复指json格式不正确时,sdk将根据json格式自动为其补偿确实的内容,如“”,{}等 16 | bool autoFix = false; 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | Widget current; 21 | 22 | // 工具栏高度 23 | double height = 180; 24 | 25 | // 文件选择区域 26 | current = FileDargView(); 27 | 28 | // 分割线 29 | Widget seperateLine = Container( 30 | color: Colors.black26, 31 | width: 1, 32 | height: height - 10, 33 | ); 34 | 35 | TextStyle textStyle = const TextStyle( 36 | color: Colors.white, 37 | fontSize: 15, 38 | ); 39 | 40 | Widget space = const SizedBox( 41 | height: 10, 42 | ); 43 | 44 | // 检测是否为JSON格式 45 | Widget dectorJSONButton = MainStyleButton( 46 | onPressed: () { 47 | bool hasJSON = JSONManager().hasInputJSON; 48 | if (hasJSON) { 49 | bool isJSON = JSONManager().isJSON; 50 | if (isJSON) { 51 | LogManager().writeMessage('JSON格式正确'); 52 | } else { 53 | LogManager() 54 | .write(const LogMessage('JSON格式不正确', level: LogLevel.error)); 55 | } 56 | } else { 57 | LogManager().writeMessage('没有任何JSON输入'); 58 | } 59 | }, 60 | child: Text( 61 | 'JSON探测', 62 | style: textStyle, 63 | )); 64 | 65 | // 格式化 66 | Widget formatButton = MainStyleButton( 67 | onPressed: () { 68 | bool formatSuccess = JSONManager().format(); 69 | formatSuccess 70 | ? LogManager().writeMessage("格式化成功") 71 | : LogManager() 72 | .write(const LogMessage("格式化失败", level: LogLevel.error)); 73 | }, 74 | child: Text( 75 | '格式化', 76 | style: textStyle, 77 | )); 78 | 79 | Widget format = Row( 80 | children: [ 81 | formatButton, 82 | const SizedBox( 83 | width: 10, 84 | ), 85 | _JSONFormatFixView(autoFix), 86 | ], 87 | ); 88 | 89 | // 转模型 90 | _DropDownMenu menu = _DropDownMenu(JSONManager().la); 91 | Widget convertButton = MainStyleButton( 92 | onPressed: () { 93 | if (JSONManager().canConvertModel == false) { 94 | LogManager().write(const LogMessage('不能转成模型,请检查输入是否为空或非Map类型', 95 | level: LogLevel.warn)); 96 | } else { 97 | JSONManager().la = menu.la; 98 | bool ret = JSONManager().convert(); 99 | if (ret) { 100 | LogManager().writeMessage( 101 | '${languageEnumToString(JSONManager().la)} 转换成功'); 102 | } else { 103 | LogManager() 104 | .write(const LogMessage('转换失败', level: LogLevel.error)); 105 | } 106 | } 107 | }, 108 | child: Text( 109 | "转模型", 110 | style: textStyle, 111 | )); 112 | 113 | Widget convert = Row( 114 | children: [ 115 | convertButton, 116 | const SizedBox( 117 | width: 10, 118 | ), 119 | menu 120 | ], 121 | ); 122 | 123 | // 可选类型选择 124 | Widget optionalWidgets = Wrap( 125 | spacing: 8, 126 | runSpacing: 8, 127 | children: [ 128 | PropertyWrapItemWidget(JsonProperty.num), 129 | PropertyWrapItemWidget(JsonProperty.bool), 130 | PropertyWrapItemWidget(JsonProperty.string), 131 | PropertyWrapItemWidget(JsonProperty.array), 132 | PropertyWrapItemWidget(JsonProperty.map), 133 | PropertyWrapItemWidget(JsonProperty.object), 134 | ], 135 | ); 136 | optionalWidgets = Container( 137 | child: optionalWidgets, 138 | padding: const EdgeInsets.only(top: 10), 139 | ); 140 | 141 | Widget buttons = Column( 142 | crossAxisAlignment: CrossAxisAlignment.start, 143 | children: [ 144 | dectorJSONButton, 145 | const SizedBox( 146 | height: 20, 147 | ), 148 | format, 149 | space, 150 | convert, 151 | optionalWidgets 152 | ], 153 | ); 154 | 155 | buttons = Padding( 156 | padding: const EdgeInsets.only(left: 10), 157 | child: buttons, 158 | ); 159 | 160 | current = Row( 161 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 162 | crossAxisAlignment: CrossAxisAlignment.start, 163 | children: [ 164 | // 左侧的按钮 165 | buttons, 166 | const SizedBox( 167 | width: 20, 168 | ), 169 | // 中间的分割线 170 | seperateLine, 171 | const SizedBox( 172 | width: 10, 173 | ), 174 | // 右侧的文件拖拽 175 | current 176 | ], 177 | ); 178 | 179 | current = SizedBox( 180 | height: height, 181 | child: Container( 182 | child: current, 183 | ), 184 | ); 185 | return current; 186 | } 187 | } 188 | 189 | class _JSONFormatFixView extends StatefulWidget { 190 | bool autoFix = false; 191 | bool showTip = false; 192 | 193 | _JSONFormatFixView(this.autoFix); 194 | 195 | @override 196 | State createState() { 197 | return _JSONFormatFixState(); 198 | } 199 | } 200 | 201 | class _JSONFormatFixState extends State<_JSONFormatFixView> { 202 | OverlayEntry? overlay; 203 | 204 | void showTip(BuildContext context, PointerHoverEvent? event) { 205 | Widget entry = const Text( 206 | '自动修正指输入的JSON格式不正确时,工具将根据正确的JSON格式自动补全。如“”、{}、:等,或移除多余字符。', 207 | style: TextStyle(fontSize: 14, color: Colors.black), 208 | ); 209 | 210 | entry = Material( 211 | child: entry, 212 | ); 213 | 214 | entry = Container( 215 | child: entry, 216 | width: 300, 217 | padding: const EdgeInsets.all(10), 218 | decoration: const BoxDecoration( 219 | color: Colors.white, 220 | borderRadius: BorderRadius.all(Radius.circular(8)), 221 | boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 20.0)]), 222 | ); 223 | 224 | entry = Positioned( 225 | child: entry, 226 | left: 20, 227 | top: 130, 228 | ); 229 | 230 | OverlayEntry overlay = OverlayEntry( 231 | builder: (_) { 232 | return entry; 233 | }, 234 | ); 235 | Overlay.of(context)?.insert(overlay); 236 | 237 | this.overlay = overlay; 238 | } 239 | 240 | @override 241 | Widget build(BuildContext context) { 242 | Widget box = Checkbox( 243 | value: widget.autoFix, 244 | onChanged: (value) { 245 | setState(() { 246 | widget.autoFix = !widget.autoFix; 247 | JSONManager().autoFixJSON = widget.autoFix; 248 | }); 249 | }); 250 | 251 | Widget space = const SizedBox( 252 | width: 2, 253 | ); 254 | 255 | Widget tip = Row( 256 | children: [ 257 | const Text('自动修正'), 258 | space, 259 | const Icon( 260 | Icons.help, 261 | size: 18, 262 | ), 263 | ], 264 | ); 265 | 266 | // tip = Listener( 267 | // child: tip, 268 | // onPointerHover: (event) { 269 | // // print(event); 270 | 271 | // },); 272 | 273 | tip = InkWell( 274 | child: tip, 275 | hoverColor: Colors.white, 276 | highlightColor: Colors.white, 277 | splashColor: Colors.white, 278 | onHover: (value) { 279 | bool needChangeState = widget.showTip != value; 280 | if (needChangeState) { 281 | if (value) { 282 | // 鼠标在tip上,显示提示 283 | showTip(context, null); 284 | } else { 285 | overlay?.remove(); 286 | } 287 | } 288 | widget.showTip = value; 289 | }, 290 | onTap: () {}, 291 | ); 292 | 293 | box = Row( 294 | children: [box, space, tip], 295 | ); 296 | 297 | return box; 298 | } 299 | } 300 | 301 | // 下拉弹窗选择语言 302 | class _DropDownMenu extends StatefulWidget { 303 | FormatLanguage la; 304 | 305 | _DropDownMenu(this.la); 306 | 307 | @override 308 | State createState() { 309 | return _DropDownMenuState(); 310 | } 311 | } 312 | 313 | class _DropDownMenuState extends State<_DropDownMenu> { 314 | @override 315 | Widget build(BuildContext context) { 316 | Widget dropDownMenu = DropdownButton( 317 | hint: Text(languageEnumToString(widget.la)), 318 | style: const TextStyle(color: Colors.black, fontSize: 14), 319 | value: widget.la, 320 | borderRadius: BorderRadius.circular(8), 321 | items: [ 322 | DropdownMenuItem( 323 | child: const Text('Dart'), 324 | value: FormatLanguage.dart, 325 | enabled: widget.la != FormatLanguage.dart, 326 | ), 327 | // DropdownMenuItem( 328 | // child: const Text('ObjectiveC'), 329 | // value: FormatLanguage.objectiveC, 330 | // enabled: widget.la != FormatLanguage.objectiveC, 331 | // ), 332 | // DropdownMenuItem( 333 | // child: const Text('Swift'), 334 | // value: FormatLanguage.swift, 335 | // enabled: widget.la != FormatLanguage.swift, 336 | // ), 337 | ], 338 | onChanged: (la) { 339 | setState(() { 340 | widget.la = la as FormatLanguage; 341 | }); 342 | }); 343 | return dropDownMenu; 344 | } 345 | } 346 | -------------------------------------------------------------------------------- /jsonformat/lib/views/output_toolbar_view.dart: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: your name 3 | * @Date: 2022-02-18 22:28:06 4 | * @LastEditTime: 2022-02-22 22:23:46 5 | * @LastEditors: your name 6 | * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE 7 | * @FilePath: /flutter_json_format/jsonformat/lib/views/output_toolbar_view.dart 8 | */ 9 | import 'package:flutter/material.dart'; 10 | import 'package:flutter/services.dart'; 11 | import 'package:jsonformat/models/json_manager.dart'; 12 | import 'package:jsonformat/models/model_convert.dart'; 13 | import 'package:jsonformat/models/output_model.dart'; 14 | import 'dart:io'; 15 | 16 | import 'package:path_provider/path_provider.dart'; 17 | 18 | import 'main_style_button.dart'; 19 | import 'package:jsonformat/models/log_message.dart'; 20 | import 'package:jsonformat/models/output_manager.dart'; 21 | 22 | class BottomOutputLogToolBarView extends StatelessWidget { 23 | const BottomOutputLogToolBarView({Key? key}) : super(key: key); 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | Widget current; 28 | 29 | //日志输出 30 | Widget log = const LogMessageWidget('日志输出'); 31 | 32 | log = Padding( 33 | padding: const EdgeInsets.only(left: 16, right: 0), 34 | child: log, 35 | ); 36 | 37 | log = Flexible(child: log); 38 | 39 | // 按钮模块 40 | TextStyle textStyle = const TextStyle( 41 | color: Colors.white, 42 | fontSize: 14, 43 | ); 44 | Widget copyButton = MainStyleButton( 45 | onPressed: () { 46 | if (OutputManager().isEmpty) return; 47 | List texts = OutputManager().readOutput; 48 | String copyText = ''; 49 | bool added = false; 50 | for (var text in texts) { 51 | if (added) copyText += '\n'; 52 | if (text != null) { 53 | copyText += text; 54 | added = true; 55 | } 56 | } 57 | Clipboard.setData(ClipboardData(text: copyText)); 58 | LogManager().writeMessage('复制成功'); 59 | }, 60 | child: Text( 61 | '复制', 62 | style: textStyle, 63 | )); 64 | Widget exportButton = MainStyleButton( 65 | onPressed: () async { 66 | if (OutputManager().isEmpty) { 67 | LogManager() 68 | .write(const LogMessage('当前没有输出', level: LogLevel.warn)); 69 | return; 70 | } 71 | Directory? downloadDir = await getDownloadsDirectory(); 72 | if (downloadDir != null) { 73 | String createDirPath = downloadDir.path; 74 | // print("path= ${createDirPath}"); 75 | if (OutputManager().isJSONText) { 76 | writeJson(createDirPath, OutputManager().readOutput.first ?? ''); 77 | } else { 78 | writeModel(createDirPath, OutputManager().readModel); 79 | } 80 | } 81 | }, 82 | child: Text( 83 | '导出', 84 | style: textStyle, 85 | )); 86 | 87 | List buttons = [ 88 | copyButton, 89 | const SizedBox( 90 | width: 12, 91 | ), 92 | exportButton, 93 | ]; 94 | 95 | Widget buttonsWidget = Row( 96 | children: buttons, 97 | ); 98 | 99 | buttonsWidget = Padding( 100 | padding: const EdgeInsets.only(right: 16, left: 16), 101 | child: buttonsWidget, 102 | ); 103 | 104 | current = Row( 105 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 106 | children: [log, buttonsWidget], 107 | ); 108 | 109 | current = Container( 110 | color: Colors.orangeAccent[200], 111 | child: current, 112 | ); 113 | 114 | current = SizedBox( 115 | height: 35, 116 | child: current, 117 | ); 118 | return current; 119 | } 120 | 121 | void writeJson(String saveDirPath, String json) async { 122 | File file = File(saveDirPath + '/my_format_json.json'); 123 | try { 124 | bool exists = await file.exists(); 125 | if (!exists) { 126 | // print("文件不存在,开始创建文件"); 127 | file = await file.create(); 128 | } 129 | file.writeAsString(json); 130 | LogManager().write(LogMessage("文件已写入 $saveDirPath")); 131 | } catch (error) { 132 | print("创建文件失败: ${error.toString()}"); 133 | LogManager().write(LogMessage(error.toString(), level: LogLevel.error)); 134 | } 135 | } 136 | 137 | void writeModel(String saveDirPath, OutputModel? model) async { 138 | if (model == null) return; 139 | try { 140 | if (model.la == FormatLanguage.dart) { 141 | File file = File(saveDirPath + '/my_model.dart'); 142 | bool exists = await file.exists(); 143 | if (!exists) { 144 | file = await file.create(); 145 | } 146 | file.writeAsString(model.impl); 147 | LogManager().write(LogMessage("文件已写入 $saveDirPath")); 148 | } else if (model.la == FormatLanguage.objectiveC) { 149 | // 写入头文件 150 | File headerFile = File(saveDirPath + '/my_model.h'); 151 | bool headerExists = await headerFile.exists(); 152 | if (!headerExists) { 153 | headerFile = await headerFile.create(); 154 | } 155 | headerFile.writeAsString(model.header ?? ''); 156 | LogManager().write(LogMessage("文件已写入 $saveDirPath")); 157 | 158 | // 写入实现文件 159 | File implFile = File(saveDirPath + '/my_model.m'); 160 | bool implExists = await implFile.exists(); 161 | if (!implExists) { 162 | implFile = await implFile.create(); 163 | } 164 | implFile.writeAsString(model.header ?? ''); 165 | LogManager().write(LogMessage("文件已写入 $saveDirPath")); 166 | } else if (model.la == FormatLanguage.swift) { 167 | File file = File(saveDirPath + '/my_model.swift'); 168 | bool exists = await file.exists(); 169 | if (!exists) { 170 | file = await file.create(); 171 | } 172 | file.writeAsString(model.impl); 173 | LogManager().write(LogMessage("文件已写入 $saveDirPath")); 174 | } 175 | } catch (error) { 176 | print("创建文件失败: ${error.toString()}"); 177 | LogManager().write(LogMessage(error.toString(), level: LogLevel.error)); 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /jsonformat/lib/views/property_wrap_item_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:jsonformat/models/json_manager.dart'; 3 | 4 | class PropertyWrapItemWidget extends StatelessWidget { 5 | final JsonProperty property; 6 | 7 | PropertyWrapItemWidget(this.property); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Container( 12 | height: 26, 13 | padding: const EdgeInsets.symmetric(horizontal: 8), 14 | decoration: BoxDecoration( 15 | borderRadius: BorderRadius.circular(6), 16 | color: const Color(0xfff4f5f6), 17 | ), 18 | alignment: Alignment.center, 19 | child: StatefulBuilder( 20 | builder: ((context, setState) { 21 | return Row( 22 | mainAxisSize: MainAxisSize.min, 23 | children: [ 24 | Checkbox( 25 | value: optional, 26 | onChanged: (value) { 27 | setState(() { 28 | valueOption = value ?? true; 29 | }); 30 | }), 31 | Text( 32 | showName, 33 | style: const TextStyle( 34 | fontSize: 16, 35 | fontWeight: FontWeight.bold, 36 | color: Color(0xff333333)), 37 | ) 38 | ], 39 | ); 40 | }), 41 | )); 42 | } 43 | 44 | String get showName { 45 | switch (property) { 46 | case JsonProperty.num: 47 | return '数字'; 48 | case JsonProperty.string: 49 | return '字符串'; 50 | case JsonProperty.bool: 51 | return '布尔'; 52 | case JsonProperty.array: 53 | return '数组'; 54 | case JsonProperty.map: 55 | return '字典'; 56 | case JsonProperty.object: 57 | return '对象'; 58 | default: 59 | return '未知类型'; 60 | } 61 | } 62 | 63 | bool get optional { 64 | switch (property) { 65 | case JsonProperty.num: 66 | return JSONManager().numOptional; 67 | case JsonProperty.string: 68 | return JSONManager().stringOptional; 69 | case JsonProperty.bool: 70 | return JSONManager().boolOptional; 71 | case JsonProperty.array: 72 | return JSONManager().arrayOptional; 73 | case JsonProperty.map: 74 | return JSONManager().mapOptional; 75 | case JsonProperty.object: 76 | return JSONManager().objectOptional; 77 | default: 78 | return true; 79 | } 80 | } 81 | 82 | set valueOption(bool value) { 83 | switch (property) { 84 | case JsonProperty.num: 85 | JSONManager().numOptional = value; 86 | break; 87 | case JsonProperty.string: 88 | JSONManager().stringOptional = value; 89 | break; 90 | case JsonProperty.bool: 91 | JSONManager().boolOptional = value; 92 | break; 93 | case JsonProperty.array: 94 | JSONManager().arrayOptional = value; 95 | break; 96 | case JsonProperty.map: 97 | JSONManager().mapOptional = value; 98 | break; 99 | case JsonProperty.object: 100 | JSONManager().objectOptional = value; 101 | break; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /jsonformat/lib/views/rich_textediting_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:jsonformat/models/json_manager.dart'; 3 | import 'package:jsonformat/models/output_serializer.dart'; 4 | import 'package:jsonformat/models/output_manager.dart'; 5 | 6 | class RichTextEditingController extends TextEditingController { 7 | /// 高亮显示 8 | bool highlight = true; 9 | 10 | /// 是否可折叠。当为`true`时,数组和字典可以折叠 11 | bool canFold = false; 12 | 13 | /// 格式化富文本 14 | final FormatJSONOutputSerializer _serializer = FormatJSONOutputSerializer(); 15 | 16 | @override 17 | TextSpan buildTextSpan( 18 | {required BuildContext context, 19 | TextStyle? style, 20 | required bool withComposing}) { 21 | if (highlight) { 22 | TextSpan text; 23 | if (OutputManager().isJSONText) { 24 | String? input = OutputManager().inputJSON; 25 | text = _serializer.formatRich(input) ?? const TextSpan(); 26 | } else { 27 | String? input = JSONManager().inputJSON; 28 | text = _serializer.formatModelRich(input) ?? const TextSpan(); 29 | } 30 | return text; 31 | } 32 | String json = value.text; 33 | return TextSpan(text: json, style: style); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jsonformat/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /jsonformat/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /jsonformat/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /jsonformat/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import bitsdojo_window_macos 9 | import desktop_drop 10 | import path_provider_macos 11 | 12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 13 | BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin")) 14 | DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) 15 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 16 | } 17 | -------------------------------------------------------------------------------- /jsonformat/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.11' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /jsonformat/macos/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - bitsdojo_window_macos (0.0.1): 3 | - FlutterMacOS 4 | - desktop_drop (0.0.1): 5 | - FlutterMacOS 6 | - FlutterMacOS (1.0.0) 7 | - path_provider_macos (0.0.1): 8 | - FlutterMacOS 9 | 10 | DEPENDENCIES: 11 | - bitsdojo_window_macos (from `Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos`) 12 | - desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`) 13 | - FlutterMacOS (from `Flutter/ephemeral`) 14 | - path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`) 15 | 16 | EXTERNAL SOURCES: 17 | bitsdojo_window_macos: 18 | :path: Flutter/ephemeral/.symlinks/plugins/bitsdojo_window_macos/macos 19 | desktop_drop: 20 | :path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos 21 | FlutterMacOS: 22 | :path: Flutter/ephemeral 23 | path_provider_macos: 24 | :path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos 25 | 26 | SPEC CHECKSUMS: 27 | bitsdojo_window_macos: 7e9b1bbb09bdce418d9657ead7fc9d824203ff0d 28 | desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898 29 | FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 30 | path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f 31 | 32 | PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c 33 | 34 | COCOAPODS: 1.11.2 35 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; 13 | buildPhases = ( 14 | 33CC111E2044C6BF0003C045 /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | ); 18 | name = "Flutter Assemble"; 19 | productName = FLX; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 25 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 26 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 27 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 28 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 29 | 782C1A7427BB92EC005A83B6 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 782C1A7327BB92EB005A83B6 /* libc++.tbd */; }; 30 | 9C4CC0B7E6AFBE48B44E96CC /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5DB148DFC3574D7B0C6903 /* Pods_Runner.framework */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 33CC10E52044A3C60003C045 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = 33CC111A2044C6BA0003C045; 39 | remoteInfo = FLX; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXCopyFilesBuildPhase section */ 44 | 33CC110E2044A8840003C045 /* Bundle Framework */ = { 45 | isa = PBXCopyFilesBuildPhase; 46 | buildActionMask = 2147483647; 47 | dstPath = ""; 48 | dstSubfolderSpec = 10; 49 | files = ( 50 | ); 51 | name = "Bundle Framework"; 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXCopyFilesBuildPhase section */ 55 | 56 | /* Begin PBXFileReference section */ 57 | 0D7E8D3C7952606CDBF4F38D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 58 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 59 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 60 | 33CC10ED2044A3C60003C045 /* jsonformat.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = jsonformat.app; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 62 | 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 63 | 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 64 | 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; 65 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; 66 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 67 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 68 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; 69 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 70 | 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 71 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 72 | 49C0D007EA3F702E09575265 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 73 | 782C1A7327BB92EB005A83B6 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; 74 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 75 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; 76 | 9B5DB148DFC3574D7B0C6903 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 77 | AD7C581BF9727EBFC6CC7F24 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 78 | /* End PBXFileReference section */ 79 | 80 | /* Begin PBXFrameworksBuildPhase section */ 81 | 33CC10EA2044A3C60003C045 /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | 782C1A7427BB92EC005A83B6 /* libc++.tbd in Frameworks */, 86 | 9C4CC0B7E6AFBE48B44E96CC /* Pods_Runner.framework in Frameworks */, 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | /* End PBXFrameworksBuildPhase section */ 91 | 92 | /* Begin PBXGroup section */ 93 | 33BA886A226E78AF003329D5 /* Configs */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 33E5194F232828860026EE4D /* AppInfo.xcconfig */, 97 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 98 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 99 | 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, 100 | ); 101 | path = Configs; 102 | sourceTree = ""; 103 | }; 104 | 33CC10E42044A3C60003C045 = { 105 | isa = PBXGroup; 106 | children = ( 107 | 33FAB671232836740065AC1E /* Runner */, 108 | 33CEB47122A05771004F2AC0 /* Flutter */, 109 | 33CC10EE2044A3C60003C045 /* Products */, 110 | D73912EC22F37F3D000D13A0 /* Frameworks */, 111 | 56CAB6537B9114CAEA3C67E9 /* Pods */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | 33CC10EE2044A3C60003C045 /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 33CC10ED2044A3C60003C045 /* jsonformat.app */, 119 | ); 120 | name = Products; 121 | sourceTree = ""; 122 | }; 123 | 33CC11242044D66E0003C045 /* Resources */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 33CC10F22044A3C60003C045 /* Assets.xcassets */, 127 | 33CC10F42044A3C60003C045 /* MainMenu.xib */, 128 | 33CC10F72044A3C60003C045 /* Info.plist */, 129 | ); 130 | name = Resources; 131 | path = ..; 132 | sourceTree = ""; 133 | }; 134 | 33CEB47122A05771004F2AC0 /* Flutter */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, 138 | 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 139 | 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 140 | 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, 141 | ); 142 | path = Flutter; 143 | sourceTree = ""; 144 | }; 145 | 33FAB671232836740065AC1E /* Runner */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 33CC10F02044A3C60003C045 /* AppDelegate.swift */, 149 | 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, 150 | 33E51913231747F40026EE4D /* DebugProfile.entitlements */, 151 | 33E51914231749380026EE4D /* Release.entitlements */, 152 | 33CC11242044D66E0003C045 /* Resources */, 153 | 33BA886A226E78AF003329D5 /* Configs */, 154 | ); 155 | path = Runner; 156 | sourceTree = ""; 157 | }; 158 | 56CAB6537B9114CAEA3C67E9 /* Pods */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | AD7C581BF9727EBFC6CC7F24 /* Pods-Runner.debug.xcconfig */, 162 | 0D7E8D3C7952606CDBF4F38D /* Pods-Runner.release.xcconfig */, 163 | 49C0D007EA3F702E09575265 /* Pods-Runner.profile.xcconfig */, 164 | ); 165 | path = Pods; 166 | sourceTree = ""; 167 | }; 168 | D73912EC22F37F3D000D13A0 /* Frameworks */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 782C1A7327BB92EB005A83B6 /* libc++.tbd */, 172 | 9B5DB148DFC3574D7B0C6903 /* Pods_Runner.framework */, 173 | ); 174 | name = Frameworks; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXGroup section */ 178 | 179 | /* Begin PBXNativeTarget section */ 180 | 33CC10EC2044A3C60003C045 /* Runner */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; 183 | buildPhases = ( 184 | 3EB23D23F5F4CE1241083014 /* [CP] Check Pods Manifest.lock */, 185 | 33CC10E92044A3C60003C045 /* Sources */, 186 | 33CC10EA2044A3C60003C045 /* Frameworks */, 187 | 33CC10EB2044A3C60003C045 /* Resources */, 188 | 33CC110E2044A8840003C045 /* Bundle Framework */, 189 | 3399D490228B24CF009A79C7 /* ShellScript */, 190 | 1B7582A4FBE6CC382A9C466D /* [CP] Embed Pods Frameworks */, 191 | ); 192 | buildRules = ( 193 | ); 194 | dependencies = ( 195 | 33CC11202044C79F0003C045 /* PBXTargetDependency */, 196 | ); 197 | name = Runner; 198 | productName = Runner; 199 | productReference = 33CC10ED2044A3C60003C045 /* jsonformat.app */; 200 | productType = "com.apple.product-type.application"; 201 | }; 202 | /* End PBXNativeTarget section */ 203 | 204 | /* Begin PBXProject section */ 205 | 33CC10E52044A3C60003C045 /* Project object */ = { 206 | isa = PBXProject; 207 | attributes = { 208 | LastSwiftUpdateCheck = 0920; 209 | LastUpgradeCheck = 1300; 210 | ORGANIZATIONNAME = ""; 211 | TargetAttributes = { 212 | 33CC10EC2044A3C60003C045 = { 213 | CreatedOnToolsVersion = 9.2; 214 | LastSwiftMigration = 1100; 215 | ProvisioningStyle = Automatic; 216 | SystemCapabilities = { 217 | com.apple.Sandbox = { 218 | enabled = 1; 219 | }; 220 | }; 221 | }; 222 | 33CC111A2044C6BA0003C045 = { 223 | CreatedOnToolsVersion = 9.2; 224 | ProvisioningStyle = Manual; 225 | }; 226 | }; 227 | }; 228 | buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; 229 | compatibilityVersion = "Xcode 9.3"; 230 | developmentRegion = en; 231 | hasScannedForEncodings = 0; 232 | knownRegions = ( 233 | en, 234 | Base, 235 | ); 236 | mainGroup = 33CC10E42044A3C60003C045; 237 | productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; 238 | projectDirPath = ""; 239 | projectRoot = ""; 240 | targets = ( 241 | 33CC10EC2044A3C60003C045 /* Runner */, 242 | 33CC111A2044C6BA0003C045 /* Flutter Assemble */, 243 | ); 244 | }; 245 | /* End PBXProject section */ 246 | 247 | /* Begin PBXResourcesBuildPhase section */ 248 | 33CC10EB2044A3C60003C045 /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 253 | 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | /* End PBXResourcesBuildPhase section */ 258 | 259 | /* Begin PBXShellScriptBuildPhase section */ 260 | 1B7582A4FBE6CC382A9C466D /* [CP] Embed Pods Frameworks */ = { 261 | isa = PBXShellScriptBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | inputFileListPaths = ( 266 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 267 | ); 268 | name = "[CP] Embed Pods Frameworks"; 269 | outputFileListPaths = ( 270 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 271 | ); 272 | runOnlyForDeploymentPostprocessing = 0; 273 | shellPath = /bin/sh; 274 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 275 | showEnvVarsInLog = 0; 276 | }; 277 | 3399D490228B24CF009A79C7 /* ShellScript */ = { 278 | isa = PBXShellScriptBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | ); 282 | inputFileListPaths = ( 283 | ); 284 | inputPaths = ( 285 | ); 286 | outputFileListPaths = ( 287 | ); 288 | outputPaths = ( 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | shellPath = /bin/sh; 292 | shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; 293 | }; 294 | 33CC111E2044C6BF0003C045 /* ShellScript */ = { 295 | isa = PBXShellScriptBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | ); 299 | inputFileListPaths = ( 300 | Flutter/ephemeral/FlutterInputs.xcfilelist, 301 | ); 302 | inputPaths = ( 303 | Flutter/ephemeral/tripwire, 304 | ); 305 | outputFileListPaths = ( 306 | Flutter/ephemeral/FlutterOutputs.xcfilelist, 307 | ); 308 | outputPaths = ( 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | shellPath = /bin/sh; 312 | shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; 313 | }; 314 | 3EB23D23F5F4CE1241083014 /* [CP] Check Pods Manifest.lock */ = { 315 | isa = PBXShellScriptBuildPhase; 316 | buildActionMask = 2147483647; 317 | files = ( 318 | ); 319 | inputFileListPaths = ( 320 | ); 321 | inputPaths = ( 322 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 323 | "${PODS_ROOT}/Manifest.lock", 324 | ); 325 | name = "[CP] Check Pods Manifest.lock"; 326 | outputFileListPaths = ( 327 | ); 328 | outputPaths = ( 329 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | shellPath = /bin/sh; 333 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 334 | showEnvVarsInLog = 0; 335 | }; 336 | /* End PBXShellScriptBuildPhase section */ 337 | 338 | /* Begin PBXSourcesBuildPhase section */ 339 | 33CC10E92044A3C60003C045 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, 344 | 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, 345 | 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, 346 | ); 347 | runOnlyForDeploymentPostprocessing = 0; 348 | }; 349 | /* End PBXSourcesBuildPhase section */ 350 | 351 | /* Begin PBXTargetDependency section */ 352 | 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { 353 | isa = PBXTargetDependency; 354 | target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; 355 | targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; 356 | }; 357 | /* End PBXTargetDependency section */ 358 | 359 | /* Begin PBXVariantGroup section */ 360 | 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | 33CC10F52044A3C60003C045 /* Base */, 364 | ); 365 | name = MainMenu.xib; 366 | path = Runner; 367 | sourceTree = ""; 368 | }; 369 | /* End PBXVariantGroup section */ 370 | 371 | /* Begin XCBuildConfiguration section */ 372 | 338D0CE9231458BD00FA5F75 /* Profile */ = { 373 | isa = XCBuildConfiguration; 374 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 375 | buildSettings = { 376 | ALWAYS_SEARCH_USER_PATHS = NO; 377 | CLANG_ANALYZER_NONNULL = YES; 378 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_ENABLE_MODULES = YES; 382 | CLANG_ENABLE_OBJC_ARC = YES; 383 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 384 | CLANG_WARN_BOOL_CONVERSION = YES; 385 | CLANG_WARN_CONSTANT_CONVERSION = YES; 386 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 387 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 388 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 389 | CLANG_WARN_EMPTY_BODY = YES; 390 | CLANG_WARN_ENUM_CONVERSION = YES; 391 | CLANG_WARN_INFINITE_RECURSION = YES; 392 | CLANG_WARN_INT_CONVERSION = YES; 393 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 395 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 396 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 397 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 398 | CODE_SIGN_IDENTITY = "-"; 399 | COPY_PHASE_STRIP = NO; 400 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 401 | ENABLE_NS_ASSERTIONS = NO; 402 | ENABLE_STRICT_OBJC_MSGSEND = YES; 403 | GCC_C_LANGUAGE_STANDARD = gnu11; 404 | GCC_NO_COMMON_BLOCKS = YES; 405 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 407 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 408 | GCC_WARN_UNUSED_FUNCTION = YES; 409 | GCC_WARN_UNUSED_VARIABLE = YES; 410 | MACOSX_DEPLOYMENT_TARGET = 10.11; 411 | MTL_ENABLE_DEBUG_INFO = NO; 412 | SDKROOT = macosx; 413 | SWIFT_COMPILATION_MODE = wholemodule; 414 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 415 | }; 416 | name = Profile; 417 | }; 418 | 338D0CEA231458BD00FA5F75 /* Profile */ = { 419 | isa = XCBuildConfiguration; 420 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 421 | buildSettings = { 422 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 423 | CLANG_ENABLE_MODULES = YES; 424 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 425 | CODE_SIGN_STYLE = Automatic; 426 | COMBINE_HIDPI_IMAGES = YES; 427 | INFOPLIST_FILE = Runner/Info.plist; 428 | LD_RUNPATH_SEARCH_PATHS = ( 429 | "$(inherited)", 430 | "@executable_path/../Frameworks", 431 | ); 432 | PROVISIONING_PROFILE_SPECIFIER = ""; 433 | SWIFT_VERSION = 5.0; 434 | }; 435 | name = Profile; 436 | }; 437 | 338D0CEB231458BD00FA5F75 /* Profile */ = { 438 | isa = XCBuildConfiguration; 439 | buildSettings = { 440 | CODE_SIGN_STYLE = Manual; 441 | PRODUCT_NAME = "$(TARGET_NAME)"; 442 | }; 443 | name = Profile; 444 | }; 445 | 33CC10F92044A3C60003C045 /* Debug */ = { 446 | isa = XCBuildConfiguration; 447 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 448 | buildSettings = { 449 | ALWAYS_SEARCH_USER_PATHS = NO; 450 | CLANG_ANALYZER_NONNULL = YES; 451 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 452 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 453 | CLANG_CXX_LIBRARY = "libc++"; 454 | CLANG_ENABLE_MODULES = YES; 455 | CLANG_ENABLE_OBJC_ARC = YES; 456 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 457 | CLANG_WARN_BOOL_CONVERSION = YES; 458 | CLANG_WARN_CONSTANT_CONVERSION = YES; 459 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 460 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 461 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 462 | CLANG_WARN_EMPTY_BODY = YES; 463 | CLANG_WARN_ENUM_CONVERSION = YES; 464 | CLANG_WARN_INFINITE_RECURSION = YES; 465 | CLANG_WARN_INT_CONVERSION = YES; 466 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 467 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 468 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 469 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 470 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 471 | CODE_SIGN_IDENTITY = "-"; 472 | COPY_PHASE_STRIP = NO; 473 | DEBUG_INFORMATION_FORMAT = dwarf; 474 | ENABLE_STRICT_OBJC_MSGSEND = YES; 475 | ENABLE_TESTABILITY = YES; 476 | GCC_C_LANGUAGE_STANDARD = gnu11; 477 | GCC_DYNAMIC_NO_PIC = NO; 478 | GCC_NO_COMMON_BLOCKS = YES; 479 | GCC_OPTIMIZATION_LEVEL = 0; 480 | GCC_PREPROCESSOR_DEFINITIONS = ( 481 | "DEBUG=1", 482 | "$(inherited)", 483 | ); 484 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 485 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 486 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 487 | GCC_WARN_UNUSED_FUNCTION = YES; 488 | GCC_WARN_UNUSED_VARIABLE = YES; 489 | MACOSX_DEPLOYMENT_TARGET = 10.11; 490 | MTL_ENABLE_DEBUG_INFO = YES; 491 | ONLY_ACTIVE_ARCH = YES; 492 | SDKROOT = macosx; 493 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 494 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 495 | }; 496 | name = Debug; 497 | }; 498 | 33CC10FA2044A3C60003C045 /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 501 | buildSettings = { 502 | ALWAYS_SEARCH_USER_PATHS = NO; 503 | CLANG_ANALYZER_NONNULL = YES; 504 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 505 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 506 | CLANG_CXX_LIBRARY = "libc++"; 507 | CLANG_ENABLE_MODULES = YES; 508 | CLANG_ENABLE_OBJC_ARC = YES; 509 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 510 | CLANG_WARN_BOOL_CONVERSION = YES; 511 | CLANG_WARN_CONSTANT_CONVERSION = YES; 512 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 513 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 514 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 515 | CLANG_WARN_EMPTY_BODY = YES; 516 | CLANG_WARN_ENUM_CONVERSION = YES; 517 | CLANG_WARN_INFINITE_RECURSION = YES; 518 | CLANG_WARN_INT_CONVERSION = YES; 519 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 520 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 521 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 522 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 523 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 524 | CODE_SIGN_IDENTITY = "-"; 525 | COPY_PHASE_STRIP = NO; 526 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 527 | ENABLE_NS_ASSERTIONS = NO; 528 | ENABLE_STRICT_OBJC_MSGSEND = YES; 529 | GCC_C_LANGUAGE_STANDARD = gnu11; 530 | GCC_NO_COMMON_BLOCKS = YES; 531 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 532 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 533 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 534 | GCC_WARN_UNUSED_FUNCTION = YES; 535 | GCC_WARN_UNUSED_VARIABLE = YES; 536 | MACOSX_DEPLOYMENT_TARGET = 10.11; 537 | MTL_ENABLE_DEBUG_INFO = NO; 538 | SDKROOT = macosx; 539 | SWIFT_COMPILATION_MODE = wholemodule; 540 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 541 | }; 542 | name = Release; 543 | }; 544 | 33CC10FC2044A3C60003C045 /* Debug */ = { 545 | isa = XCBuildConfiguration; 546 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 547 | buildSettings = { 548 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 549 | CLANG_ENABLE_MODULES = YES; 550 | CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; 551 | CODE_SIGN_STYLE = Automatic; 552 | COMBINE_HIDPI_IMAGES = YES; 553 | INFOPLIST_FILE = Runner/Info.plist; 554 | LD_RUNPATH_SEARCH_PATHS = ( 555 | "$(inherited)", 556 | "@executable_path/../Frameworks", 557 | ); 558 | PROVISIONING_PROFILE_SPECIFIER = ""; 559 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 560 | SWIFT_VERSION = 5.0; 561 | }; 562 | name = Debug; 563 | }; 564 | 33CC10FD2044A3C60003C045 /* Release */ = { 565 | isa = XCBuildConfiguration; 566 | baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; 567 | buildSettings = { 568 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 569 | CLANG_ENABLE_MODULES = YES; 570 | CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; 571 | CODE_SIGN_STYLE = Automatic; 572 | COMBINE_HIDPI_IMAGES = YES; 573 | INFOPLIST_FILE = Runner/Info.plist; 574 | LD_RUNPATH_SEARCH_PATHS = ( 575 | "$(inherited)", 576 | "@executable_path/../Frameworks", 577 | ); 578 | PROVISIONING_PROFILE_SPECIFIER = ""; 579 | SWIFT_VERSION = 5.0; 580 | }; 581 | name = Release; 582 | }; 583 | 33CC111C2044C6BA0003C045 /* Debug */ = { 584 | isa = XCBuildConfiguration; 585 | buildSettings = { 586 | CODE_SIGN_STYLE = Manual; 587 | PRODUCT_NAME = "$(TARGET_NAME)"; 588 | }; 589 | name = Debug; 590 | }; 591 | 33CC111D2044C6BA0003C045 /* Release */ = { 592 | isa = XCBuildConfiguration; 593 | buildSettings = { 594 | CODE_SIGN_STYLE = Automatic; 595 | PRODUCT_NAME = "$(TARGET_NAME)"; 596 | }; 597 | name = Release; 598 | }; 599 | /* End XCBuildConfiguration section */ 600 | 601 | /* Begin XCConfigurationList section */ 602 | 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { 603 | isa = XCConfigurationList; 604 | buildConfigurations = ( 605 | 33CC10F92044A3C60003C045 /* Debug */, 606 | 33CC10FA2044A3C60003C045 /* Release */, 607 | 338D0CE9231458BD00FA5F75 /* Profile */, 608 | ); 609 | defaultConfigurationIsVisible = 0; 610 | defaultConfigurationName = Release; 611 | }; 612 | 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { 613 | isa = XCConfigurationList; 614 | buildConfigurations = ( 615 | 33CC10FC2044A3C60003C045 /* Debug */, 616 | 33CC10FD2044A3C60003C045 /* Release */, 617 | 338D0CEA231458BD00FA5F75 /* Profile */, 618 | ); 619 | defaultConfigurationIsVisible = 0; 620 | defaultConfigurationName = Release; 621 | }; 622 | 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { 623 | isa = XCConfigurationList; 624 | buildConfigurations = ( 625 | 33CC111C2044C6BA0003C045 /* Debug */, 626 | 33CC111D2044C6BA0003C045 /* Release */, 627 | 338D0CEB231458BD00FA5F75 /* Profile */, 628 | ); 629 | defaultConfigurationIsVisible = 0; 630 | defaultConfigurationName = Release; 631 | }; 632 | /* End XCConfigurationList section */ 633 | }; 634 | rootObject = 33CC10E52044A3C60003C045 /* Project object */; 635 | } 636 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 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 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | -------------------------------------------------------------------------------- /jsonformat/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 = jsonformat 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.jsonformat 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.files.downloads.read-write 6 | 7 | com.apple.security.files.user-selected.read-write 8 | 9 | com.apple.security.app-sandbox 10 | 11 | com.apple.security.cs.allow-jit 12 | 13 | com.apple.security.network.server 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import bitsdojo_window_macos 4 | 5 | class MainFlutterWindow: BitsdojoWindow { 6 | override func awakeFromNib() { 7 | let flutterViewController = FlutterViewController.init() 8 | let windowFrame = self.frame 9 | self.contentViewController = flutterViewController 10 | self.setFrame(windowFrame, display: true) 11 | 12 | RegisterGeneratedPlugins(registry: flutterViewController) 13 | 14 | super.awakeFromNib() 15 | } 16 | 17 | override func bitsdojo_window_configure() -> UInt { 18 | return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /jsonformat/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /jsonformat/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.8.2" 11 | bitsdojo_window: 12 | dependency: "direct main" 13 | description: 14 | name: bitsdojo_window 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "0.1.1+1" 18 | bitsdojo_window_linux: 19 | dependency: transitive 20 | description: 21 | name: bitsdojo_window_linux 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "0.1.1" 25 | bitsdojo_window_macos: 26 | dependency: transitive 27 | description: 28 | name: bitsdojo_window_macos 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "0.1.0" 32 | bitsdojo_window_platform_interface: 33 | dependency: transitive 34 | description: 35 | name: bitsdojo_window_platform_interface 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "0.1.0" 39 | bitsdojo_window_windows: 40 | dependency: transitive 41 | description: 42 | name: bitsdojo_window_windows 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "0.1.0" 46 | boolean_selector: 47 | dependency: transitive 48 | description: 49 | name: boolean_selector 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "2.1.0" 53 | characters: 54 | dependency: transitive 55 | description: 56 | name: characters 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.2.0" 60 | charcode: 61 | dependency: transitive 62 | description: 63 | name: charcode 64 | url: "https://pub.flutter-io.cn" 65 | source: hosted 66 | version: "1.3.1" 67 | clock: 68 | dependency: transitive 69 | description: 70 | name: clock 71 | url: "https://pub.flutter-io.cn" 72 | source: hosted 73 | version: "1.1.0" 74 | collection: 75 | dependency: transitive 76 | description: 77 | name: collection 78 | url: "https://pub.flutter-io.cn" 79 | source: hosted 80 | version: "1.15.0" 81 | cross_file: 82 | dependency: transitive 83 | description: 84 | name: cross_file 85 | url: "https://pub.flutter-io.cn" 86 | source: hosted 87 | version: "0.3.2" 88 | cupertino_icons: 89 | dependency: "direct main" 90 | description: 91 | name: cupertino_icons 92 | url: "https://pub.flutter-io.cn" 93 | source: hosted 94 | version: "1.0.4" 95 | desktop_drop: 96 | dependency: "direct main" 97 | description: 98 | name: desktop_drop 99 | url: "https://pub.flutter-io.cn" 100 | source: hosted 101 | version: "0.3.2" 102 | fake_async: 103 | dependency: transitive 104 | description: 105 | name: fake_async 106 | url: "https://pub.flutter-io.cn" 107 | source: hosted 108 | version: "1.2.0" 109 | ffi: 110 | dependency: transitive 111 | description: 112 | name: ffi 113 | url: "https://pub.flutter-io.cn" 114 | source: hosted 115 | version: "1.1.2" 116 | file: 117 | dependency: transitive 118 | description: 119 | name: file 120 | url: "https://pub.flutter-io.cn" 121 | source: hosted 122 | version: "6.1.2" 123 | file_picker: 124 | dependency: "direct main" 125 | description: 126 | name: file_picker 127 | url: "https://pub.flutter-io.cn" 128 | source: hosted 129 | version: "4.4.0" 130 | flutter: 131 | dependency: "direct main" 132 | description: flutter 133 | source: sdk 134 | version: "0.0.0" 135 | flutter_lints: 136 | dependency: "direct dev" 137 | description: 138 | name: flutter_lints 139 | url: "https://pub.flutter-io.cn" 140 | source: hosted 141 | version: "1.0.4" 142 | flutter_plugin_android_lifecycle: 143 | dependency: transitive 144 | description: 145 | name: flutter_plugin_android_lifecycle 146 | url: "https://pub.flutter-io.cn" 147 | source: hosted 148 | version: "2.0.5" 149 | flutter_test: 150 | dependency: "direct dev" 151 | description: flutter 152 | source: sdk 153 | version: "0.0.0" 154 | flutter_web_plugins: 155 | dependency: transitive 156 | description: flutter 157 | source: sdk 158 | version: "0.0.0" 159 | js: 160 | dependency: transitive 161 | description: 162 | name: js 163 | url: "https://pub.flutter-io.cn" 164 | source: hosted 165 | version: "0.6.3" 166 | lints: 167 | dependency: transitive 168 | description: 169 | name: lints 170 | url: "https://pub.flutter-io.cn" 171 | source: hosted 172 | version: "1.0.1" 173 | matcher: 174 | dependency: transitive 175 | description: 176 | name: matcher 177 | url: "https://pub.flutter-io.cn" 178 | source: hosted 179 | version: "0.12.11" 180 | material_color_utilities: 181 | dependency: transitive 182 | description: 183 | name: material_color_utilities 184 | url: "https://pub.flutter-io.cn" 185 | source: hosted 186 | version: "0.1.3" 187 | meta: 188 | dependency: transitive 189 | description: 190 | name: meta 191 | url: "https://pub.flutter-io.cn" 192 | source: hosted 193 | version: "1.7.0" 194 | path: 195 | dependency: transitive 196 | description: 197 | name: path 198 | url: "https://pub.flutter-io.cn" 199 | source: hosted 200 | version: "1.8.0" 201 | path_provider: 202 | dependency: "direct main" 203 | description: 204 | name: path_provider 205 | url: "https://pub.flutter-io.cn" 206 | source: hosted 207 | version: "2.0.9" 208 | path_provider_android: 209 | dependency: transitive 210 | description: 211 | name: path_provider_android 212 | url: "https://pub.flutter-io.cn" 213 | source: hosted 214 | version: "2.0.11" 215 | path_provider_ios: 216 | dependency: transitive 217 | description: 218 | name: path_provider_ios 219 | url: "https://pub.flutter-io.cn" 220 | source: hosted 221 | version: "2.0.7" 222 | path_provider_linux: 223 | dependency: transitive 224 | description: 225 | name: path_provider_linux 226 | url: "https://pub.flutter-io.cn" 227 | source: hosted 228 | version: "2.1.5" 229 | path_provider_macos: 230 | dependency: transitive 231 | description: 232 | name: path_provider_macos 233 | url: "https://pub.flutter-io.cn" 234 | source: hosted 235 | version: "2.0.5" 236 | path_provider_platform_interface: 237 | dependency: transitive 238 | description: 239 | name: path_provider_platform_interface 240 | url: "https://pub.flutter-io.cn" 241 | source: hosted 242 | version: "2.0.3" 243 | path_provider_windows: 244 | dependency: transitive 245 | description: 246 | name: path_provider_windows 247 | url: "https://pub.flutter-io.cn" 248 | source: hosted 249 | version: "2.0.5" 250 | platform: 251 | dependency: transitive 252 | description: 253 | name: platform 254 | url: "https://pub.flutter-io.cn" 255 | source: hosted 256 | version: "3.1.0" 257 | plugin_platform_interface: 258 | dependency: transitive 259 | description: 260 | name: plugin_platform_interface 261 | url: "https://pub.flutter-io.cn" 262 | source: hosted 263 | version: "2.1.2" 264 | process: 265 | dependency: transitive 266 | description: 267 | name: process 268 | url: "https://pub.flutter-io.cn" 269 | source: hosted 270 | version: "4.2.4" 271 | sky_engine: 272 | dependency: transitive 273 | description: flutter 274 | source: sdk 275 | version: "0.0.99" 276 | source_span: 277 | dependency: transitive 278 | description: 279 | name: source_span 280 | url: "https://pub.flutter-io.cn" 281 | source: hosted 282 | version: "1.8.1" 283 | stack_trace: 284 | dependency: transitive 285 | description: 286 | name: stack_trace 287 | url: "https://pub.flutter-io.cn" 288 | source: hosted 289 | version: "1.10.0" 290 | stream_channel: 291 | dependency: transitive 292 | description: 293 | name: stream_channel 294 | url: "https://pub.flutter-io.cn" 295 | source: hosted 296 | version: "2.1.0" 297 | string_scanner: 298 | dependency: transitive 299 | description: 300 | name: string_scanner 301 | url: "https://pub.flutter-io.cn" 302 | source: hosted 303 | version: "1.1.0" 304 | term_glyph: 305 | dependency: transitive 306 | description: 307 | name: term_glyph 308 | url: "https://pub.flutter-io.cn" 309 | source: hosted 310 | version: "1.2.0" 311 | test_api: 312 | dependency: transitive 313 | description: 314 | name: test_api 315 | url: "https://pub.flutter-io.cn" 316 | source: hosted 317 | version: "0.4.8" 318 | typed_data: 319 | dependency: transitive 320 | description: 321 | name: typed_data 322 | url: "https://pub.flutter-io.cn" 323 | source: hosted 324 | version: "1.3.0" 325 | vector_math: 326 | dependency: transitive 327 | description: 328 | name: vector_math 329 | url: "https://pub.flutter-io.cn" 330 | source: hosted 331 | version: "2.1.1" 332 | win32: 333 | dependency: transitive 334 | description: 335 | name: win32 336 | url: "https://pub.flutter-io.cn" 337 | source: hosted 338 | version: "2.4.0" 339 | xdg_directories: 340 | dependency: transitive 341 | description: 342 | name: xdg_directories 343 | url: "https://pub.flutter-io.cn" 344 | source: hosted 345 | version: "0.2.0+1" 346 | sdks: 347 | dart: ">=2.15.1 <3.0.0" 348 | flutter: ">=2.5.0" 349 | -------------------------------------------------------------------------------- /jsonformat/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: jsonformat 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.15.1 <3.0.0" 22 | 23 | # Dependencies specify other packages that your package needs in order to work. 24 | # To automatically upgrade your package dependencies to the latest versions 25 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 26 | # dependencies can be manually updated by changing the version numbers below to 27 | # the latest version available on pub.dev. To see which dependencies have newer 28 | # versions available, run `flutter pub outdated`. 29 | dependencies: 30 | flutter: 31 | sdk: flutter 32 | 33 | 34 | # The following adds the Cupertino Icons font to your application. 35 | # Use with the CupertinoIcons class for iOS style icons. 36 | cupertino_icons: ^1.0.2 37 | 38 | bitsdojo_window: ^0.1.1 39 | desktop_drop: ^0.3.2 40 | file_picker: ^4.4.0 41 | path_provider: ^2.0.9 42 | 43 | dev_dependencies: 44 | flutter_test: 45 | sdk: flutter 46 | 47 | # The "flutter_lints" package below contains a set of recommended lints to 48 | # encourage good coding practices. The lint set provided by the package is 49 | # activated in the `analysis_options.yaml` file located at the root of your 50 | # package. See that file for information about deactivating specific lint 51 | # rules and activating additional ones. 52 | flutter_lints: ^1.0.0 53 | 54 | # For information on the generic Dart part of this file, see the 55 | # following page: https://dart.dev/tools/pub/pubspec 56 | 57 | # The following section is specific to Flutter. 58 | flutter: 59 | 60 | # The following line ensures that the Material Icons font is 61 | # included with your application, so that you can use the icons in 62 | # the material Icons class. 63 | uses-material-design: true 64 | 65 | # To add assets to your application, add an assets section, like this: 66 | assets: 67 | - assets/json_icon.jpeg 68 | 69 | # An image asset can refer to one or more resolution-specific "variants", see 70 | # https://flutter.dev/assets-and-images/#resolution-aware. 71 | 72 | # For details regarding adding assets from package dependencies, see 73 | # https://flutter.dev/assets-and-images/#from-packages 74 | 75 | # To add custom fonts to your application, add a fonts section here, 76 | # in this "flutter" section. Each entry in this list should have a 77 | # "family" key with the font family name, and a "fonts" key with a 78 | # list giving the asset and other descriptors for the font. For 79 | # example: 80 | # fonts: 81 | # - family: Schyler 82 | # fonts: 83 | # - asset: fonts/Schyler-Regular.ttf 84 | # - asset: fonts/Schyler-Italic.ttf 85 | # style: italic 86 | # - family: Trajan Pro 87 | # fonts: 88 | # - asset: fonts/TrajanPro.ttf 89 | # - asset: fonts/TrajanPro_Bold.ttf 90 | # weight: 700 91 | # 92 | # For details regarding fonts from package dependencies, 93 | # see https://flutter.dev/custom-fonts/#from-packages 94 | -------------------------------------------------------------------------------- /jsonformat/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 that Flutter provides. 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 | 11 | import 'package:jsonformat/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /jsonformat/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/web/favicon.png -------------------------------------------------------------------------------- /jsonformat/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/web/icons/Icon-192.png -------------------------------------------------------------------------------- /jsonformat/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/web/icons/Icon-512.png -------------------------------------------------------------------------------- /jsonformat/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /jsonformat/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /jsonformat/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | jsonformat 33 | 34 | 35 | 36 | 39 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /jsonformat/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsonformat", 3 | "short_name": "jsonformat", 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 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(jsonformat LANGUAGES CXX) 3 | 4 | set(BINARY_NAME "jsonformat") 5 | 6 | cmake_policy(SET CMP0063 NEW) 7 | 8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 9 | 10 | # Configure build options. 11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 12 | if(IS_MULTICONFIG) 13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 14 | CACHE STRING "" FORCE) 15 | else() 16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 17 | set(CMAKE_BUILD_TYPE "Debug" CACHE 18 | STRING "Flutter build mode" FORCE) 19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 20 | "Debug" "Profile" "Release") 21 | endif() 22 | endif() 23 | 24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 28 | 29 | # Use Unicode for all projects. 30 | add_definitions(-DUNICODE -D_UNICODE) 31 | 32 | # Compilation settings that should be applied to most targets. 33 | function(APPLY_STANDARD_SETTINGS TARGET) 34 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 36 | target_compile_options(${TARGET} PRIVATE /EHsc) 37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 39 | endfunction() 40 | 41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 42 | 43 | # Flutter library and tool build rules. 44 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 45 | 46 | # Application build 47 | add_subdirectory("runner") 48 | 49 | # Generated plugin build rules, which manage building the plugins and adding 50 | # them to the application. 51 | include(flutter/generated_plugins.cmake) 52 | 53 | 54 | # === Installation === 55 | # Support files are copied into place next to the executable, so that it can 56 | # run in place. This is done instead of making a separate bundle (as on Linux) 57 | # so that building and running from within Visual Studio will work. 58 | set(BUILD_BUNDLE_DIR "$") 59 | # Make the "install" step default, as it's required to run. 60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 63 | endif() 64 | 65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 67 | 68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 69 | COMPONENT Runtime) 70 | 71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 72 | COMPONENT Runtime) 73 | 74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 75 | COMPONENT Runtime) 76 | 77 | if(PLUGIN_BUNDLED_LIBRARIES) 78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 80 | COMPONENT Runtime) 81 | endif() 82 | 83 | # Fully re-copy the assets directory on each build to avoid having stale files 84 | # from a previous install. 85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 86 | install(CODE " 87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 88 | " COMPONENT Runtime) 89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 91 | 92 | # Install the AOT library on non-Debug builds only. 93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 94 | CONFIGURATIONS Profile;Release 95 | COMPONENT Runtime) 96 | -------------------------------------------------------------------------------- /jsonformat/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 4 | 5 | # Configuration provided via flutter tool. 6 | include(${EPHEMERAL_DIR}/generated_config.cmake) 7 | 8 | # TODO: Move the rest of this into files in ephemeral. See 9 | # https://github.com/flutter/flutter/issues/57146. 10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 11 | 12 | # === Flutter Library === 13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 14 | 15 | # Published to parent scope for install step. 16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 20 | 21 | list(APPEND FLUTTER_LIBRARY_HEADERS 22 | "flutter_export.h" 23 | "flutter_windows.h" 24 | "flutter_messenger.h" 25 | "flutter_plugin_registrar.h" 26 | "flutter_texture_registrar.h" 27 | ) 28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 29 | add_library(flutter INTERFACE) 30 | target_include_directories(flutter INTERFACE 31 | "${EPHEMERAL_DIR}" 32 | ) 33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 34 | add_dependencies(flutter flutter_assemble) 35 | 36 | # === Wrapper === 37 | list(APPEND CPP_WRAPPER_SOURCES_CORE 38 | "core_implementations.cc" 39 | "standard_codec.cc" 40 | ) 41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 43 | "plugin_registrar.cc" 44 | ) 45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 46 | list(APPEND CPP_WRAPPER_SOURCES_APP 47 | "flutter_engine.cc" 48 | "flutter_view_controller.cc" 49 | ) 50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 51 | 52 | # Wrapper sources needed for a plugin. 53 | add_library(flutter_wrapper_plugin STATIC 54 | ${CPP_WRAPPER_SOURCES_CORE} 55 | ${CPP_WRAPPER_SOURCES_PLUGIN} 56 | ) 57 | apply_standard_settings(flutter_wrapper_plugin) 58 | set_target_properties(flutter_wrapper_plugin PROPERTIES 59 | POSITION_INDEPENDENT_CODE ON) 60 | set_target_properties(flutter_wrapper_plugin PROPERTIES 61 | CXX_VISIBILITY_PRESET hidden) 62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 63 | target_include_directories(flutter_wrapper_plugin PUBLIC 64 | "${WRAPPER_ROOT}/include" 65 | ) 66 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 67 | 68 | # Wrapper sources needed for the runner. 69 | add_library(flutter_wrapper_app STATIC 70 | ${CPP_WRAPPER_SOURCES_CORE} 71 | ${CPP_WRAPPER_SOURCES_APP} 72 | ) 73 | apply_standard_settings(flutter_wrapper_app) 74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 75 | target_include_directories(flutter_wrapper_app PUBLIC 76 | "${WRAPPER_ROOT}/include" 77 | ) 78 | add_dependencies(flutter_wrapper_app flutter_assemble) 79 | 80 | # === Flutter tool backend === 81 | # _phony_ is a non-existent file to force this command to run every time, 82 | # since currently there's no way to get a full input/output list from the 83 | # flutter tool. 84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 86 | add_custom_command( 87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 89 | ${CPP_WRAPPER_SOURCES_APP} 90 | ${PHONY_OUTPUT} 91 | COMMAND ${CMAKE_COMMAND} -E env 92 | ${FLUTTER_TOOL_ENVIRONMENT} 93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 94 | windows-x64 $ 95 | VERBATIM 96 | ) 97 | add_custom_target(flutter_assemble DEPENDS 98 | "${FLUTTER_LIBRARY}" 99 | ${FLUTTER_LIBRARY_HEADERS} 100 | ${CPP_WRAPPER_SOURCES_CORE} 101 | ${CPP_WRAPPER_SOURCES_PLUGIN} 102 | ${CPP_WRAPPER_SOURCES_APP} 103 | ) 104 | -------------------------------------------------------------------------------- /jsonformat/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 | #include 10 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | BitsdojoWindowPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("BitsdojoWindowPlugin")); 15 | DesktopDropPluginRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("DesktopDropPlugin")); 17 | } 18 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | bitsdojo_window_windows 7 | desktop_drop 8 | ) 9 | 10 | set(PLUGIN_BUNDLED_LIBRARIES) 11 | 12 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 13 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 14 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 15 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 17 | endforeach(plugin) 18 | -------------------------------------------------------------------------------- /jsonformat/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | add_executable(${BINARY_NAME} WIN32 5 | "flutter_window.cpp" 6 | "main.cpp" 7 | "utils.cpp" 8 | "win32_window.cpp" 9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 10 | "Runner.rc" 11 | "runner.exe.manifest" 12 | ) 13 | apply_standard_settings(${BINARY_NAME}) 14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 17 | add_dependencies(${BINARY_NAME} flutter_assemble) 18 | -------------------------------------------------------------------------------- /jsonformat/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 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 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", "A new Flutter project." "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "jsonformat" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "jsonformat.exe" "\0" 98 | VALUE "ProductName", "jsonformat" "\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 | -------------------------------------------------------------------------------- /jsonformat/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 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | #include 9 | auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP); 10 | 11 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 12 | _In_ wchar_t *command_line, _In_ int show_command) { 13 | // Attach to console when present (e.g., 'flutter run') or create a 14 | // new console when running with a debugger. 15 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 16 | CreateAndAttachConsole(); 17 | } 18 | 19 | // Initialize COM, so that it is available for use in the library and/or 20 | // plugins. 21 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 22 | 23 | flutter::DartProject project(L"data"); 24 | 25 | std::vector command_line_arguments = 26 | GetCommandLineArguments(); 27 | 28 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 29 | 30 | FlutterWindow window(project); 31 | Win32Window::Point origin(10, 10); 32 | Win32Window::Size size(1280, 720); 33 | if (!window.CreateAndShow(L"jsonformat", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | ::MSG msg; 39 | while (::GetMessage(&msg, nullptr, 0, 0)) { 40 | ::TranslateMessage(&msg); 41 | ::DispatchMessage(&msg); 42 | } 43 | 44 | ::CoUninitialize(); 45 | return EXIT_SUCCESS; 46 | } 47 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/jsonformat/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/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 | if (target_length == 0) { 52 | return std::string(); 53 | } 54 | std::string utf8_string; 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /jsonformat/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 | -------------------------------------------------------------------------------- /jsonformat/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /jsonformat/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 and shows a win32 window with |title| and position and size 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 to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | -------------------------------------------------------------------------------- /submit.rb: -------------------------------------------------------------------------------- 1 | 2 | #! /usr/bin/ruby 3 | 4 | 5 | system('git status -s') 6 | system('git add .') 7 | system("git commit -m 'update'") 8 | system('git pull --rebase origin') 9 | system('git push origin') -------------------------------------------------------------------------------- /yanshi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ijinfeng/flutter_json_format/623ece5ed2a205e24db3bac795a7679850edc721/yanshi.gif --------------------------------------------------------------------------------