├── .gitignore ├── .vscode └── launch.json ├── README.md ├── data_demo ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── cn │ │ │ │ │ └── bmob │ │ │ │ │ └── data_demo │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── flutter_export_environment.sh │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ ├── bean │ │ ├── blog.dart │ │ ├── blog.g.dart │ │ ├── user.dart │ │ └── user.g.dart │ ├── main.dart │ └── page │ │ ├── acl_page.dart │ │ ├── file_page.dart │ │ ├── geo_point_page.dart │ │ ├── home_page.dart │ │ ├── installation_page.dart │ │ ├── list_page.dart │ │ ├── object_page.dart │ │ ├── order_page.dart │ │ ├── pointer_page.dart │ │ ├── query │ │ ├── query_page.dart │ │ └── query_statistics_page.dart │ │ ├── real_time_page.dart │ │ ├── sms_page.dart │ │ ├── time_page.dart │ │ └── user │ │ ├── login_by_sms_page.dart │ │ ├── login_page.dart │ │ ├── register_page.dart │ │ ├── reset_by_email_page.dart │ │ ├── reset_by_sms_page.dart │ │ └── user_page.dart ├── pubspec.lock ├── pubspec.yaml ├── res │ └── values │ │ └── strings_en.arb └── test │ └── widget_test.dart └── data_plugin ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── res │ └── values │ │ └── strings_en.arb ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── cn │ └── bmob │ └── data_plugin │ ├── DataPlugin.java │ └── util │ ├── FileUtils.java │ └── InstallationUtils.java ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── cn │ │ │ │ │ └── bmob │ │ │ │ │ └── data_plugin_example │ │ │ │ │ └── MainActivity.java │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── res │ │ └── values │ │ │ └── strings_en.arb │ └── settings.gradle ├── ios │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── flutter_export_environment.sh │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ ├── bean │ │ ├── blog.dart │ │ ├── blog.g.dart │ │ ├── user.dart │ │ └── user.g.dart │ ├── generated │ │ └── i18n.dart │ ├── main.dart │ └── page │ │ ├── acl_page.dart │ │ ├── file_page.dart │ │ ├── geo_point_page.dart │ │ ├── home_page.dart │ │ ├── installation_page.dart │ │ ├── list_page.dart │ │ ├── object_page.dart │ │ ├── order_page.dart │ │ ├── pointer_page.dart │ │ ├── query │ │ ├── query_page.dart │ │ └── query_statistics_page.dart │ │ ├── real_time_page.dart │ │ ├── sms_page.dart │ │ ├── time_page.dart │ │ └── user │ │ ├── login_by_sms_page.dart │ │ ├── login_page.dart │ │ ├── register_page.dart │ │ ├── reset_by_email_page.dart │ │ ├── reset_by_sms_page.dart │ │ └── user_page.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── DataPlugin.h │ └── DataPlugin.m └── data_plugin.podspec ├── lib ├── bmob │ ├── bmob.dart │ ├── bmob_batch.dart │ ├── bmob_date_manager.dart │ ├── bmob_dio.dart │ ├── bmob_file_manager.dart │ ├── bmob_installation_manager.dart │ ├── bmob_query.dart │ ├── bmob_query.g.dart │ ├── bmob_sms.dart │ ├── bmob_sms.g.dart │ ├── bmob_utils.dart │ ├── realtime │ │ ├── change.dart │ │ ├── change.g.dart │ │ ├── client.dart │ │ ├── message.dart │ │ ├── message.g.dart │ │ └── real_time_data_manager.dart │ ├── response │ │ ├── bmob_error.dart │ │ ├── bmob_error.g.dart │ │ ├── bmob_handled.dart │ │ ├── bmob_handled.g.dart │ │ ├── bmob_pointer.dart │ │ ├── bmob_pointer.g.dart │ │ ├── bmob_registered.dart │ │ ├── bmob_registered.g.dart │ │ ├── bmob_results.dart │ │ ├── bmob_results.g.dart │ │ ├── bmob_saved.dart │ │ ├── bmob_saved.g.dart │ │ ├── bmob_sent.dart │ │ ├── bmob_sent.g.dart │ │ ├── bmob_updated.dart │ │ ├── bmob_updated.g.dart │ │ ├── server_time.dart │ │ └── server_time.g.dart │ ├── table │ │ ├── bmob_installation.dart │ │ ├── bmob_installation.g.dart │ │ ├── bmob_object.dart │ │ ├── bmob_role.dart │ │ ├── bmob_role.g.dart │ │ ├── bmob_user.dart │ │ └── bmob_user.g.dart │ └── type │ │ ├── bmob_acl.dart │ │ ├── bmob_date.dart │ │ ├── bmob_date.g.dart │ │ ├── bmob_file.dart │ │ ├── bmob_file.g.dart │ │ ├── bmob_geo_point.dart │ │ ├── bmob_geo_point.g.dart │ │ ├── bmob_pointer.dart │ │ ├── bmob_pointer.g.dart │ │ ├── bmob_relation.dart │ │ └── bmob_relation.g.dart ├── data_plugin.dart ├── generated │ └── i18n.dart └── utils │ ├── dialog_util.dart │ └── file_picker.dart ├── pubspec.lock ├── pubspec.yaml ├── res └── values │ └── strings_en.arb └── test └── data_plugin_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | scellaneous 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 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | /build/ 32 | 33 | # Web related 34 | lib/generated_plugin_registrant.dart 35 | 36 | # Exceptions to above rules. 37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 38 | 39 | -------------------------------------------------------------------------------- /.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": "data_demo", 9 | "cwd": "data_demo", 10 | "request": "launch", 11 | "type": "dart" 12 | }, 13 | { 14 | "name": "data_demo (profile mode)", 15 | "cwd": "data_demo", 16 | "request": "launch", 17 | "type": "dart", 18 | "flutterMode": "profile" 19 | }, 20 | { 21 | "name": "data_demo (release mode)", 22 | "cwd": "data_demo", 23 | "request": "launch", 24 | "type": "dart", 25 | "flutterMode": "release" 26 | }, 27 | { 28 | "name": "data_plugin", 29 | "cwd": "data_plugin", 30 | "request": "launch", 31 | "type": "dart" 32 | }, 33 | { 34 | "name": "data_plugin (profile mode)", 35 | "cwd": "data_plugin", 36 | "request": "launch", 37 | "type": "dart", 38 | "flutterMode": "profile" 39 | }, 40 | { 41 | "name": "data_plugin (release mode)", 42 | "cwd": "data_plugin", 43 | "request": "launch", 44 | "type": "dart", 45 | "flutterMode": "release" 46 | }, 47 | { 48 | "name": "example", 49 | "cwd": "data_plugin/example", 50 | "request": "launch", 51 | "type": "dart" 52 | }, 53 | { 54 | "name": "example (profile mode)", 55 | "cwd": "data_plugin/example", 56 | "request": "launch", 57 | "type": "dart", 58 | "flutterMode": "profile" 59 | }, 60 | { 61 | "name": "example (release mode)", 62 | "cwd": "data_plugin/example", 63 | "request": "launch", 64 | "type": "dart", 65 | "flutterMode": "release" 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /data_demo/.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 | # Visual Studio Code related 19 | .vscode/ 20 | 21 | # Flutter/Dart/Pub related 22 | **/doc/api/ 23 | .dart_tool/ 24 | .flutter-plugins 25 | .packages 26 | .pub-cache/ 27 | .pub/ 28 | /build/ 29 | 30 | # Android related 31 | **/android/**/gradle-wrapper.jar 32 | **/android/.gradle 33 | **/android/captures/ 34 | **/android/gradlew 35 | **/android/gradlew.bat 36 | **/android/local.properties 37 | **/android/**/GeneratedPluginRegistrant.java 38 | 39 | # iOS/XCode related 40 | **/ios/**/*.mode1v3 41 | **/ios/**/*.mode2v3 42 | **/ios/**/*.moved-aside 43 | **/ios/**/*.pbxuser 44 | **/ios/**/*.perspectivev3 45 | **/ios/**/*sync/ 46 | **/ios/**/.sconsign.dblite 47 | **/ios/**/.tags* 48 | **/ios/**/.vagrant/ 49 | **/ios/**/DerivedData/ 50 | **/ios/**/Icon? 51 | **/ios/**/Pods/ 52 | **/ios/**/.symlinks/ 53 | **/ios/**/profile 54 | **/ios/**/xcuserdata 55 | **/ios/.generated/ 56 | **/ios/Flutter/App.framework 57 | **/ios/Flutter/Flutter.framework 58 | **/ios/Flutter/Generated.xcconfig 59 | **/ios/Flutter/app.flx 60 | **/ios/Flutter/app.zip 61 | **/ios/Flutter/flutter_assets/ 62 | **/ios/ServiceDefinitions.json 63 | **/ios/Runner/GeneratedPluginRegistrant.* 64 | 65 | # Exceptions to above rules. 66 | !**/ios/**/default.mode1v3 67 | !**/ios/**/default.mode2v3 68 | !**/ios/**/default.pbxuser 69 | !**/ios/**/default.perspectivev3 70 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 71 | -------------------------------------------------------------------------------- /data_demo/.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: 8661d8aecd626f7f57ccbcb735553edc05a2e713 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /data_demo/README.md: -------------------------------------------------------------------------------- 1 | # data_demo 2 | 3 | Bmob Data Flutter Demo. 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.io/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.io/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /data_demo/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 33 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "cn.bmob.data_demo" 37 | minSdkVersion 21 38 | targetSdkVersion 33 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | testImplementation 'junit:junit:4.12' 59 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 61 | } 62 | -------------------------------------------------------------------------------- /data_demo/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_demo/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 11 | 12 | 16 | 24 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /data_demo/android/app/src/main/java/cn/bmob/data_demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.data_demo; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | // @Override 7 | // protected void onCreate(Bundle savedInstanceState) { 8 | // super.onCreate(savedInstanceState); 9 | // GeneratedPluginRegistrant.registerWith(this); 10 | // } 11 | } 12 | -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_demo/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /data_demo/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_demo/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:7.1.2' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /data_demo/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true -------------------------------------------------------------------------------- /data_demo/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | 8 | -------------------------------------------------------------------------------- /data_demo/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /data_demo/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /data_demo/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /data_demo/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /data_demo/ios/Flutter/flutter_export_environment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This is a generated file; do not edit or check into version control. 3 | export "FLUTTER_ROOT=/Users/quinn/flutter" 4 | export "FLUTTER_APPLICATION_PATH=/Users/quinn/Bmob/Github/bmob-flutter-sdk/data_demo" 5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true" 6 | export "FLUTTER_TARGET=lib/main.dart" 7 | export "FLUTTER_BUILD_DIR=build" 8 | export "FLUTTER_BUILD_NAME=0.0.11" 9 | export "FLUTTER_BUILD_NUMBER=0.0.11" 10 | export "DART_OBFUSCATION=false" 11 | export "TRACK_WIDGET_CREATION=true" 12 | export "TREE_SHAKE_ICONS=false" 13 | export "PACKAGE_CONFIG=.dart_tool/package_config.json" 14 | -------------------------------------------------------------------------------- /data_demo/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def parse_KV_file(file, separator='=') 14 | file_abs_path = File.expand_path(file) 15 | if !File.exists? file_abs_path 16 | return []; 17 | end 18 | pods_ary = [] 19 | skip_line_start_symbols = ["#", "/"] 20 | File.foreach(file_abs_path) { |line| 21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 22 | plugin = line.split(pattern=separator) 23 | if plugin.length == 2 24 | podname = plugin[0].strip() 25 | path = plugin[1].strip() 26 | podpath = File.expand_path("#{path}", file_abs_path) 27 | pods_ary.push({:name => podname, :path => podpath}); 28 | else 29 | puts "Invalid plugin specification: #{line}" 30 | end 31 | } 32 | return pods_ary 33 | end 34 | 35 | target 'Runner' do 36 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 37 | # referring to absolute paths on developers' machines. 38 | system('rm -rf .symlinks') 39 | system('mkdir -p .symlinks/plugins') 40 | 41 | # Flutter Pods 42 | generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') 43 | if generated_xcode_build_settings.empty? 44 | puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." 45 | end 46 | generated_xcode_build_settings.map { |p| 47 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR' 48 | symlink = File.join('.symlinks', 'flutter') 49 | File.symlink(File.dirname(p[:path]), symlink) 50 | pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) 51 | end 52 | } 53 | 54 | # Plugin Pods 55 | plugin_pods = parse_KV_file('../.flutter-plugins') 56 | plugin_pods.map { |p| 57 | symlink = File.join('.symlinks', 'plugins', p[:name]) 58 | File.symlink(p[:path], symlink) 59 | pod p[:name], :path => File.join(symlink, 'ios') 60 | } 61 | end 62 | 63 | post_install do |installer| 64 | installer.pods_project.targets.each do |target| 65 | target.build_configurations.each do |config| 66 | config.build_settings['ENABLE_BITCODE'] = 'NO' 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /data_demo/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_demo/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /data_demo/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /data_demo/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /data_demo/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | data_demo 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /data_demo/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /data_demo/lib/bean/blog.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 4 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 5 | 6 | import 'package:data_plugin/bmob/type/bmob_geo_point.dart'; 7 | import 'package:data_plugin/bmob/type/bmob_date.dart'; 8 | import 'package:data_plugin/bmob/type/bmob_file.dart'; 9 | //此处与类名一致,由指令自动生成代码 10 | part 'blog.g.dart'; 11 | 12 | 13 | @JsonSerializable() 14 | class Blog extends BmobObject{ 15 | 16 | //博客标题 17 | String title; 18 | //博客内容 19 | String content; 20 | //博客作者 21 | BmobUser author; 22 | int like; 23 | BmobGeoPoint addr; 24 | BmobDate time; 25 | BmobFile pic; 26 | Blog(); 27 | 28 | //此处与类名一致,由指令自动生成代码 29 | factory Blog.fromJson(Map json) => 30 | _$BlogFromJson(json); 31 | 32 | 33 | 34 | //此处与类名一致,由指令自动生成代码 35 | Map toJson() => _$BlogToJson(this); 36 | 37 | @override 38 | Map getParams() { 39 | // TODO: implement getParams 40 | return toJson(); 41 | } 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | } -------------------------------------------------------------------------------- /data_demo/lib/bean/blog.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'blog.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Blog _$BlogFromJson(Map json) { 10 | return Blog() 11 | ..createdAt = json['createdAt'] as String 12 | ..updatedAt = json['updatedAt'] as String 13 | ..objectId = json['objectId'] as String 14 | ..ACL = json['ACL'] as Map 15 | ..title = json['title'] as String 16 | ..content = json['content'] as String 17 | ..author = json['author'] == null 18 | ? null 19 | : BmobUser.fromJson(json['author'] as Map) 20 | ..like = json['like'] as int 21 | ..addr = json['addr'] == null 22 | ? null 23 | : BmobGeoPoint.fromJson(json['addr'] as Map) 24 | ..time = json['time'] == null 25 | ? null 26 | : BmobDate.fromJson(json['time'] as Map) 27 | ..pic = json['pic'] == null 28 | ? null 29 | : BmobFile.fromJson(json['pic'] as Map); 30 | } 31 | 32 | Map _$BlogToJson(Blog instance) => { 33 | 'createdAt': instance.createdAt, 34 | 'updatedAt': instance.updatedAt, 35 | 'objectId': instance.objectId, 36 | 'ACL': instance.ACL, 37 | 'title': instance.title, 38 | 'content': instance.content, 39 | 'author': instance.author, 40 | 'like': instance.like, 41 | 'addr': instance.addr, 42 | 'time': instance.time, 43 | 'pic': instance.pic 44 | }; 45 | -------------------------------------------------------------------------------- /data_demo/lib/bean/user.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'user.g.dart'; 5 | 6 | @JsonSerializable() 7 | class User extends BmobUser { 8 | factory User.fromJson(Map json) => _$UserFromJson(json); 9 | 10 | Map toJson() => _$UserToJson(this); 11 | 12 | int age; 13 | int gender; 14 | String nickname; 15 | 16 | User(); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /data_demo/lib/bean/user.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'user.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | User _$UserFromJson(Map json) { 10 | return User() 11 | ..createdAt = json['createdAt'] as String 12 | ..updatedAt = json['updatedAt'] as String 13 | ..objectId = json['objectId'] as String 14 | ..ACL = json['ACL'] as Map 15 | ..username = json['username'] as String 16 | ..password = json['password'] as String 17 | ..email = json['email'] as String 18 | ..emailVerified = json['emailVerified'] as bool 19 | ..mobilePhoneNumber = json['mobilePhoneNumber'] as String 20 | ..mobilePhoneNumberVerified = json['mobilePhoneNumberVerified'] as bool 21 | ..sessionToken = json['sessionToken'] as String 22 | ..age = json['age'] as int 23 | ..gender = json['gender'] as int 24 | ..nickname = json['nickname'] as String; 25 | } 26 | 27 | Map _$UserToJson(User instance) => { 28 | 'createdAt': instance.createdAt, 29 | 'updatedAt': instance.updatedAt, 30 | 'objectId': instance.objectId, 31 | 'ACL': instance.ACL, 32 | 'username': instance.username, 33 | 'password': instance.password, 34 | 'email': instance.email, 35 | 'emailVerified': instance.emailVerified, 36 | 'mobilePhoneNumber': instance.mobilePhoneNumber, 37 | 'mobilePhoneNumberVerified': instance.mobilePhoneNumberVerified, 38 | 'sessionToken': instance.sessionToken, 39 | 'age': instance.age, 40 | 'gender': instance.gender, 41 | 'nickname': instance.nickname 42 | }; 43 | -------------------------------------------------------------------------------- /data_demo/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:data_plugin/bmob/bmob.dart'; 3 | import 'page/home_page.dart'; 4 | import 'page/object_page.dart'; 5 | import 'page/query/query_page.dart'; 6 | import 'page/query/query_statistics_page.dart'; 7 | import 'page/sms_page.dart'; 8 | import 'page/installation_page.dart'; 9 | import 'page/list_page.dart'; 10 | import 'page/file_page.dart'; 11 | import 'page/time_page.dart'; 12 | import 'page/pointer_page.dart'; 13 | import 'page/acl_page.dart'; 14 | import 'page/geo_point_page.dart'; 15 | import 'page/real_time_page.dart'; 16 | import 'page/order_page.dart'; 17 | import 'page/user/login_by_sms_page.dart'; 18 | import 'page/user/login_page.dart'; 19 | import 'page/user/register_page.dart'; 20 | import 'page/user/reset_by_email_page.dart'; 21 | import 'page/user/reset_by_sms_page.dart'; 22 | import 'page/user/user_page.dart'; 23 | 24 | void main() => runApp(MyApp()); 25 | 26 | class MyApp extends StatelessWidget { 27 | // This widget is the root of your application. 28 | @override 29 | Widget build(BuildContext context) { 30 | Bmob.initMasterKey("","12784168944a56ae41c4575686b7b332", 31 | "9e8ffb8e0945092d1a6b3562741ae564", "0db392c02287a18bf05592d6d5221a6e"); 32 | 33 | 34 | return MaterialApp( 35 | title: 'Flutter Bmob', 36 | theme: ThemeData( 37 | // This is the theme of your application. 38 | // 39 | // Try running your application with "flutter run". You'll see the 40 | // application has a blue toolbar. Then, without quitting the app, try 41 | // changing the primarySwatch below to Colors.green and then invoke 42 | // "hot reload" (press "r" in the console where you ran "flutter run", 43 | // or press Run > Flutter Hot Reload in IntelliJ). Notice that the 44 | // counter didn't reset back to zero; the application is not restarted. 45 | primarySwatch: Colors.blue, 46 | ), 47 | home: HomePage(title: 'Flutter Bmob'), 48 | routes: { 49 | 'loginRoute': (BuildContext context) => new LoginPage(), 50 | 'registerRoute': (BuildContext context) => new RegisterPage(), 51 | 'userRoute': (BuildContext context) => new UserPage(title: '用户管理'), 52 | 'installationRoute': (BuildContext context) => 53 | new InstallationPage(title: '设备管理'), 54 | 'objectRoute': (BuildContext context) => new ObjectPage(title: '数据操作'), 55 | 'smsRoute': (BuildContext context) => new SmsPage(), 56 | 'listRoute': (BuildContext context) => new ListPage(), 57 | 'fileRoute':(BuildContext context)=>new FilePage(), 58 | 'timeRoute':(BuildContext context)=>new TimePage(), 59 | 'queryRoute':(BuildContext context)=>new QueryPage(), 60 | 'pointerRoute':(BuildContext context)=>new PointerPage(), 61 | 'aclRoute':(BuildContext context)=>new AclPage(), 62 | 'geoPointRoute':(BuildContext context)=> new GeoPointPage(), 63 | 'realtimeRoute':(BuildContext context)=> new RealTimePage(), 64 | 'orderRoute':(BuildContext context)=> new OrderPage(), 65 | 'smsLoginRoute':(BuildContext context)=> new SmsLoginPage(), 66 | 'smsResetRoute':(BuildContext context)=> new SmsResetPage(), 67 | 'emailResetRoute':(BuildContext context)=> new EmailResetPage(), 68 | 'statisticsQQueryRoute':(BuildContext context)=> new QueryStatisticsPage(), 69 | }, 70 | ); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /data_demo/lib/page/geo_point_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/utils/dialog_util.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:data_plugin/bmob/type/bmob_geo_point.dart'; 4 | import '../bean/blog.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 6 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 7 | import 'package:data_plugin/data_plugin.dart'; 8 | 9 | class GeoPointPage extends StatefulWidget { 10 | @override 11 | State createState() { 12 | // TODO: implement createState 13 | return _GeoPointPageState(); 14 | } 15 | } 16 | 17 | class _GeoPointPageState extends State { 18 | @override 19 | Widget build(BuildContext context) { 20 | // TODO: implement build 21 | return new Scaffold( 22 | appBar: AppBar( 23 | title: Text("地理位置"), 24 | ), 25 | body: new Container( 26 | child: new Column( 27 | children: [ 28 | ElevatedButton( 29 | onPressed: () { 30 | _addGeoPoint(); 31 | }, 32 | child: Text( 33 | "添加地理位置数据", 34 | style: TextStyle(color: Colors.white), 35 | ), 36 | ), 37 | ], 38 | ), 39 | ), 40 | ); 41 | } 42 | 43 | ///添加地理位置信息 44 | _addGeoPoint() { 45 | Blog blog = Blog(); 46 | BmobGeoPoint bmobGeoPoint = BmobGeoPoint(); 47 | bmobGeoPoint.latitude = 12.4445; 48 | bmobGeoPoint.longitude = 124.122; 49 | blog.addr = bmobGeoPoint; 50 | blog.save().then((BmobSaved bmobSaved) { 51 | String message = 52 | "创建一条数据成功:${bmobSaved.objectId} - ${bmobSaved.createdAt}"; 53 | showSuccess(context, message); 54 | }).catchError((e) { 55 | showError(context, BmobError.convert(e).error); 56 | }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /data_demo/lib/page/installation_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/utils/dialog_util.dart'; 2 | 3 | /** 4 | * home page 5 | */ 6 | import 'package:flutter/material.dart'; 7 | import 'package:data_plugin/bmob/bmob_installation_manager.dart'; 8 | import 'package:data_plugin/bmob/table/bmob_installation.dart'; 9 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 10 | 11 | class InstallationPage extends StatefulWidget { 12 | InstallationPage({Key key, this.title}) : super(key: key); 13 | 14 | // This widget is the home page of your application. It is stateful, meaning 15 | // that it has a State object (defined below) that contains fields that affect 16 | // how it looks. 17 | 18 | // This class is the configuration for the state. It holds the values (in this 19 | // case the title) provided by the parent (in this case the App widget) and 20 | // used by the build method of the State. Fields in a Widget subclass are 21 | // always marked "final". 22 | 23 | final String title; 24 | 25 | @override 26 | _InstallationPageState createState() => _InstallationPageState(); 27 | } 28 | 29 | class _InstallationPageState extends State { 30 | @override 31 | Widget build(BuildContext context) { 32 | // This method is rerun every time setState is called, for instance as done 33 | // by the _incrementCounter method above. 34 | // 35 | // The Flutter framework has been optimized to make rerunning build methods 36 | // fast, so that you can just rebuild anything that needs updating rather 37 | // than having to individually change instances of widgets. 38 | return Scaffold( 39 | appBar: AppBar( 40 | // Here we take the value from the MyInstallationPage object that was created by 41 | // the App.build method, and use it to set our appbar title. 42 | title: Text(widget.title), 43 | ), 44 | body: new Container( 45 | margin: new EdgeInsets.all(10.0), 46 | child: new Column( 47 | children: [ 48 | ElevatedButton( 49 | onPressed: () { 50 | _getInstallationId(context); 51 | }, 52 | child: new Text('获取设备ID', 53 | style: new TextStyle(color: Colors.white))), 54 | ElevatedButton( 55 | onPressed: () { 56 | _initInstallation(context); 57 | }, 58 | child: new Text('初始化设备', 59 | style: new TextStyle(color: Colors.white))), 60 | ], 61 | ), 62 | ), 63 | ); 64 | } 65 | 66 | ///获取设备ID 67 | _getInstallationId(BuildContext context) async { 68 | String installationId = await BmobInstallationManager.getInstallationId(); 69 | showSuccess(context, installationId); 70 | } 71 | 72 | ///初始化设备 73 | _initInstallation(BuildContext context) { 74 | BmobInstallationManager.init().then((BmobInstallation bmobInstallation) { 75 | showSuccess(context, bmobInstallation.toJson().toString()); 76 | }).catchError((e) { 77 | showError(context, BmobError.convert(e).error); 78 | }); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /data_demo/lib/page/list_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:data_plugin/bmob/bmob_query.dart'; 3 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 4 | import 'package:data_plugin/utils/dialog_util.dart'; 5 | 6 | import '../bean/blog.dart'; 7 | 8 | class ListPage extends StatefulWidget { 9 | @override 10 | State createState() { 11 | // TODO: implement createState 12 | return new Page(); 13 | } 14 | } 15 | 16 | class Page extends State { 17 | var _items = []; 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | // TODO: implement build 22 | return layout(context); 23 | } 24 | 25 | @override 26 | void initState() { 27 | // TODO: implement initState 28 | _queryList(context); 29 | super.initState(); 30 | } 31 | 32 | ///查询多条数据 33 | void _queryList(BuildContext context) { 34 | BmobQuery query = BmobQuery(); 35 | query.setInclude("author"); 36 | query.setLimit(10); 37 | query.setSkip(10); 38 | query.queryObjects().then((List data) { 39 | List blogs = data.map((i) => Blog.fromJson(i)).toList(); 40 | 41 | setState(() { 42 | _items = blogs; 43 | }); 44 | int index = 0; 45 | for (Blog blog in blogs) { 46 | index++; 47 | if (blog != null) { 48 | print(index); 49 | print(blog.objectId); 50 | print(blog.title); 51 | print(blog.content); 52 | if (blog.author != null) { 53 | print(blog.author.objectId); 54 | print(blog.author.username); 55 | } 56 | } 57 | } 58 | }).catchError((e) { 59 | showError(context, BmobError.convert(e).error); 60 | }); 61 | } 62 | 63 | Widget layout(BuildContext context) { 64 | return new Scaffold( 65 | appBar: buildAppBar(context), 66 | body: 67 | new ListView.builder(itemCount: _items.length, itemBuilder: itemView), 68 | ); 69 | } 70 | 71 | Widget buildAppBar(BuildContext context) { 72 | return new AppBar(title: const Text('列表查询')); 73 | } 74 | 75 | Widget itemView(BuildContext context, int index) { 76 | print("item $index"); 77 | Blog model = this._items[index]; 78 | //设置分割线 79 | return new Container( 80 | child: new Padding( 81 | padding: const EdgeInsets.all(8.0), 82 | child: new Padding( 83 | padding: const EdgeInsets.all(8.0), 84 | child: new Column( 85 | children: [ 86 | new Row( 87 | children: [ 88 | new Text('${model.title}', 89 | style: new TextStyle(fontSize: 15.0)), 90 | new Text('(${model.objectId})', 91 | style: new TextStyle(fontSize: 15.0)), 92 | new Text('(${model.createdAt})', 93 | style: new TextStyle(fontSize: 15.0)), 94 | ], 95 | ), 96 | new Center( 97 | heightFactor: 6.0, 98 | child: new Text("${model.content}\n第$index条数据", 99 | style: new TextStyle(fontSize: 17.0)), 100 | ), 101 | new Divider(height: 2.0), 102 | ], 103 | )))); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /data_demo/lib/page/order_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:data_plugin/bmob/bmob_query.dart'; 4 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 5 | import 'package:data_plugin/utils/dialog_util.dart'; 6 | import '../bean/blog.dart'; 7 | 8 | class OrderPage extends StatefulWidget { 9 | @override 10 | State createState() { 11 | // TODO: implement createState 12 | return _OrderPageState(); 13 | } 14 | } 15 | 16 | class _OrderPageState extends State { 17 | @override 18 | Widget build(BuildContext context) { 19 | // TODO: implement build 20 | return new Scaffold( 21 | appBar: AppBar( 22 | title: Text("查询"), 23 | ), 24 | body: new Container( 25 | child: new Column( 26 | children: [ 27 | ElevatedButton( 28 | onPressed: () { 29 | _queryOrder(context); 30 | }, 31 | child: new Text('排序查询', 32 | style: new TextStyle(color: Colors.white))), 33 | ], 34 | ), 35 | ), 36 | ); 37 | } 38 | 39 | ///数据排序 40 | _queryOrder(BuildContext context) { 41 | BmobQuery query = BmobQuery(); 42 | query.setOrder("createdAt"); 43 | query.setLimit(10); 44 | query.setSkip(10); 45 | query.queryObjects().then((data) { 46 | List blogs = data.map((i) => Blog.fromJson(i)).toList(); 47 | Navigator.pushNamed(context, "listRoute"); 48 | 49 | for (Blog blog in blogs) { 50 | if (blog != null) { 51 | print(blog.objectId); 52 | print(blog.title); 53 | print(blog.content); 54 | } 55 | } 56 | }).catchError((e) { 57 | showError(context, BmobError.convert(e).error); 58 | }); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /data_demo/lib/page/real_time_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 2 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 3 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 4 | import 'package:data_plugin/utils/dialog_util.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | import 'package:data_plugin/bmob/realtime/real_time_data_manager.dart'; 8 | import 'package:data_plugin/bmob/realtime/client.dart'; 9 | import 'package:data_plugin/bmob/realtime/change.dart'; 10 | import '../bean/blog.dart'; 11 | 12 | class RealTimePage extends StatefulWidget { 13 | @override 14 | _RealTimeState createState() { 15 | // TODO: implement createState 16 | return _RealTimeState(); 17 | } 18 | } 19 | 20 | class _RealTimeState extends State { 21 | @override 22 | Widget build(BuildContext context) { 23 | // TODO: implement build 24 | return new Scaffold( 25 | appBar: new AppBar( 26 | title: Text("其他操作"), 27 | ), 28 | body: new Container( 29 | margin: new EdgeInsets.all(10.0), 30 | child: new Column( 31 | children: [ 32 | ElevatedButton( 33 | onPressed: () { 34 | _listen(); 35 | }, 36 | child: new Text('开始监听', 37 | style: new TextStyle(color: Colors.white))), 38 | ElevatedButton( 39 | onPressed: () { 40 | _change(context); 41 | }, 42 | child: new Text('修改数据', 43 | style: new TextStyle(color: Colors.white))), 44 | ], 45 | ), 46 | ), 47 | ); 48 | } 49 | 50 | ///数据监听 51 | _listen() { 52 | RealTimeDataManager.getInstance().listen(onConnected: (Client client) { 53 | showSuccess(context, "监听数据连接成功,开始订阅消息!"); 54 | client.subTableUpdate("Blog"); 55 | }, onDisconnected: () { 56 | showError(context, "监听数据断开连接"); 57 | }, onDataChanged: (Change data) { 58 | ///注意:此处返回的data.data类型与Blog类型不一致,需要使用map来获取具体属性值而不是使用Blog 59 | Map map = data.data; 60 | showSuccess(context, "监听到数据变化:" + map.toString()); 61 | }, onError: (error) { 62 | showError(context, error.toString()); 63 | }); 64 | } 65 | 66 | ///改编数据 67 | _change(context) { 68 | ///保存一条数据 69 | BmobUser bmobUser = BmobUser(); 70 | bmobUser.objectId = "7c7fd3afe1"; 71 | Blog blog = Blog(); 72 | blog.title = "博客标题"; 73 | blog.content = "博客内容"; 74 | blog.author = bmobUser; 75 | blog.like = 77; 76 | blog.save().then((BmobSaved bmobSaved) { 77 | String message = 78 | "创建一条数据成功:${bmobSaved.objectId} - ${bmobSaved.createdAt}"; 79 | showSuccess(context, message); 80 | }).catchError((e) { 81 | showError(context, BmobError.convert(e).error); 82 | }); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /data_demo/lib/page/time_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/utils/dialog_util.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:data_plugin/data_plugin.dart'; 4 | import 'package:data_plugin/bmob/response/server_time.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 6 | import 'package:data_plugin/bmob/bmob_date_manager.dart'; 7 | import '../bean/blog.dart'; 8 | import 'package:data_plugin/bmob/type/bmob_date.dart'; 9 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 10 | 11 | class TimePage extends StatefulWidget { 12 | @override 13 | State createState() { 14 | // TODO: implement createState 15 | return _OtherState(); 16 | } 17 | } 18 | 19 | class _OtherState extends State { 20 | @override 21 | Widget build(BuildContext context) { 22 | // TODO: implement build 23 | return new Scaffold( 24 | appBar: new AppBar( 25 | title: Text("其他操作"), 26 | ), 27 | body: new Container( 28 | margin: new EdgeInsets.all(10.0), 29 | child: new Column( 30 | children: [ 31 | ElevatedButton( 32 | onPressed: () { 33 | _getServerTime(); 34 | }, 35 | child: new Text('获取服务器时间', 36 | style: new TextStyle(color: Colors.white))), 37 | ElevatedButton( 38 | onPressed: () { 39 | _addDate(); 40 | }, 41 | child: new Text('添加时间类型', 42 | style: new TextStyle(color: Colors.white))), 43 | ], 44 | ), 45 | ), 46 | ); 47 | } 48 | 49 | ///获取服务器时间 50 | _getServerTime() { 51 | BmobDateManager.getServerTimestamp().then((ServerTime serverTime) { 52 | showSuccess(context, "${serverTime.timestamp}\n${serverTime.datetime}"); 53 | }).catchError((e) { 54 | showError(context, BmobError.convert(e).error); 55 | }); 56 | } 57 | 58 | ///添加时间数据 59 | _addDate() { 60 | DateTime dateTime = DateTime.now(); 61 | BmobDate bmobDate = BmobDate(); 62 | bmobDate.setDate(dateTime); 63 | Blog blog = Blog(); 64 | blog.time = bmobDate; 65 | blog.title = "添加时间类型"; 66 | blog.content = "测试时间类型的请求"; 67 | blog.save().then((BmobSaved bmobSaved) { 68 | showSuccess(context, bmobSaved.objectId); 69 | }).catchError((e) { 70 | showError(context, BmobError.convert(e).error); 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /data_demo/lib/page/user/reset_by_email_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/bmob_handled.dart'; 2 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 3 | 4 | /** 5 | * login page 6 | */ 7 | import 'package:flutter/material.dart'; 8 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 9 | import 'package:data_plugin/utils/dialog_util.dart'; 10 | 11 | class EmailResetPage extends StatefulWidget { 12 | @override 13 | _EmailResetPageState createState() => _EmailResetPageState(); 14 | } 15 | 16 | class _EmailResetPageState extends State { 17 | final _formKey = GlobalKey(); 18 | String _email; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return Scaffold( 23 | body: Form( 24 | key: _formKey, 25 | child: ListView( 26 | padding: EdgeInsets.symmetric(horizontal: 22.0), 27 | children: [ 28 | SizedBox( 29 | height: kToolbarHeight, 30 | ), 31 | buildTitle(), 32 | buildTitleLine(), 33 | SizedBox(height: 30.0), 34 | buildVerifyTextField(context), 35 | SizedBox(height: 30.0), 36 | ], 37 | ))); 38 | } 39 | 40 | 41 | 42 | TextFormField buildVerifyTextField(BuildContext context) { 43 | return TextFormField( 44 | onSaved: (String value) => _email = value, 45 | validator: (String value) { 46 | if (value.isEmpty) { 47 | return '请输入邮箱'; 48 | } 49 | }, 50 | decoration: InputDecoration( 51 | labelText: '邮箱', 52 | suffixIcon: IconButton( 53 | icon: Icon( 54 | Icons.send, 55 | ), 56 | onPressed: () { 57 | _formKey.currentState.save(); 58 | _sendEmail(context); 59 | })), 60 | ); 61 | } 62 | 63 | 64 | 65 | Padding buildTitleLine() { 66 | return Padding( 67 | padding: EdgeInsets.only(left: 12.0, top: 4.0), 68 | child: Align( 69 | alignment: Alignment.bottomLeft, 70 | child: Container( 71 | color: Colors.black, 72 | width: 40.0, 73 | height: 2.0, 74 | ), 75 | ), 76 | ); 77 | } 78 | 79 | Padding buildTitle() { 80 | return Padding( 81 | padding: EdgeInsets.all(8.0), 82 | child: Text( 83 | '发送重置密码邮件', 84 | style: TextStyle(fontSize: 42.0), 85 | ), 86 | ); 87 | } 88 | 89 | ///发送重置密码邮件到邮箱 90 | _sendEmail(BuildContext context) { 91 | BmobUser bmobUser = BmobUser(); 92 | bmobUser.email = _email; 93 | bmobUser 94 | .requestPasswordResetByEmail() 95 | .then((BmobHandled bmobHandled) {}) 96 | .catchError((e) { 97 | showError(context, BmobError.convert(e).error); 98 | }); 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /data_demo/lib/page/user/user_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 2 | import 'package:data_plugin/bmob/response/bmob_handled.dart'; 3 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 4 | import 'package:data_plugin/utils/dialog_util.dart'; 5 | 6 | /** 7 | * home page 8 | */ 9 | import 'package:flutter/material.dart'; 10 | 11 | class UserPage extends StatefulWidget { 12 | UserPage({Key key, this.title}) : super(key: key); 13 | 14 | // This widget is the home page of your application. It is stateful, meaning 15 | // that it has a State object (defined below) that contains fields that affect 16 | // how it looks. 17 | 18 | // This class is the configuration for the state. It holds the values (in this 19 | // case the title) provided by the parent (in this case the App widget) and 20 | // used by the build method of the State. Fields in a Widget subclass are 21 | // always marked "final". 22 | 23 | final String title; 24 | 25 | @override 26 | _UserPageState createState() => _UserPageState(); 27 | } 28 | 29 | class _UserPageState extends State { 30 | @override 31 | Widget build(BuildContext context) { 32 | // This method is rerun every time setState is called, for instance as done 33 | // by the _incrementCounter method above. 34 | // 35 | // The Flutter framework has been optimized to make rerunning build methods 36 | // fast, so that you can just rebuild anything that needs updating rather 37 | // than having to individually change instances of widgets. 38 | return Scaffold( 39 | appBar: AppBar( 40 | // Here we take the value from the MyUserPage object that was created by 41 | // the App.build method, and use it to set our appbar title. 42 | title: Text(widget.title), 43 | ), 44 | body: new Container( 45 | margin: new EdgeInsets.all(10.0), 46 | child: new Column( 47 | children: [ 48 | ElevatedButton( 49 | onPressed: () { 50 | Navigator.pushNamed(context, "loginRoute"); 51 | }, 52 | child: 53 | new Text('登录', style: new TextStyle(color: Colors.white))), 54 | ElevatedButton( 55 | onPressed: () { 56 | Navigator.pushNamed(context, "registerRoute"); 57 | }, 58 | child: 59 | new Text('注册', style: new TextStyle(color: Colors.white))), 60 | ElevatedButton( 61 | onPressed: () { 62 | Navigator.pushNamed(context, "smsLoginRoute"); 63 | }, 64 | child: new Text('手机验证码登录', 65 | style: new TextStyle(color: Colors.white))), 66 | ElevatedButton( 67 | onPressed: () { 68 | Navigator.pushNamed(context, "emailResetRoute"); 69 | }, 70 | child: new Text('发送重置密码邮箱', 71 | style: new TextStyle(color: Colors.white))), 72 | ElevatedButton( 73 | onPressed: () { 74 | Navigator.pushNamed(context, "smsResetRoute"); 75 | }, 76 | child: new Text('短信重置密码', 77 | style: new TextStyle(color: Colors.white))), 78 | 79 | ], 80 | 81 | ), 82 | ), 83 | ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /data_demo/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: data_demo 2 | description: Bmob Data Flutter Demo. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 0.0.11 15 | 16 | environment: 17 | sdk: ">=2.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | 23 | 24 | # The following adds the Cupertino Icons font to your application. 25 | # Use with the CupertinoIcons class for iOS style icons. 26 | cupertino_icons: ^1.0.3 27 | # data_plugin: ^0.0.19 28 | data_plugin: 29 | path: ../data_plugin 30 | permission_handler: ^3.0.0 31 | 32 | dev_dependencies: 33 | flutter_test: 34 | sdk: flutter 35 | 36 | 37 | # For information on the generic Dart part of this file, see the 38 | # following page: https://www.dartlang.org/tools/pub/pubspec 39 | 40 | # The following section is specific to Flutter. 41 | flutter: 42 | 43 | # The following line ensures that the Material Icons font is 44 | # included with your application, so that you can use the icons in 45 | # the material Icons class. 46 | uses-material-design: true 47 | 48 | # To add assets to your application, add an assets section, like this: 49 | # assets: 50 | # - images/a_dot_burr.jpeg 51 | # - images/a_dot_ham.jpeg 52 | 53 | # An image asset can refer to one or more resolution-specific "variants", see 54 | # https://flutter.io/assets-and-images/#resolution-aware. 55 | 56 | # For details regarding adding assets from package dependencies, see 57 | # https://flutter.io/assets-and-images/#from-packages 58 | 59 | # To add custom fonts to your application, add a fonts section here, 60 | # in this "flutter" section. Each entry in this list should have a 61 | # "family" key with the font family name, and a "fonts" key with a 62 | # list giving the asset and other descriptors for the font. For 63 | # example: 64 | # fonts: 65 | # - family: Schyler 66 | # fonts: 67 | # - asset: fonts/Schyler-Regular.ttf 68 | # - asset: fonts/Schyler-Italic.ttf 69 | # style: italic 70 | # - family: Trajan Pro 71 | # fonts: 72 | # - asset: fonts/TrajanPro.ttf 73 | # - asset: fonts/TrajanPro_Bold.ttf 74 | # weight: 700 75 | # 76 | # For details regarding fonts from package dependencies, 77 | # see https://flutter.io/custom-fonts/#from-packages 78 | -------------------------------------------------------------------------------- /data_demo/res/values/strings_en.arb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_demo/res/values/strings_en.arb -------------------------------------------------------------------------------- /data_demo/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:data_demo/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(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 | -------------------------------------------------------------------------------- /data_plugin/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | .idea 4 | 5 | *.iml 6 | 7 | .packages 8 | .pub/ 9 | 10 | build/ 11 | -------------------------------------------------------------------------------- /data_plugin/.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: 8661d8aecd626f7f57ccbcb735553edc05a2e713 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /data_plugin/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /data_plugin/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /data_plugin/README.md: -------------------------------------------------------------------------------- 1 | # data_plugin 2 | 3 | Bmob Data Flutter plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter 8 | [plug-in package](https://flutter.io/developing-packages/), 9 | a specialized package that includes platform-specific implementation code for 10 | Android and/or iOS. 11 | 12 | For help getting started with Flutter, view our 13 | [online documentation](https://flutter.io/docs), which offers tutorials, 14 | samples, guidance on mobile development, and a full API reference. 15 | -------------------------------------------------------------------------------- /data_plugin/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /data_plugin/android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'cn.bmob.data_plugin' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.2.1' 12 | } 13 | } 14 | 15 | rootProject.allprojects { 16 | repositories { 17 | google() 18 | jcenter() 19 | } 20 | } 21 | 22 | apply plugin: 'com.android.library' 23 | 24 | android { 25 | compileSdkVersion 28 26 | 27 | defaultConfig { 28 | minSdkVersion 16 29 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 30 | } 31 | lintOptions { 32 | disable 'InvalidPackage' 33 | } 34 | } 35 | dependencies { 36 | implementation 'androidx.appcompat:appcompat:1.0.0-beta01' 37 | } -------------------------------------------------------------------------------- /data_plugin/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /data_plugin/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /data_plugin/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 27 12:53:57 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip 7 | -------------------------------------------------------------------------------- /data_plugin/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /data_plugin/android/res/values/strings_en.arb: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /data_plugin/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'data_plugin' 2 | -------------------------------------------------------------------------------- /data_plugin/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /data_plugin/example/.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 | # Visual Studio Code related 19 | .vscode/ 20 | 21 | # Flutter/Dart/Pub related 22 | **/doc/api/ 23 | .dart_tool/ 24 | .flutter-plugins 25 | .packages 26 | .pub-cache/ 27 | .pub/ 28 | /build/ 29 | 30 | # Android related 31 | **/android/**/gradle-wrapper.jar 32 | **/android/.gradle 33 | **/android/captures/ 34 | **/android/gradlew 35 | **/android/gradlew.bat 36 | **/android/local.properties 37 | **/android/**/GeneratedPluginRegistrant.java 38 | 39 | # iOS/XCode related 40 | **/ios/**/*.mode1v3 41 | **/ios/**/*.mode2v3 42 | **/ios/**/*.moved-aside 43 | **/ios/**/*.pbxuser 44 | **/ios/**/*.perspectivev3 45 | **/ios/**/*sync/ 46 | **/ios/**/.sconsign.dblite 47 | **/ios/**/.tags* 48 | **/ios/**/.vagrant/ 49 | **/ios/**/DerivedData/ 50 | **/ios/**/Icon? 51 | **/ios/**/Pods/ 52 | **/ios/**/.symlinks/ 53 | **/ios/**/profile 54 | **/ios/**/xcuserdata 55 | **/ios/.generated/ 56 | **/ios/Flutter/App.framework 57 | **/ios/Flutter/Flutter.framework 58 | **/ios/Flutter/Generated.xcconfig 59 | **/ios/Flutter/app.flx 60 | **/ios/Flutter/app.zip 61 | **/ios/Flutter/flutter_assets/ 62 | **/ios/ServiceDefinitions.json 63 | **/ios/Runner/GeneratedPluginRegistrant.* 64 | 65 | # Exceptions to above rules. 66 | !**/ios/**/default.mode1v3 67 | !**/ios/**/default.mode2v3 68 | !**/ios/**/default.pbxuser 69 | !**/ios/**/default.perspectivev3 70 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 71 | -------------------------------------------------------------------------------- /data_plugin/example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 8661d8aecd626f7f57ccbcb735553edc05a2e713 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /data_plugin/example/README.md: -------------------------------------------------------------------------------- 1 | # data_plugin_example 2 | 3 | Demonstrates how to use the data_plugin plugin. 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.io/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.io/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 26 | 27 | android { 28 | compileSdkVersion 28 29 | 30 | lintOptions { 31 | disable 'InvalidPackage' 32 | } 33 | 34 | defaultConfig { 35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 36 | applicationId "cn.bmob.data_plugin_example" 37 | minSdkVersion 16 38 | targetSdkVersion 28 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 42 | } 43 | 44 | buildTypes { 45 | release { 46 | // TODO: Add your own signing config for the release build. 47 | // Signing with the debug keys for now, so `flutter run --release` works. 48 | signingConfig signingConfigs.debug 49 | } 50 | } 51 | } 52 | 53 | flutter { 54 | source '../..' 55 | } 56 | 57 | dependencies { 58 | testImplementation 'junit:junit:4.12' 59 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 61 | } 62 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 25 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/java/cn/bmob/data_plugin_example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package cn.bmob.data_plugin_example; 2 | 3 | import android.os.Bundle; 4 | import io.flutter.app.FlutterActivity; 5 | import io.flutter.plugins.GeneratedPluginRegistrant; 6 | 7 | public class MainActivity extends FlutterActivity { 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | GeneratedPluginRegistrant.registerWith(this); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /data_plugin/example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_plugin/example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.2.1' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | google() 15 | jcenter() 16 | } 17 | } 18 | 19 | rootProject.buildDir = '../build' 20 | subprojects { 21 | project.buildDir = "${rootProject.buildDir}/${project.name}" 22 | } 23 | subprojects { 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /data_plugin/example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.enableJetifier=true 4 | android.useAndroidX=true -------------------------------------------------------------------------------- /data_plugin/example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /data_plugin/example/android/res/values/strings_en.arb: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /data_plugin/example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Flutter/flutter_export_environment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This is a generated file; do not edit or check into version control. 3 | export "FLUTTER_ROOT=/Users/quinn/flutter" 4 | export "FLUTTER_APPLICATION_PATH=/Users/quinn/Bmob/Github/bmob-flutter-sdk/data_plugin/example" 5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true" 6 | export "FLUTTER_TARGET=lib/main.dart" 7 | export "FLUTTER_BUILD_DIR=build" 8 | export "FLUTTER_BUILD_NAME=1.0.0" 9 | export "FLUTTER_BUILD_NUMBER=1" 10 | export "DART_OBFUSCATION=false" 11 | export "TRACK_WIDGET_CREATION=true" 12 | export "TREE_SHAKE_ICONS=false" 13 | export "PACKAGE_CONFIG=.dart_tool/package_config.json" 14 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def parse_KV_file(file, separator='=') 14 | file_abs_path = File.expand_path(file) 15 | if !File.exists? file_abs_path 16 | return []; 17 | end 18 | pods_ary = [] 19 | skip_line_start_symbols = ["#", "/"] 20 | File.foreach(file_abs_path) { |line| 21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } 22 | plugin = line.split(pattern=separator) 23 | if plugin.length == 2 24 | podname = plugin[0].strip() 25 | path = plugin[1].strip() 26 | podpath = File.expand_path("#{path}", file_abs_path) 27 | pods_ary.push({:name => podname, :path => podpath}); 28 | else 29 | puts "Invalid plugin specification: #{line}" 30 | end 31 | } 32 | return pods_ary 33 | end 34 | 35 | target 'Runner' do 36 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock 37 | # referring to absolute paths on developers' machines. 38 | system('rm -rf .symlinks') 39 | system('mkdir -p .symlinks/plugins') 40 | 41 | # Flutter Pods 42 | generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') 43 | if generated_xcode_build_settings.empty? 44 | puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." 45 | end 46 | generated_xcode_build_settings.map { |p| 47 | if p[:name] == 'FLUTTER_FRAMEWORK_DIR' 48 | symlink = File.join('.symlinks', 'flutter') 49 | File.symlink(File.dirname(p[:path]), symlink) 50 | pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) 51 | end 52 | } 53 | 54 | # Plugin Pods 55 | plugin_pods = parse_KV_file('../.flutter-plugins') 56 | plugin_pods.map { |p| 57 | symlink = File.join('.symlinks', 'plugins', p[:name]) 58 | File.symlink(p[:path], symlink) 59 | pod p[:name], :path => File.join(symlink, 'ios') 60 | } 61 | end 62 | 63 | post_install do |installer| 64 | installer.pods_project.targets.each do |target| 65 | target.build_configurations.each do |config| 66 | config.build_settings['ENABLE_BITCODE'] = 'NO' 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | data_plugin_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /data_plugin/example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /data_plugin/example/lib/bean/blog.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 4 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 5 | 6 | import 'package:data_plugin/bmob/type/bmob_geo_point.dart'; 7 | import 'package:data_plugin/bmob/type/bmob_date.dart'; 8 | import 'package:data_plugin/bmob/type/bmob_file.dart'; 9 | //此处与类名一致,由指令自动生成代码 10 | part 'blog.g.dart'; 11 | 12 | 13 | @JsonSerializable() 14 | class Blog extends BmobObject{ 15 | 16 | //博客标题 17 | String? title; 18 | //博客内容 19 | String? content; 20 | //博客作者 21 | BmobUser? author; 22 | int? like; 23 | BmobGeoPoint? addr; 24 | BmobDate? time; 25 | BmobFile? pic; 26 | Blog(); 27 | 28 | //此处与类名一致,由指令自动生成代码 29 | factory Blog.fromJson(Map json) => 30 | _$BlogFromJson(json); 31 | 32 | 33 | 34 | //此处与类名一致,由指令自动生成代码 35 | Map toJson() => _$BlogToJson(this); 36 | 37 | @override 38 | Map getParams() { 39 | // TODO: implement getParams 40 | return toJson(); 41 | } 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | } -------------------------------------------------------------------------------- /data_plugin/example/lib/bean/blog.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'blog.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Blog _$BlogFromJson(Map json) { 10 | return Blog() 11 | ..createdAt = json['createdAt'] as String? 12 | ..updatedAt = json['updatedAt'] as String? 13 | ..objectId = json['objectId'] as String? 14 | ..ACL = (json['ACL'] as Map?) as Map? 15 | ..title = json['title'] as String? 16 | ..content = json['content'] as String? 17 | ..author = json['author'] == null 18 | ? null 19 | : BmobUser.fromJson(json['author'] as Map) 20 | ..like = json['like'] as int? 21 | ..addr = json['addr'] == null 22 | ? null 23 | : BmobGeoPoint.fromJson(json['addr'] as Map) 24 | ..time = json['time'] == null 25 | ? null 26 | : BmobDate.fromJson(json['time'] as Map) 27 | ..pic = json['pic'] == null 28 | ? null 29 | : BmobFile.fromJson(json['pic'] as Map); 30 | } 31 | 32 | Map _$BlogToJson(Blog instance) => { 33 | 'createdAt': instance.createdAt, 34 | 'updatedAt': instance.updatedAt, 35 | 'objectId': instance.objectId, 36 | 'ACL': instance.ACL, 37 | 'title': instance.title, 38 | 'content': instance.content, 39 | 'author': instance.author, 40 | 'like': instance.like, 41 | 'addr': instance.addr, 42 | 'time': instance.time, 43 | 'pic': instance.pic 44 | }; 45 | -------------------------------------------------------------------------------- /data_plugin/example/lib/bean/user.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | part 'user.g.dart'; 5 | 6 | @JsonSerializable() 7 | class User extends BmobUser { 8 | factory User.fromJson(Map json) => _$UserFromJson(json); 9 | 10 | Map toJson() => _$UserToJson(this); 11 | 12 | int? age; 13 | int? gender; 14 | String? nickname; 15 | 16 | User(); 17 | 18 | 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /data_plugin/example/lib/bean/user.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'user.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | User _$UserFromJson(Map json) { 10 | return User() 11 | ..createdAt = json['createdAt'] as String? 12 | ..updatedAt = json['updatedAt'] as String? 13 | ..objectId = json['objectId'] as String? 14 | ..ACL = (json['ACL'] as Map?) as Map? 15 | ..username = json['username'] as String? 16 | ..password = json['password'] as String? 17 | ..email = json['email'] as String? 18 | ..emailVerified = json['emailVerified'] as bool? 19 | ..mobilePhoneNumber = json['mobilePhoneNumber'] as String? 20 | ..mobilePhoneNumberVerified = json['mobilePhoneNumberVerified'] as bool? 21 | ..sessionToken = json['sessionToken'] as String? 22 | ..age = json['age'] as int? 23 | ..gender = json['gender'] as int? 24 | ..nickname = json['nickname'] as String?; 25 | } 26 | 27 | Map _$UserToJson(User instance) => { 28 | 'createdAt': instance.createdAt, 29 | 'updatedAt': instance.updatedAt, 30 | 'objectId': instance.objectId, 31 | 'ACL': instance.ACL, 32 | 'username': instance.username, 33 | 'password': instance.password, 34 | 'email': instance.email, 35 | 'emailVerified': instance.emailVerified, 36 | 'mobilePhoneNumber': instance.mobilePhoneNumber, 37 | 'mobilePhoneNumberVerified': instance.mobilePhoneNumberVerified, 38 | 'sessionToken': instance.sessionToken, 39 | 'age': instance.age, 40 | 'gender': instance.gender, 41 | 'nickname': instance.nickname 42 | }; 43 | -------------------------------------------------------------------------------- /data_plugin/example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:data_plugin/bmob/bmob.dart'; 3 | import 'page/home_page.dart'; 4 | import 'page/object_page.dart'; 5 | import 'page/query/query_page.dart'; 6 | import 'page/query/query_statistics_page.dart'; 7 | import 'page/sms_page.dart'; 8 | import 'page/installation_page.dart'; 9 | import 'page/list_page.dart'; 10 | import 'page/file_page.dart'; 11 | import 'page/time_page.dart'; 12 | import 'page/pointer_page.dart'; 13 | import 'page/acl_page.dart'; 14 | import 'page/geo_point_page.dart'; 15 | import 'page/real_time_page.dart'; 16 | import 'page/order_page.dart'; 17 | import 'page/user/login_by_sms_page.dart'; 18 | import 'page/user/login_page.dart'; 19 | import 'page/user/register_page.dart'; 20 | import 'page/user/reset_by_email_page.dart'; 21 | import 'page/user/reset_by_sms_page.dart'; 22 | import 'page/user/user_page.dart'; 23 | 24 | void main() => runApp(MyApp()); 25 | 26 | class MyApp extends StatelessWidget { 27 | // This widget is the root of your application. 28 | @override 29 | Widget build(BuildContext context) { 30 | // /** 31 | // * 非加密方式初始化 32 | // */ 33 | // Bmob.init("https://api2.bmob.cn", "80c24431e79606ad4cac39e4b50d0ec9", 34 | // "1ffdda4ed16323500457d700d9d70065"); 35 | 36 | /** 37 | * 超级权限非加密方式初始化 38 | */ 39 | Bmob.initMasterKey( 40 | "https://api2.bmob.cn", 41 | "12784168944a56ae41c4575686b7b332", 42 | "9e8ffb8e0945092d1a6b3562741ae564", 43 | "0db392c02287a18bf05592d6d5221a6e"); 44 | // 45 | // /** 46 | // * 加密方式初始化 47 | // */ 48 | // Bmob.initEncryption("https://api2.bmob.cn", "3d53e458e911733e", "imdata"); 49 | // 50 | // /** 51 | // * 超级权限加密方式初始化 52 | // */ 53 | // Bmob.initEncryptionMasterKey("https://api2.bmob.cn", "3d53e458e911733e", 54 | // "imdata", "0db392c02287a18bf05592d6d5221a6e"); 55 | 56 | return MaterialApp( 57 | title: 'Flutter Bmob', 58 | theme: ThemeData( 59 | // This is the theme of your application. 60 | // 61 | // Try running your application with "flutter run". You'll see the 62 | // application has a blue toolbar. Then, without quitting the app, try 63 | // changing the primarySwatch below to Colors.green and then invoke 64 | // "hot reload" (press "r" in the console where you ran "flutter run", 65 | // or press Run > Flutter Hot Reload in IntelliJ). Notice that the 66 | // counter didn't reset back to zero; the application is not restarted. 67 | primarySwatch: Colors.blue, 68 | ), 69 | home: HomePage(title: 'Flutter Bmob'), 70 | routes: { 71 | 'loginRoute': (BuildContext context) => new LoginPage(), 72 | 'registerRoute': (BuildContext context) => new RegisterPage(), 73 | 'userRoute': (BuildContext context) => new UserPage(title: '用户管理'), 74 | 'installationRoute': (BuildContext context) => 75 | new InstallationPage(title: '设备管理'), 76 | 'objectRoute': (BuildContext context) => new ObjectPage(title: '数据操作'), 77 | 'smsRoute': (BuildContext context) => new SmsPage(), 78 | 'listRoute': (BuildContext context) => new ListPage(), 79 | 'fileRoute': (BuildContext context) => new FilePage(), 80 | 'timeRoute': (BuildContext context) => new TimePage(), 81 | 'queryRoute': (BuildContext context) => new QueryPage(), 82 | 'pointerRoute': (BuildContext context) => new PointerPage(), 83 | 'aclRoute': (BuildContext context) => new AclPage(), 84 | 'geoPointRoute': (BuildContext context) => new GeoPointPage(), 85 | 'realtimeRoute': (BuildContext context) => new RealTimePage(), 86 | 'orderRoute': (BuildContext context) => new OrderPage(), 87 | 'smsLoginRoute': (BuildContext context) => new SmsLoginPage(), 88 | 'smsResetRoute': (BuildContext context) => new SmsResetPage(), 89 | 'emailResetRoute': (BuildContext context) => new EmailResetPage(), 90 | 'statisticsQQueryRoute': (BuildContext context) => 91 | new QueryStatisticsPage(), 92 | }, 93 | ); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /data_plugin/example/lib/page/geo_point_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/utils/dialog_util.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:data_plugin/bmob/type/bmob_geo_point.dart'; 4 | import '../bean/blog.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 6 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 7 | import 'package:data_plugin/data_plugin.dart'; 8 | 9 | class GeoPointPage extends StatefulWidget { 10 | @override 11 | State createState() { 12 | // TODO: implement createState 13 | return _GeoPointPageState(); 14 | } 15 | } 16 | 17 | class _GeoPointPageState extends State { 18 | @override 19 | Widget build(BuildContext context) { 20 | // TODO: implement build 21 | return new Scaffold( 22 | appBar: AppBar( 23 | title: Text("地理位置"), 24 | ), 25 | body: new Container( 26 | child: new Column( 27 | children: [ 28 | ElevatedButton( 29 | onPressed: () { 30 | _addGeoPoint(); 31 | }, 32 | child: Text( 33 | "添加地理位置数据", 34 | style: TextStyle(color: Colors.white), 35 | ), 36 | ), 37 | ], 38 | ), 39 | ), 40 | ); 41 | } 42 | 43 | ///添加地理位置信息 44 | _addGeoPoint() { 45 | Blog blog = Blog(); 46 | BmobGeoPoint bmobGeoPoint = BmobGeoPoint(); 47 | bmobGeoPoint.latitude = 12.4445; 48 | bmobGeoPoint.longitude = 124.122; 49 | blog.addr = bmobGeoPoint; 50 | blog.save().then((BmobSaved bmobSaved) { 51 | String message = 52 | "创建一条数据成功:${bmobSaved.objectId} - ${bmobSaved.createdAt}"; 53 | showSuccess(context, message); 54 | }).catchError((e) { 55 | showError(context, BmobError.convert(e)!.error!); 56 | }); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /data_plugin/example/lib/page/list_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:data_plugin/bmob/bmob_query.dart'; 3 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 4 | import 'package:data_plugin/utils/dialog_util.dart'; 5 | 6 | import '../bean/blog.dart'; 7 | 8 | class ListPage extends StatefulWidget { 9 | @override 10 | State createState() { 11 | // TODO: implement createState 12 | return new Page(); 13 | } 14 | } 15 | 16 | class Page extends State { 17 | var _items = []; 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | // TODO: implement build 22 | return layout(context); 23 | } 24 | 25 | @override 26 | void initState() { 27 | // TODO: implement initState 28 | _queryList(context); 29 | super.initState(); 30 | } 31 | 32 | ///查询多条数据 33 | void _queryList(BuildContext context) { 34 | BmobQuery query = BmobQuery(); 35 | query.setInclude("author"); 36 | query.setLimit(10); 37 | query.setSkip(10); 38 | query.queryObjects().then((List? data) { 39 | List blogs = data!.map((i) => Blog.fromJson(i)).toList(); 40 | 41 | setState(() { 42 | _items = blogs; 43 | }); 44 | int index = 0; 45 | for (Blog blog in blogs) { 46 | index++; 47 | if (blog != null) { 48 | print(index); 49 | print(blog.objectId); 50 | print(blog.title); 51 | print(blog.content); 52 | if (blog.author != null) { 53 | print(blog.author!.objectId); 54 | print(blog.author!.username); 55 | } 56 | } 57 | } 58 | }).catchError((e) { 59 | showError(context, BmobError.convert(e)!.error!); 60 | }); 61 | } 62 | 63 | Widget layout(BuildContext context) { 64 | return new Scaffold( 65 | appBar: buildAppBar(context) as PreferredSizeWidget?, 66 | body: 67 | new ListView.builder(itemCount: _items.length, itemBuilder: itemView), 68 | ); 69 | } 70 | 71 | Widget buildAppBar(BuildContext context) { 72 | return new AppBar(title: const Text('列表查询')); 73 | } 74 | 75 | Widget itemView(BuildContext context, int index) { 76 | print("item $index"); 77 | Blog model = this._items[index]; 78 | //设置分割线 79 | return new Container( 80 | child: new Padding( 81 | padding: const EdgeInsets.all(8.0), 82 | child: new Padding( 83 | padding: const EdgeInsets.all(8.0), 84 | child: new Column( 85 | children: [ 86 | new Row( 87 | children: [ 88 | new Text('${model.title}', 89 | style: new TextStyle(fontSize: 15.0)), 90 | new Text('(${model.objectId})', 91 | style: new TextStyle(fontSize: 15.0)), 92 | new Text('(${model.createdAt})', 93 | style: new TextStyle(fontSize: 15.0)), 94 | ], 95 | ), 96 | new Center( 97 | heightFactor: 6.0, 98 | child: new Text("${model.content}\n第$index条数据", 99 | style: new TextStyle(fontSize: 17.0)), 100 | ), 101 | new Divider(height: 2.0), 102 | ], 103 | )))); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /data_plugin/example/lib/page/order_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:data_plugin/bmob/bmob_query.dart'; 4 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 5 | import 'package:data_plugin/utils/dialog_util.dart'; 6 | import '../bean/blog.dart'; 7 | 8 | class OrderPage extends StatefulWidget { 9 | @override 10 | State createState() { 11 | // TODO: implement createState 12 | return _OrderPageState(); 13 | } 14 | } 15 | 16 | class _OrderPageState extends State { 17 | @override 18 | Widget build(BuildContext context) { 19 | // TODO: implement build 20 | return new Scaffold( 21 | appBar: AppBar( 22 | title: Text("查询"), 23 | ), 24 | body: new Container( 25 | child: new Column( 26 | children: [ 27 | ElevatedButton( 28 | onPressed: () { 29 | _queryOrder(context); 30 | }, 31 | child: new Text('排序查询', 32 | style: new TextStyle(color: Colors.white))), 33 | ], 34 | ), 35 | ), 36 | ); 37 | } 38 | 39 | ///数据排序 40 | _queryOrder(BuildContext context) { 41 | BmobQuery query = BmobQuery(); 42 | query.setOrder("createdAt"); 43 | query.setLimit(10); 44 | query.setSkip(10); 45 | query.queryObjects().then((data) { 46 | List blogs = data!.map((i) => Blog.fromJson(i)).toList(); 47 | Navigator.pushNamed(context, "listRoute"); 48 | 49 | for (Blog blog in blogs) { 50 | if (blog != null) { 51 | print(blog.objectId); 52 | print(blog.title); 53 | print(blog.content); 54 | } 55 | } 56 | }).catchError((e) { 57 | showError(context, BmobError.convert(e)!.error!); 58 | }); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /data_plugin/example/lib/page/real_time_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 2 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 3 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 4 | import 'package:data_plugin/utils/dialog_util.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | import 'package:data_plugin/bmob/realtime/real_time_data_manager.dart'; 8 | import 'package:data_plugin/bmob/realtime/client.dart'; 9 | import 'package:data_plugin/bmob/realtime/change.dart'; 10 | import '../bean/blog.dart'; 11 | 12 | class RealTimePage extends StatefulWidget { 13 | @override 14 | _RealTimeState createState() { 15 | // TODO: implement createState 16 | return _RealTimeState(); 17 | } 18 | } 19 | 20 | class _RealTimeState extends State { 21 | @override 22 | Widget build(BuildContext context) { 23 | // TODO: implement build 24 | return new Scaffold( 25 | appBar: new AppBar( 26 | title: Text("其他操作"), 27 | ), 28 | body: new Container( 29 | margin: new EdgeInsets.all(10.0), 30 | child: new Column( 31 | children: [ 32 | ElevatedButton( 33 | onPressed: () { 34 | _listen(); 35 | }, 36 | child: new Text('开始监听', 37 | style: new TextStyle(color: Colors.white))), 38 | ElevatedButton( 39 | onPressed: () { 40 | _change(context); 41 | }, 42 | child: new Text('修改数据', 43 | style: new TextStyle(color: Colors.white))), 44 | ], 45 | ), 46 | ), 47 | ); 48 | } 49 | 50 | ///数据监听 51 | _listen() { 52 | RealTimeDataManager.getInstance()!.listen(onConnected: (Client client) { 53 | showSuccess(context, "监听数据连接成功,开始订阅消息!"); 54 | client.subTableUpdate("Blog"); 55 | }, onDisconnected: () { 56 | showError(context, "监听数据断开连接"); 57 | }, onDataChanged: (Change data) { 58 | ///注意:此处返回的data.data类型与Blog类型不一致,需要使用map来获取具体属性值而不是使用Blog 59 | Map? map = data.data; 60 | showSuccess(context, "监听到数据变化:" + map.toString()); 61 | }, onError: (error) { 62 | showError(context, error.toString()); 63 | }); 64 | } 65 | 66 | ///改编数据 67 | _change(context) { 68 | ///保存一条数据 69 | BmobUser bmobUser = BmobUser(); 70 | bmobUser.objectId = "7c7fd3afe1"; 71 | Blog blog = Blog(); 72 | blog.title = "博客标题"; 73 | blog.content = "博客内容"; 74 | blog.author = bmobUser; 75 | blog.like = 77; 76 | blog.save().then((BmobSaved bmobSaved) { 77 | String message = 78 | "创建一条数据成功:${bmobSaved.objectId} - ${bmobSaved.createdAt}"; 79 | showSuccess(context, message); 80 | }).catchError((e) { 81 | showError(context, BmobError.convert(e)!.error!); 82 | }); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /data_plugin/example/lib/page/time_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/utils/dialog_util.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:data_plugin/data_plugin.dart'; 4 | import 'package:data_plugin/bmob/response/server_time.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 6 | import 'package:data_plugin/bmob/bmob_date_manager.dart'; 7 | import '../bean/blog.dart'; 8 | import 'package:data_plugin/bmob/type/bmob_date.dart'; 9 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 10 | 11 | class TimePage extends StatefulWidget { 12 | @override 13 | State createState() { 14 | // TODO: implement createState 15 | return _OtherState(); 16 | } 17 | } 18 | 19 | class _OtherState extends State { 20 | @override 21 | Widget build(BuildContext context) { 22 | // TODO: implement build 23 | return new Scaffold( 24 | appBar: new AppBar( 25 | title: Text("其他操作"), 26 | ), 27 | body: new Container( 28 | margin: new EdgeInsets.all(10.0), 29 | child: new Column( 30 | children: [ 31 | ElevatedButton( 32 | onPressed: () { 33 | _getServerTime(); 34 | }, 35 | child: new Text('获取服务器时间', 36 | style: new TextStyle(color: Colors.white))), 37 | ElevatedButton( 38 | onPressed: () { 39 | _addDate(); 40 | }, 41 | child: new Text('添加时间类型', 42 | style: new TextStyle(color: Colors.white))), 43 | ElevatedButton( 44 | onPressed: () { 45 | _queryDate(); 46 | }, 47 | child: new Text('查询某个时间段数据', 48 | style: new TextStyle(color: Colors.white))), 49 | ], 50 | ), 51 | ), 52 | ); 53 | } 54 | 55 | ///获取服务器时间 56 | _getServerTime() { 57 | BmobDateManager.getServerTimestamp().then((ServerTime serverTime) { 58 | showSuccess(context, "${serverTime.timestamp}\n${serverTime.datetime}"); 59 | }).catchError((e) { 60 | showError(context, BmobError.convert(e)!.error!); 61 | }); 62 | } 63 | 64 | ///添加时间数据 65 | _addDate() { 66 | DateTime dateTime = DateTime.now(); 67 | BmobDate bmobDate = BmobDate(); 68 | bmobDate.setDate(dateTime); 69 | Blog blog = Blog(); 70 | blog.time = bmobDate; 71 | blog.title = "添加时间类型"; 72 | blog.content = "测试时间类型的请求"; 73 | blog.save().then((BmobSaved bmobSaved) { 74 | showSuccess(context, bmobSaved.objectId!); 75 | }).catchError((e) { 76 | showError(context, BmobError.convert(e)!.error!); 77 | }); 78 | } 79 | 80 | void _queryDate() { 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /data_plugin/example/lib/page/user/reset_by_email_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/bmob_handled.dart'; 2 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 3 | 4 | /** 5 | * login page 6 | */ 7 | import 'package:flutter/material.dart'; 8 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 9 | import 'package:data_plugin/utils/dialog_util.dart'; 10 | 11 | class EmailResetPage extends StatefulWidget { 12 | @override 13 | _EmailResetPageState createState() => _EmailResetPageState(); 14 | } 15 | 16 | class _EmailResetPageState extends State { 17 | final _formKey = GlobalKey(); 18 | String? _email; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return Scaffold( 23 | body: Form( 24 | key: _formKey, 25 | child: ListView( 26 | padding: EdgeInsets.symmetric(horizontal: 22.0), 27 | children: [ 28 | SizedBox( 29 | height: kToolbarHeight, 30 | ), 31 | buildTitle(), 32 | buildTitleLine(), 33 | SizedBox(height: 30.0), 34 | buildVerifyTextField(context), 35 | SizedBox(height: 30.0), 36 | ], 37 | ))); 38 | } 39 | 40 | 41 | 42 | TextFormField buildVerifyTextField(BuildContext context) { 43 | return TextFormField( 44 | onSaved: (String? value) => _email = value, 45 | validator: (String? value) { 46 | if (value!.isEmpty) { 47 | return '请输入邮箱'; 48 | } 49 | }, 50 | decoration: InputDecoration( 51 | labelText: '邮箱', 52 | suffixIcon: IconButton( 53 | icon: Icon( 54 | Icons.send, 55 | ), 56 | onPressed: () { 57 | _formKey.currentState!.save(); 58 | _sendEmail(context); 59 | })), 60 | ); 61 | } 62 | 63 | 64 | 65 | Padding buildTitleLine() { 66 | return Padding( 67 | padding: EdgeInsets.only(left: 12.0, top: 4.0), 68 | child: Align( 69 | alignment: Alignment.bottomLeft, 70 | child: Container( 71 | color: Colors.black, 72 | width: 40.0, 73 | height: 2.0, 74 | ), 75 | ), 76 | ); 77 | } 78 | 79 | Padding buildTitle() { 80 | return Padding( 81 | padding: EdgeInsets.all(8.0), 82 | child: Text( 83 | '发送重置密码邮件', 84 | style: TextStyle(fontSize: 42.0), 85 | ), 86 | ); 87 | } 88 | 89 | ///发送重置密码邮件到邮箱 90 | _sendEmail(BuildContext context) { 91 | BmobUser bmobUser = BmobUser(); 92 | bmobUser.email = _email; 93 | bmobUser 94 | .requestPasswordResetByEmail() 95 | .then((BmobHandled bmobHandled) {}) 96 | .catchError((e) { 97 | showError(context, BmobError.convert(e)!.error!); 98 | }); 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /data_plugin/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: data_plugin_example 2 | description: Demonstrates how to use the data_plugin plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: '>=2.12.0 <3.0.0' 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | 12 | # The following adds the Cupertino Icons font to your application. 13 | # Use with the CupertinoIcons class for iOS style icons. 14 | cupertino_icons: ^1.0.3 15 | 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | data_plugin: 22 | path: ../ 23 | 24 | # For information on the generic Dart part of this file, see the 25 | # following page: https://www.dartlang.org/tools/pub/pubspec 26 | 27 | # The following section is specific to Flutter. 28 | flutter: 29 | 30 | # The following line ensures that the Material Icons font is 31 | # included with your application, so that you can use the icons in 32 | # the material Icons class. 33 | uses-material-design: true 34 | 35 | # To add assets to your application, add an assets section, like this: 36 | # assets: 37 | # - images/a_dot_burr.jpeg 38 | # - images/a_dot_ham.jpeg 39 | 40 | # An image asset can refer to one or more resolution-specific "variants", see 41 | # https://flutter.io/assets-and-images/#resolution-aware. 42 | 43 | # For details regarding adding assets from package dependencies, see 44 | # https://flutter.io/assets-and-images/#from-packages 45 | 46 | # To add custom fonts to your application, add a fonts section here, 47 | # in this "flutter" section. Each entry in this list should have a 48 | # "family" key with the font family name, and a "fonts" key with a 49 | # list giving the asset and other descriptors for the font. For 50 | # example: 51 | # fonts: 52 | # - family: Schyler 53 | # fonts: 54 | # - asset: fonts/Schyler-Regular.ttf 55 | # - asset: fonts/Schyler-Italic.ttf 56 | # style: italic 57 | # - family: Trajan Pro 58 | # fonts: 59 | # - asset: fonts/TrajanPro.ttf 60 | # - asset: fonts/TrajanPro_Bold.ttf 61 | # weight: 700 62 | # 63 | # For details regarding fonts from package dependencies, 64 | # see https://flutter.io/custom-fonts/#from-packages 65 | -------------------------------------------------------------------------------- /data_plugin/example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility 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 | //import 'package:data_plugin_example/main.dart'; 11 | 12 | void main() { 13 | // testWidgets('Verify Platform version', (WidgetTester tester) async { 14 | // // Build our app and trigger a frame. 15 | // await tester.pumpWidget(MyApp()); 16 | // 17 | // // Verify that platform version is retrieved. 18 | // expect( 19 | // find.byWidgetPredicate( 20 | // (Widget widget) => widget is Text && 21 | // widget.data.startsWith('Running on:'), 22 | // ), 23 | // findsOneWidget, 24 | // ); 25 | // }); 26 | } 27 | -------------------------------------------------------------------------------- /data_plugin/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | -------------------------------------------------------------------------------- /data_plugin/ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /data_plugin/ios/Classes/DataPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface DataPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /data_plugin/ios/Classes/DataPlugin.m: -------------------------------------------------------------------------------- 1 | #import "DataPlugin.h" 2 | 3 | @implementation DataPlugin 4 | + (void)registerWithRegistrar:(NSObject*)registrar { 5 | FlutterMethodChannel* channel = [FlutterMethodChannel 6 | methodChannelWithName:@"data_plugin" 7 | binaryMessenger:[registrar messenger]]; 8 | DataPlugin* instance = [[DataPlugin alloc] init]; 9 | [registrar addMethodCallDelegate:instance channel:channel]; 10 | } 11 | 12 | - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { 13 | if ([@"getPlatformVersion" isEqualToString:call.method]) { 14 | result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]); 15 | } else { 16 | result(FlutterMethodNotImplemented); 17 | } 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /data_plugin/ios/data_plugin.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'data_plugin' 6 | s.version = '0.0.1' 7 | s.summary = 'Bmob Data Flutter plugin.' 8 | s.description = <<-DESC 9 | Bmob Data Flutter plugin. 10 | DESC 11 | s.homepage = 'http://example.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Your Company' => 'email@example.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.deployment_target = '8.0' 20 | end 21 | 22 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob.dart: -------------------------------------------------------------------------------- 1 | class Bmob { 2 | //Bmob REST API 地址 3 | static String bmobHost = "https://api2.bmob.cn"; 4 | 5 | //Bmob 应用ID,不可泄漏 6 | static String bmobAppId = ""; 7 | 8 | //Bmob REST API 密钥,不可泄漏 9 | static String bmobRestApiKey = ""; 10 | 11 | //Bmob REST API 管理密钥 超级权限Key,不可泄漏 12 | static String bmobMasterKey = ""; 13 | 14 | //SDK安全密钥,不可泄漏 15 | static String bmobSecretKey = ""; 16 | 17 | //SDK安全码,不可泄漏 18 | static String bmobApiSafe = ""; 19 | 20 | //固定 21 | static final String bmobSDKType = "Flutter"; 22 | 23 | //固定 24 | static final String bmobSDKVersion = "10"; 25 | 26 | static const String BMOB_PROPERTY_OBJECT_ID = "objectId"; 27 | static const String BMOB_PROPERTY_CREATED_AT = "createdAt"; 28 | static const String BMOB_PROPERTY_UPDATED_AT = "updatedAt"; 29 | static const String BMOB_PROPERTY_SESSION_TOKEN = "sessionToken"; 30 | 31 | static const String BMOB_KEY_TYPE = "__type"; 32 | static const String BMOB_KEY_CLASS_NAME = "className"; 33 | static const String BMOB_KEY_RESULTS = "results"; 34 | 35 | static const String BMOB_API_VERSION = "/1"; 36 | static const String BMOB_API_FILE_VERSION = "/2"; 37 | static const String BMOB_API_CLASSES = BMOB_API_VERSION + "/classes/"; 38 | static const String BMOB_API_USERS = BMOB_API_VERSION + "/users"; 39 | 40 | static const String BMOB_API_REQUEST_PASSWORD_RESET = 41 | BMOB_API_VERSION + "/requestPasswordReset"; 42 | 43 | static const String BMOB_API_REQUEST_PASSWORD_BY_SMS_CODE = 44 | BMOB_API_VERSION + "/resetPasswordBySmsCode"; 45 | 46 | static const String BMOB_API_REQUEST_UPDATE_USER_PASSWORD = 47 | BMOB_API_VERSION + "/updateUserPassword"; 48 | 49 | static const String BMOB_API_BATCH = BMOB_API_VERSION + "/batch"; 50 | 51 | static const String BMOB_API_REQUEST_REQUEST_EMAIL_VERIFY = 52 | BMOB_API_VERSION + "/requestEmailVerify"; 53 | 54 | static const String BMOB_API_LOGIN = BMOB_API_VERSION + "/login"; 55 | static const String BMOB_API_SLASH = "/"; 56 | static const String BMOB_API_SEND_SMS_CODE = 57 | BMOB_API_VERSION + "/requestSmsCode"; 58 | static const String BMOB_API_VERIFY_SMS_CODE = 59 | BMOB_API_VERSION + "/verifySmsCode/"; 60 | static const String BMOB_API_TIMESTAMP = "/timestamp"; 61 | static const String BMOB_API_FILE = "/files"; 62 | 63 | static const String BMOB_TYPE_POINTER = "Pointer"; 64 | 65 | static const String BMOB_CLASS_BMOB_USER = "BmobUser"; 66 | 67 | static const String BMOB_CLASS_BMOB_INSTALLATION = "BmobInstallation"; 68 | 69 | static const String BMOB_TABLE_USER = "_User"; 70 | 71 | static const String BMOB_TABLE_INSTALLATION = "_Installation"; 72 | 73 | static const String BMOB_ERROR_OBJECT_ID = "ObjectId is null or empty."; 74 | 75 | static const int BMOB_ERROR_CODE_LOCAL = 1001; 76 | 77 | static const String BMOB_TABLE_TOLE = "_Role"; 78 | 79 | //SDK初始化 80 | static void init(appHost, appId, apiKey) { 81 | bmobHost = appHost; 82 | bmobAppId = appId; 83 | bmobRestApiKey = apiKey; 84 | } 85 | 86 | //SDK初始化,包含master key,允许操作其他用户 87 | static void initMasterKey(appHost, appId, apiKey, masterKey) { 88 | init(appHost, appId, apiKey); 89 | bmobMasterKey = masterKey; 90 | } 91 | 92 | //SDK初始化,加密请求格式 93 | static void initEncryption(appHost, secretKey, apiSafe) { 94 | bmobHost = appHost; 95 | bmobSecretKey = secretKey; 96 | bmobApiSafe = apiSafe; 97 | } 98 | 99 | //SDK初始化,加密请求格式,包含master key,允许操作其他用户 100 | static void initEncryptionMasterKey(appHost, secretKey, apiSafe, masterKey) { 101 | initEncryption(appHost, secretKey, apiSafe); 102 | bmobMasterKey = masterKey; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_batch.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:data_plugin/bmob/bmob.dart'; 4 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 5 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 6 | import 'package:shared_preferences/shared_preferences.dart'; 7 | 8 | import 'bmob_dio.dart'; 9 | 10 | class BmobBatch { 11 | Future insertBatch(List bmobObjects) async { 12 | return process("POST", bmobObjects); 13 | } 14 | 15 | Future deleteBatch(List bmobObjects) async { 16 | return process("DELETE", bmobObjects); 17 | } 18 | 19 | Future updateBatch(List bmobObjects) async { 20 | return process("PUT", bmobObjects); 21 | } 22 | 23 | Future process(String method, List bmobObjects) async { 24 | List list = List.empty(growable: true); 25 | Map params = Map(); 26 | 27 | SharedPreferences prefs = await SharedPreferences.getInstance(); 28 | String? userJson = prefs.get("user") as String?; 29 | print(userJson); 30 | BmobUser? bmobUser; 31 | if (userJson != null) { 32 | bmobUser = json.decode(userJson); 33 | } 34 | 35 | for (BmobObject bmobObject in bmobObjects) { 36 | if (bmobObject is BmobUser) { 37 | //过滤BmobUser类型的处理,因为批处理操作不支持对User表的操作 38 | print("BmobUser does not support batch operations"); 39 | } else { 40 | Map single = Map(); 41 | single["method"] = method; 42 | if (method == "PUT" || method == "DELETE") { 43 | //批量更新和批量删除 44 | if (userJson != null) { 45 | single["token"] = bmobUser!.sessionToken; 46 | } 47 | single["path"] = Bmob.BMOB_API_CLASSES + 48 | bmobObject.runtimeType.toString() + 49 | "/" + 50 | bmobObject.objectId!; 51 | } else { 52 | //批量添加 53 | single["path"] = 54 | Bmob.BMOB_API_CLASSES + bmobObject.runtimeType.toString(); 55 | } 56 | 57 | Map body = bmobObject.getParams(); 58 | Map tmp = bmobObject.getParams(); 59 | tmp.forEach((key, value) { 60 | if (value == null) { 61 | body.remove(key); 62 | } 63 | }); 64 | single["body"] = body; 65 | 66 | body.remove("objectId"); 67 | body.remove("createdAt"); 68 | body.remove("updatedAt"); 69 | 70 | list.add(single); 71 | } 72 | } 73 | params["requests"] = list; 74 | print(params.toString()); 75 | 76 | List responseData = 77 | await BmobDio.getInstance().post(Bmob.BMOB_API_BATCH, data: params); 78 | 79 | print(responseData.toString()); 80 | 81 | return list; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_date_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/server_time.dart'; 2 | 3 | import 'bmob.dart'; 4 | import 'bmob_dio.dart'; 5 | 6 | class BmobDateManager { 7 | ///查询服务器时间 8 | static Future getServerTimestamp() async { 9 | Map data = await BmobDio.getInstance() 10 | .get(Bmob.BMOB_API_VERSION + Bmob.BMOB_API_TIMESTAMP); 11 | ServerTime serverTime = ServerTime.fromJson(data); 12 | return serverTime; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_file_manager.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:typed_data'; 3 | import 'bmob_dio.dart'; 4 | import 'bmob.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_handled.dart'; 6 | 7 | import 'package:data_plugin/bmob/type/bmob_file.dart'; 8 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 9 | 10 | class BmobFileManager { 11 | ///文件上传 12 | ///method:POST 13 | ///body:文本或者二进制流 14 | ///Content-Type:不同类型文件使用不同的值 15 | static Future upload(File file) async { 16 | String allPath = file.path; 17 | int indexSlash = allPath.lastIndexOf("/"); 18 | if (file == null) { 19 | throw BmobError(9016, "The file is null."); 20 | } 21 | if (indexSlash == -1) { 22 | throw BmobError(9016, "The file's path is available."); 23 | } 24 | String fileName = allPath.substring(indexSlash, allPath.length); 25 | int indexPoint = fileName.indexOf("."); 26 | bool one = indexPoint < fileName.length - 1; 27 | bool two = fileName.contains("."); 28 | bool hasSuffix = one && two; 29 | if (!hasSuffix) { 30 | throw BmobError(9016, "The file has no suffix."); 31 | } 32 | 33 | String path = "${Bmob.BMOB_API_FILE_VERSION}${Bmob.BMOB_API_FILE}$fileName"; 34 | 35 | 36 | //获取所上传文件的二进制流 37 | var responseData = await BmobDio.getInstance().upload(path, data: file.readAsBytes()); 38 | BmobFile bmobFile = BmobFile.fromJson(responseData); 39 | return bmobFile; 40 | } 41 | 42 | ///文件删除 43 | ///method:delete 44 | ///http://bmob-cdn-18925.b0.upaiyun.com/2019/03/25/f425482f73e646a6a425d746764c3b6c.jpg 45 | static Future delete(String url) async { 46 | if (url == null || url.isEmpty) { 47 | throw BmobError(9015, "The url is null or empty."); 48 | } 49 | 50 | String domain = "upaiyun.com"; 51 | int indexDomain = url.indexOf(domain); 52 | if (indexDomain == -1) { 53 | throw BmobError(9015, "The url is not a upaiyun's url."); 54 | } 55 | int indexHead = indexDomain + domain.length; 56 | int indexTail = url.length; 57 | String fileUrl = url.substring(indexHead, indexTail); 58 | String path = "${Bmob.BMOB_API_FILE_VERSION}${Bmob.BMOB_API_FILE}/upyun$fileUrl"; 59 | 60 | var responseData = await BmobDio.getInstance().delete(path); 61 | BmobHandled bmobHandled = BmobHandled.fromJson(responseData); 62 | 63 | return bmobHandled; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_installation_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/bmob.dart'; 2 | import 'package:data_plugin/bmob/bmob_query.dart'; 3 | import 'package:data_plugin/bmob/table/bmob_installation.dart'; 4 | import 'package:data_plugin/data_plugin.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 6 | import 'package:data_plugin/bmob/response/bmob_saved.dart'; 7 | 8 | class BmobInstallationManager { 9 | //TODO 获取android installationId 10 | static Future getInstallationId() async { 11 | var installationId = await DataPlugin.installationId; 12 | return installationId; 13 | } 14 | 15 | //TODO 初始化设备信息 16 | static Future init() async { 17 | String? installationId = await getInstallationId(); 18 | BmobQuery bmobQuery = BmobQuery(); 19 | bmobQuery.addWhereEqualTo("installationId", installationId); 20 | 21 | List responseData = await bmobQuery.queryInstallations(); 22 | List installations = 23 | responseData.map((i) => BmobInstallation.fromJson(i)).toList(); 24 | 25 | if (installations.isNotEmpty) { 26 | BmobInstallation installation = installations[0]; 27 | return installation; 28 | } else { 29 | BmobInstallation bmobInstallation = BmobInstallation(); 30 | bmobInstallation.installationId = installationId; 31 | bmobInstallation.save(); 32 | return bmobInstallation; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_query.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_query.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobQuery _$BmobQueryFromJson(Map json) { 10 | return BmobQuery() 11 | ..include = json['include'] as String? 12 | ..limit = json['limit'] as int? 13 | ..skip = json['skip'] as int? 14 | ..order = json['order'] as String? 15 | ..count = json['count'] as int? 16 | ..where = json['where'] as Map? 17 | ..having = json['having'] as Map? 18 | ..groupby = json['groupby'] as String? 19 | ..sum = json['sum'] as String? 20 | ..average = json['average'] as String? 21 | ..max = json['max'] as String? 22 | ..min = json['min'] as String? 23 | ..groupcount = json['groupcount'] as bool?; 24 | } 25 | 26 | Map _$BmobQueryToJson(BmobQuery instance) => 27 | { 28 | 'include': instance.include, 29 | 'limit': instance.limit, 30 | 'skip': instance.skip, 31 | 'order': instance.order, 32 | 'count': instance.count, 33 | 'where': instance.where, 34 | 'having': instance.having, 35 | 'groupby': instance.groupby, 36 | 'sum': instance.sum, 37 | 'average': instance.average, 38 | 'max': instance.max, 39 | 'min': instance.min, 40 | 'groupcount': instance.groupcount 41 | }; 42 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_sms.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/bmob_dio.dart'; 2 | import 'package:data_plugin/bmob/bmob.dart'; 3 | 4 | import 'package:json_annotation/json_annotation.dart'; 5 | import 'package:data_plugin/bmob/response/bmob_handled.dart'; 6 | import 'package:data_plugin/bmob/response/bmob_sent.dart'; 7 | 8 | //此处与类名一致,由指令自动生成代码 9 | part 'bmob_sms.g.dart'; 10 | 11 | @JsonSerializable() 12 | class BmobSms { 13 | String? mobilePhoneNumber; 14 | String? template; 15 | 16 | BmobSms(); 17 | 18 | ///查询单条数据 19 | Future sendSms() async { 20 | Map responseData = await (BmobDio.getInstance().post( 21 | Bmob.BMOB_API_SEND_SMS_CODE, data: getParams()) ); 22 | BmobSent sent = BmobSent.fromJson(responseData as Map); 23 | return sent; 24 | } 25 | 26 | ///查询多条数据 27 | Future verifySmsCode(smsCode) async { 28 | Map params = getParams(); 29 | params.remove("template"); 30 | Map responseData = await (BmobDio.getInstance() 31 | .post(Bmob.BMOB_API_VERIFY_SMS_CODE + smsCode, data: params) ); 32 | BmobHandled bmobHandled = BmobHandled.fromJson(responseData as Map); 33 | return bmobHandled; 34 | } 35 | 36 | //此处与类名一致,由指令自动生成代码 37 | factory BmobSms.fromJson(Map json) => 38 | _$BmobSmsFromJson(json); 39 | 40 | //此处与类名一致,由指令自动生成代码 41 | Map toJson() => _$BmobSmsToJson(this); 42 | 43 | 44 | ///获取请求参数 45 | Map getParams() { 46 | Map map = toJson(); 47 | Map params = toJson(); 48 | map.forEach((k, v) { 49 | if (v == null) { 50 | params.remove(k); 51 | } 52 | }); 53 | return params; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_sms.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_sms.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobSms _$BmobSmsFromJson(Map json) { 10 | return BmobSms() 11 | ..mobilePhoneNumber = json['mobilePhoneNumber'] as String? 12 | ..template = json['template'] as String?; 13 | } 14 | 15 | Map _$BmobSmsToJson(BmobSms instance) => { 16 | 'mobilePhoneNumber': instance.mobilePhoneNumber, 17 | 'template': instance.template 18 | }; 19 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/bmob_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/bmob.dart'; 2 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 3 | import 'package:data_plugin/bmob/table/bmob_user.dart'; 4 | import 'package:data_plugin/bmob/table/bmob_installation.dart'; 5 | import 'package:data_plugin/bmob/table/bmob_role.dart'; 6 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 7 | 8 | class BmobUtils { 9 | ///获取BmobObject对象的表名 10 | static String getTableName(BmobObject object) { 11 | if (!(object is BmobObject)) { 12 | throw new BmobError(1002, "The object is not a BmobObject."); 13 | } 14 | String tableName; 15 | if (object is BmobUser) { 16 | tableName = Bmob.BMOB_TABLE_USER; 17 | } else if (object is BmobInstallation) { 18 | tableName = Bmob.BMOB_TABLE_INSTALLATION; 19 | } else if (object is BmobRole) { 20 | tableName = Bmob.BMOB_TABLE_TOLE; 21 | } else { 22 | tableName = object.runtimeType.toString(); 23 | } 24 | return tableName; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/realtime/change.dart: -------------------------------------------------------------------------------- 1 | library change; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | part 'change.g.dart'; 6 | 7 | @JsonSerializable() 8 | class Change { 9 | factory Change.fromJson(Map json) => _$ChangeFromJson(json); 10 | 11 | Map toJson() => _$ChangeToJson(this); 12 | 13 | String? appKey; 14 | String? tableName; 15 | String? objectId; 16 | String? action; 17 | Map? data; 18 | 19 | Change(); 20 | } 21 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/realtime/change.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of change; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Change _$ChangeFromJson(Map json) { 10 | return Change() 11 | ..appKey = json['appKey'] as String? 12 | ..tableName = json['tableName'] as String? 13 | ..objectId = json['objectId'] as String? 14 | ..action = json['action'] as String? 15 | ..data = json['data'] as Map?; 16 | } 17 | 18 | Map _$ChangeToJson(Change instance) => { 19 | 'appKey': instance.appKey, 20 | 'tableName': instance.tableName, 21 | 'objectId': instance.objectId, 22 | 'action': instance.action, 23 | 'data': instance.data 24 | }; 25 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/realtime/message.dart: -------------------------------------------------------------------------------- 1 | library message; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | part 'message.g.dart'; 6 | 7 | @JsonSerializable() 8 | class Message { 9 | factory Message.fromJson(Map json) => 10 | _$MessageFromJson(json); 11 | 12 | Map toJson() => _$MessageToJson(this); 13 | 14 | String? name; 15 | List? args; 16 | 17 | Message(); 18 | } 19 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/realtime/message.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of message; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | Message _$MessageFromJson(Map json) { 10 | return Message() 11 | ..name = json['name'] as String? 12 | ..args = (json['args'] as List?)?.map((e) => e as String)?.toList(); 13 | } 14 | 15 | Map _$MessageToJson(Message instance) => 16 | {'name': instance.name, 'args': instance.args}; 17 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/realtime/real_time_data_manager.dart: -------------------------------------------------------------------------------- 1 | import 'client.dart'; 2 | 3 | import 'dart:async'; 4 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 5 | import 'package:data_plugin/bmob/realtime/change.dart'; 6 | 7 | class RealTimeDataManager { 8 | static RealTimeDataManager? instance; 9 | 10 | RealTimeDataManager(); 11 | 12 | ///单例 13 | static RealTimeDataManager? getInstance() { 14 | if (instance == null) { 15 | instance = new RealTimeDataManager(); 16 | } 17 | return instance; 18 | } 19 | 20 | ///数据监听 21 | Future listen({onConnected, onDisconnected, onDataChanged, onError}) async { 22 | Client client = Client(); 23 | client.listen(connectedCallback: (Client client) { 24 | onConnected(client); 25 | }, disconnectedCallback: (Client client) { 26 | onDisconnected(client); 27 | }, dataChangedCallback: (Change change) { 28 | onDataChanged(change); 29 | }, errorCallback: (BmobError error) { 30 | onError(error); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_error.dart: -------------------------------------------------------------------------------- 1 | import 'package:dio/dio.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_error.g.dart'; 6 | 7 | @JsonSerializable() 8 | class BmobError extends Error { 9 | int? code; 10 | String? error; 11 | 12 | BmobError(this.code, this.error); 13 | 14 | //此处与类名一致,由指令自动生成代码 15 | factory BmobError.fromJson(Map json) => 16 | _$BmobErrorFromJson(json); 17 | 18 | //此处与类名一致,由指令自动生成代码 19 | Map toJson() => _$BmobErrorToJson(this); 20 | 21 | String toString() => "BmobError [$code]:" + error!; 22 | 23 | //转化DioError错误为BmobError类型 24 | static BmobError? convert(e) { 25 | BmobError? bmobError; 26 | 27 | if (e is BmobError) { 28 | bmobError = e; 29 | } else if (e is DioError) { 30 | DioError dioError = e; 31 | switch (dioError.type) { 32 | case DioErrorType.sendTimeout: 33 | bmobError = BmobError(9015, dioError.message); 34 | break; 35 | case DioErrorType.other: 36 | bmobError = BmobError(9015, dioError.message); 37 | break; 38 | case DioErrorType.cancel: 39 | bmobError = BmobError(9015, dioError.message); 40 | break; 41 | case DioErrorType.receiveTimeout: 42 | bmobError = BmobError(9015, dioError.message); 43 | break; 44 | case DioErrorType.response: 45 | bmobError = BmobError( 46 | dioError.response?.data['code'], dioError.response?.data['error']); 47 | break; 48 | case DioErrorType.connectTimeout: 49 | bmobError = BmobError(9015, dioError.message); 50 | break; 51 | } 52 | } else { 53 | bmobError = BmobError(9015, e.toString()); 54 | } 55 | 56 | return bmobError; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_error.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_error.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobError _$BmobErrorFromJson(Map json) { 10 | return BmobError(json['code'] as int?, json['error'] as String?); 11 | } 12 | 13 | Map _$BmobErrorToJson(BmobError instance) => 14 | {'code': instance.code, 'error': instance.error}; 15 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_handled.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_handled.g.dart'; 6 | 7 | 8 | @JsonSerializable() 9 | class BmobHandled{ 10 | String? msg; 11 | 12 | BmobHandled(); 13 | 14 | //此处与类名一致,由指令自动生成代码 15 | factory BmobHandled.fromJson(Map json) => 16 | _$BmobHandledFromJson(json); 17 | 18 | //此处与类名一致,由指令自动生成代码 19 | Map toJson() => _$BmobHandledToJson(this); 20 | 21 | 22 | 23 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_handled.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_handled.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobHandled _$BmobHandledFromJson(Map json) { 10 | return BmobHandled()..msg = json['msg'] as String?; 11 | } 12 | 13 | Map _$BmobHandledToJson(BmobHandled instance) => 14 | {'msg': instance.msg}; 15 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_pointer.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_pointer.g.dart'; 6 | 7 | 8 | @JsonSerializable() 9 | class BmobPointer{ 10 | String? __type; 11 | String? className; 12 | String? objectId; 13 | 14 | BmobPointer(); 15 | 16 | //此处与类名一致,由指令自动生成代码 17 | factory BmobPointer.fromJson(Map json) => 18 | _$BmobPointerFromJson(json); 19 | 20 | //此处与类名一致,由指令自动生成代码 21 | Map toJson() => _$BmobPointerToJson(this); 22 | 23 | 24 | 25 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_pointer.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_pointer.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobPointer _$BmobPointerFromJson(Map json) { 10 | return BmobPointer() 11 | ..className = json['className'] as String? 12 | ..objectId = json['objectId'] as String?; 13 | } 14 | 15 | Map _$BmobPointerToJson(BmobPointer instance) => 16 | { 17 | 'className': instance.className, 18 | 'objectId': instance.objectId 19 | }; 20 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_registered.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_registered.g.dart'; 6 | 7 | 8 | @JsonSerializable() 9 | class BmobRegistered{ 10 | String? createdAt; 11 | String? objectId; 12 | String? sessionToken; 13 | 14 | BmobRegistered(); 15 | 16 | //此处与类名一致,由指令自动生成代码 17 | factory BmobRegistered.fromJson(Map json) => 18 | _$BmobRegisteredFromJson(json); 19 | 20 | //此处与类名一致,由指令自动生成代码 21 | Map toJson() => _$BmobRegisteredToJson(this); 22 | 23 | 24 | 25 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_registered.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_registered.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobRegistered _$BmobRegisteredFromJson(Map json) { 10 | return BmobRegistered() 11 | ..createdAt = json['createdAt'] as String? 12 | ..objectId = json['objectId'] as String? 13 | ..sessionToken = json['sessionToken'] as String?; 14 | } 15 | 16 | Map _$BmobRegisteredToJson(BmobRegistered instance) => 17 | { 18 | 'createdAt': instance.createdAt, 19 | 'objectId': instance.objectId, 20 | 'sessionToken': instance.sessionToken 21 | }; 22 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_results.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_results.g.dart'; 6 | 7 | 8 | @JsonSerializable() 9 | class BmobResults{ 10 | List? results; 11 | int? count; 12 | 13 | BmobResults(); 14 | 15 | //此处与类名一致,由指令自动生成代码 16 | factory BmobResults.fromJson(Map json) => 17 | _$BmobResultsFromJson(json); 18 | 19 | //此处与类名一致,由指令自动生成代码 20 | Map toJson() => _$BmobResultsToJson(this); 21 | 22 | 23 | 24 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_results.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_results.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobResults _$BmobResultsFromJson(Map json) { 10 | return BmobResults() 11 | ..results = json['results'] as List? 12 | ..count = json['count'] as int?; 13 | } 14 | 15 | Map _$BmobResultsToJson(BmobResults instance) => 16 | {'results': instance.results, 'count': instance.count}; 17 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_saved.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_saved.g.dart'; 6 | 7 | 8 | @JsonSerializable() 9 | class BmobSaved{ 10 | String? createdAt; 11 | String? objectId; 12 | 13 | 14 | BmobSaved(); 15 | 16 | //此处与类名一致,由指令自动生成代码 17 | factory BmobSaved.fromJson(Map json) => 18 | _$BmobSavedFromJson(json); 19 | 20 | //此处与类名一致,由指令自动生成代码 21 | Map toJson() => _$BmobSavedToJson(this); 22 | 23 | 24 | 25 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_saved.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_saved.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobSaved _$BmobSavedFromJson(Map json) { 10 | return BmobSaved() 11 | ..createdAt = json['createdAt'] as String? 12 | ..objectId = json['objectId'] as String?; 13 | } 14 | 15 | Map _$BmobSavedToJson(BmobSaved instance) => { 16 | 'createdAt': instance.createdAt, 17 | 'objectId': instance.objectId 18 | }; 19 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_sent.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | 4 | //此处与类名一致,由指令自动生成代码 5 | part 'bmob_sent.g.dart'; 6 | 7 | 8 | @JsonSerializable() 9 | class BmobSent{ 10 | int? smsId; 11 | 12 | BmobSent(); 13 | 14 | //此处与类名一致,由指令自动生成代码 15 | factory BmobSent.fromJson(Map json) => 16 | _$BmobSentFromJson(json); 17 | 18 | //此处与类名一致,由指令自动生成代码 19 | Map toJson() => _$BmobSentToJson(this); 20 | 21 | 22 | 23 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_sent.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_sent.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobSent _$BmobSentFromJson(Map json) { 10 | return BmobSent()..smsId = json['smsId'] as int?; 11 | } 12 | 13 | Map _$BmobSentToJson(BmobSent instance) => 14 | {'smsId': instance.smsId}; 15 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_updated.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | //此处与类名一致,由指令自动生成代码 4 | part 'bmob_updated.g.dart'; 5 | 6 | 7 | @JsonSerializable() 8 | class BmobUpdated{ 9 | String? updatedAt; 10 | 11 | BmobUpdated(); 12 | 13 | //此处与类名一致,由指令自动生成代码 14 | factory BmobUpdated.fromJson(Map json) => 15 | _$BmobUpdatedFromJson(json); 16 | 17 | //此处与类名一致,由指令自动生成代码 18 | Map toJson() => _$BmobUpdatedToJson(this); 19 | 20 | 21 | 22 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/bmob_updated.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_updated.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobUpdated _$BmobUpdatedFromJson(Map json) { 10 | return BmobUpdated()..updatedAt = json['updatedAt'] as String?; 11 | } 12 | 13 | Map _$BmobUpdatedToJson(BmobUpdated instance) => 14 | {'updatedAt': instance.updatedAt}; 15 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/server_time.dart: -------------------------------------------------------------------------------- 1 | library servertime; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | part 'server_time.g.dart'; 6 | 7 | @JsonSerializable() 8 | class ServerTime { 9 | int? timestamp; 10 | String? datetime; 11 | 12 | ServerTime(); 13 | 14 | factory ServerTime.fromJson(Map json) => 15 | _$ServerTimeFromJson(json); 16 | 17 | Map toJson(ServerTime instance) => 18 | _$ServerTimeToJson(instance); 19 | } 20 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/response/server_time.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of servertime; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | ServerTime _$ServerTimeFromJson(Map json) { 10 | return ServerTime() 11 | ..timestamp = json['timestamp'] as int? 12 | ..datetime = json['datetime'] as String?; 13 | } 14 | 15 | Map _$ServerTimeToJson(ServerTime instance) => 16 | { 17 | 'timestamp': instance.timestamp, 18 | 'datetime': instance.datetime 19 | }; 20 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/table/bmob_installation.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 2 | import 'package:json_annotation/json_annotation.dart'; 3 | //此处与类名一致,由指令自动生成代码 4 | part 'bmob_installation.g.dart'; 5 | @JsonSerializable() 6 | class BmobInstallation extends BmobObject { 7 | String? deviceType = "android"; 8 | String? installationId; 9 | String? timeZone; 10 | String? deviceToken; 11 | 12 | 13 | BmobInstallation(){ 14 | timeZone = ""; 15 | } 16 | //此处与类名一致,由指令自动生成代码 17 | factory BmobInstallation.fromJson(Map json) => 18 | _$BmobInstallationFromJson(json); 19 | 20 | //此处与类名一致,由指令自动生成代码 21 | Map toJson() => _$BmobInstallationToJson(this); 22 | 23 | 24 | 25 | @override 26 | Map getParams() { 27 | return toJson(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/table/bmob_installation.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_installation.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobInstallation _$BmobInstallationFromJson(Map json) { 10 | return BmobInstallation() 11 | ..createdAt = json['createdAt'] as String? 12 | ..updatedAt = json['updatedAt'] as String? 13 | ..objectId = json['objectId'] as String? 14 | ..ACL = (json['ACL'] as Map?) as Map? 15 | ..deviceType = json['deviceType'] as String? 16 | ..installationId = json['installationId'] as String? 17 | ..timeZone = json['timeZone'] as String? 18 | ..deviceToken = json['deviceToken'] as String?; 19 | } 20 | 21 | Map _$BmobInstallationToJson(BmobInstallation instance) => 22 | { 23 | 'createdAt': instance.createdAt, 24 | 'updatedAt': instance.updatedAt, 25 | 'objectId': instance.objectId, 26 | 'ACL': instance.ACL, 27 | 'deviceType': instance.deviceType, 28 | 'installationId': instance.installationId, 29 | 'timeZone': instance.timeZone, 30 | 'deviceToken': instance.deviceToken 31 | }; 32 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/table/bmob_role.dart: -------------------------------------------------------------------------------- 1 | library bmobrole; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 6 | 7 | import 'package:data_plugin/bmob/type/bmob_relation.dart'; 8 | 9 | 10 | import 'package:data_plugin/bmob/type/bmob_pointer.dart'; 11 | 12 | part 'bmob_role.g.dart'; 13 | 14 | @JsonSerializable() 15 | class BmobRole extends BmobObject { 16 | factory BmobRole.fromJson(Map json) => 17 | _$BmobRoleFromJson(json); 18 | 19 | Map toJson(BmobRole instance) => _$BmobRoleToJson(instance); 20 | 21 | String? name; 22 | Map? roles; 23 | Map? users; 24 | 25 | BmobRole(); 26 | 27 | @override 28 | Map getParams() { 29 | // TODO: implement getParams 30 | return toJson(this); 31 | } 32 | 33 | ///设置角色 34 | void setRoles(BmobRelation bmobRelation) { 35 | roles = bmobRelation.toJson(); 36 | } 37 | 38 | ///设置用户 39 | void setUsers(BmobRelation bmobRelation) { 40 | users = bmobRelation.toJson(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/table/bmob_role.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of bmobrole; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobRole _$BmobRoleFromJson(Map json) { 10 | return BmobRole() 11 | ..createdAt = json['createdAt'] as String? 12 | ..updatedAt = json['updatedAt'] as String? 13 | ..objectId = json['objectId'] as String? 14 | ..ACL = (json['ACL'] as Map?) as Map? 15 | ..name = json['name'] as String? 16 | ..roles = json['roles'] as Map? 17 | ..users = json['users'] as Map?; 18 | } 19 | 20 | Map _$BmobRoleToJson(BmobRole instance) => { 21 | 'createdAt': instance.createdAt, 22 | 'updatedAt': instance.updatedAt, 23 | 'objectId': instance.objectId, 24 | 'ACL': instance.ACL, 25 | 'name': instance.name, 26 | 'roles': instance.roles, 27 | 'users': instance.users 28 | }; 29 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/table/bmob_user.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_user.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobUser _$BmobUserFromJson(Map json) { 10 | return BmobUser() 11 | ..createdAt = json['createdAt'] as String? 12 | ..updatedAt = json['updatedAt'] as String? 13 | ..objectId = json['objectId'] as String? 14 | ..ACL = (json['ACL'] as Map?) as Map? 15 | ..username = json['username'] as String? 16 | ..password = json['password'] as String? 17 | ..email = json['email'] as String? 18 | ..emailVerified = json['emailVerified'] as bool? 19 | ..mobilePhoneNumber = json['mobilePhoneNumber'] as String? 20 | ..mobilePhoneNumberVerified = json['mobilePhoneNumberVerified'] as bool? 21 | ..sessionToken = json['sessionToken'] as String?; 22 | } 23 | 24 | Map _$BmobUserToJson(BmobUser instance) => { 25 | 'createdAt': instance.createdAt, 26 | 'updatedAt': instance.updatedAt, 27 | 'objectId': instance.objectId, 28 | 'ACL': instance.ACL, 29 | 'username': instance.username, 30 | 'password': instance.password, 31 | 'email': instance.email, 32 | 'emailVerified': instance.emailVerified, 33 | 'mobilePhoneNumber': instance.mobilePhoneNumber, 34 | 'mobilePhoneNumberVerified': instance.mobilePhoneNumberVerified, 35 | 'sessionToken': instance.sessionToken 36 | }; 37 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_acl.dart: -------------------------------------------------------------------------------- 1 | import 'package:data_plugin/bmob/response/bmob_error.dart'; 2 | 3 | class BmobAcl { 4 | static const String READ = "read"; 5 | static const String WRITE = "write"; 6 | 7 | Map? acl = Map(); 8 | 9 | 10 | BmobAcl(); 11 | 12 | 13 | void addAccess(String accessType, String userIdOrRoleName, bool allowed) { 14 | if (userIdOrRoleName == null || userIdOrRoleName.isEmpty) { 15 | throw BmobError(1001, "The userId is null or empty."); 16 | } 17 | if (acl!.containsKey(userIdOrRoleName)) { 18 | Map map = acl![userIdOrRoleName]; 19 | map[accessType] = allowed; 20 | acl![userIdOrRoleName] = map; 21 | } else { 22 | Map map = Map(); 23 | map[accessType] = allowed; 24 | acl![userIdOrRoleName] = map; 25 | } 26 | } 27 | 28 | //添加某用户对该数据的读取权限规则 29 | void addUserReadAccess(String userId, bool allowed) { 30 | addAccess(READ, userId, allowed); 31 | } 32 | 33 | //添加某用户对该数据的写入权限规则 34 | void addUserWriteAccess(String userId, bool allowed) { 35 | addAccess(WRITE, userId, allowed); 36 | } 37 | 38 | //添加某角色对该数据的读取权限规则 39 | void addRoleReadAccess(String roleName, bool allowed) { 40 | addAccess(READ, "role:$roleName", allowed); 41 | } 42 | 43 | //添加某角色对该数据的写入权限规则 44 | void addRoleWriteAccess(String roleName, bool allowed) { 45 | addAccess(WRITE, "role:$roleName", allowed); 46 | } 47 | 48 | //设置所有用户对该数据的读取权限规则 49 | void setPublicWriteAccess(bool allowed) { 50 | addUserReadAccess("*", allowed); 51 | } 52 | 53 | //设置所有用户对该数据的写入权限规则 54 | void setPublicReadAccess(bool allowed) { 55 | addUserWriteAccess("*", allowed); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_date.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | //此处与类名一致,由指令自动生成代码 4 | part 'bmob_date.g.dart'; 5 | 6 | @JsonSerializable() 7 | class BmobDate { 8 | String? iso; 9 | @JsonKey(name: '__type') 10 | String? type = "Date"; 11 | 12 | BmobDate(); 13 | 14 | 15 | void setDate(DateTime dateTime){ 16 | this.iso = dateTime.toString(); 17 | } 18 | 19 | //此处与类名一致,由指令自动生成代码 20 | factory BmobDate.fromJson(Map json) => 21 | _$BmobDateFromJson(json); 22 | 23 | //此处与类名一致,由指令自动生成代码 24 | Map toJson() => _$BmobDateToJson(this); 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_date.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_date.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobDate _$BmobDateFromJson(Map json) { 10 | return BmobDate() 11 | ..iso = json['iso'] as String? 12 | ..type = json['__type'] as String?; 13 | } 14 | 15 | Map _$BmobDateToJson(BmobDate instance) => 16 | {'iso': instance.iso, '__type': instance.type}; 17 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_file.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:data_plugin/bmob/bmob.dart'; 4 | import 'package:data_plugin/bmob/bmob_dio.dart'; 5 | import 'package:json_annotation/json_annotation.dart'; 6 | 7 | part 'bmob_file.g.dart'; 8 | 9 | 10 | @JsonSerializable() 11 | class BmobFile{ 12 | @JsonKey(name: "__type") 13 | String? type; 14 | String? cdn; 15 | String? url; 16 | String? filename; 17 | 18 | 19 | BmobFile(){ 20 | type="File"; 21 | } 22 | 23 | 24 | //此处与类名一致,由指令自动生成代码 25 | factory BmobFile.fromJson(Map json) => 26 | _$BmobFileFromJson(json); 27 | 28 | 29 | //此处与类名一致,由指令自动生成代码 30 | Map toJson() => _$BmobFileToJson(this); 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | } -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_file.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_file.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobFile _$BmobFileFromJson(Map json) { 10 | return BmobFile() 11 | ..type = json['__type'] as String? 12 | ..cdn = json['cdn'] as String? 13 | ..url = json['url'] as String? 14 | ..filename = json['filename'] as String?; 15 | } 16 | 17 | Map _$BmobFileToJson(BmobFile instance) => { 18 | '__type': instance.type, 19 | 'cdn': instance.cdn, 20 | 'url': instance.url, 21 | 'filename': instance.filename 22 | }; 23 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_geo_point.dart: -------------------------------------------------------------------------------- 1 | library bmobgeopoint; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | part 'bmob_geo_point.g.dart'; 6 | 7 | @JsonSerializable() 8 | class BmobGeoPoint { 9 | factory BmobGeoPoint.fromJson(Map json) => 10 | _$BmobGeoPointFromJson(json); 11 | 12 | Map toJson() => 13 | _$BmobGeoPointToJson(this); 14 | 15 | double? latitude; 16 | double? longitude; 17 | 18 | @JsonKey(name: "__type") 19 | String? type = "GeoPoint"; 20 | 21 | BmobGeoPoint(); 22 | } 23 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_geo_point.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of bmobgeopoint; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobGeoPoint _$BmobGeoPointFromJson(Map json) { 10 | return BmobGeoPoint() 11 | ..latitude = (json['latitude'] as num?)?.toDouble() 12 | ..longitude = (json['longitude'] as num?)?.toDouble() 13 | ..type = json['__type'] as String?; 14 | } 15 | 16 | Map _$BmobGeoPointToJson(BmobGeoPoint instance) => 17 | { 18 | 'latitude': instance.latitude, 19 | 'longitude': instance.longitude, 20 | '__type': instance.type 21 | }; 22 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_pointer.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | part 'bmob_pointer.g.dart'; 4 | 5 | @JsonSerializable() 6 | class BmobPointer { 7 | factory BmobPointer.fromJson(Map json) => 8 | _$BmobPointerFromJson(json); 9 | 10 | Map toJson() => _$BmobPointerToJson(this); 11 | 12 | @JsonKey(name: "__type") 13 | String? type = "Pointer"; 14 | String? className; 15 | String? objectId; 16 | 17 | BmobPointer(); 18 | } 19 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_pointer.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_pointer.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobPointer _$BmobPointerFromJson(Map json) { 10 | return BmobPointer() 11 | ..type = json['__type'] as String? 12 | ..className = json['className'] as String? 13 | ..objectId = json['objectId'] as String?; 14 | } 15 | 16 | Map _$BmobPointerToJson(BmobPointer instance) => 17 | { 18 | '__type': instance.type, 19 | 'className': instance.className, 20 | 'objectId': instance.objectId 21 | }; 22 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_relation.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | import 'bmob_pointer.dart'; 3 | import 'package:data_plugin/bmob/table/bmob_object.dart'; 4 | import 'package:data_plugin/bmob/bmob_utils.dart'; 5 | 6 | part 'bmob_relation.g.dart'; 7 | 8 | @JsonSerializable() 9 | class BmobRelation { 10 | factory BmobRelation.fromJson(Map json) => 11 | _$BmobRelationFromJson(json); 12 | 13 | Map toJson() => _$BmobRelationToJson(this); 14 | 15 | @JsonKey(name: "__op") 16 | String? op; 17 | 18 | //关联关系列表 19 | List>? objects; 20 | 21 | BmobRelation() { 22 | objects = List.empty(growable: true); 23 | } 24 | 25 | //添加某个关联关系 26 | void add(BmobObject value) { 27 | op = "AddRelation"; 28 | BmobPointer bmobPointer = BmobPointer(); 29 | bmobPointer.className = BmobUtils.getTableName(value); 30 | bmobPointer.objectId = value.objectId; 31 | objects!.add(bmobPointer.toJson()); 32 | } 33 | 34 | //移除某个关联关系 35 | void remove(BmobObject value) { 36 | op = "RemoveRelation"; 37 | BmobPointer bmobPointer = BmobPointer(); 38 | bmobPointer.className = BmobUtils.getTableName(value); 39 | bmobPointer.objectId = value.objectId; 40 | objects!.add(bmobPointer.toJson()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /data_plugin/lib/bmob/type/bmob_relation.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'bmob_relation.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | BmobRelation _$BmobRelationFromJson(Map json) { 10 | return BmobRelation() 11 | ..op = json['__op'] as String? 12 | ..objects = (json['objects'] as List?) 13 | ?.map((e) => e as Map) 14 | ?.toList(); 15 | } 16 | 17 | Map _$BmobRelationToJson(BmobRelation instance) => 18 | {'__op': instance.op, 'objects': instance.objects}; 19 | -------------------------------------------------------------------------------- /data_plugin/lib/data_plugin.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | 5 | class DataPlugin { 6 | static const MethodChannel _channel = const MethodChannel('data_plugin'); 7 | 8 | static Future get platformVersion async { 9 | final String? version = await _channel.invokeMethod('getPlatformVersion'); 10 | return version; 11 | } 12 | 13 | static Future get installationId async { 14 | final String? version = await _channel.invokeMethod('getInstallationId'); 15 | return version; 16 | } 17 | 18 | static void toast(String msg) async{ 19 | Map args = { 20 | "msg": msg, 21 | }; 22 | await _channel.invokeMethod("showToast",args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /data_plugin/lib/utils/dialog_util.dart: -------------------------------------------------------------------------------- 1 | /** 2 | * dialog 工具类 3 | */ 4 | import 'package:flutter/material.dart'; 5 | 6 | 7 | ///显示操作结果的提示框 8 | void showResult(BuildContext context, String title, String message) { 9 | showDialog( 10 | context: context, 11 | barrierDismissible: false, 12 | builder: (BuildContext context) { 13 | return new AlertDialog( 14 | title: new Text(title), 15 | content: new SingleChildScrollView( 16 | child: new ListBody( 17 | children: [ 18 | new Text(message), 19 | ], 20 | ), 21 | ), 22 | actions: [ 23 | new ElevatedButton( 24 | child: new Text('确定'), 25 | onPressed: () { 26 | Navigator.of(context).pop(); 27 | }, 28 | ), 29 | ], 30 | ); 31 | }, 32 | ); 33 | } 34 | 35 | ///显示操作成功的提示框 36 | void showSuccess(BuildContext context,String message){ 37 | showResult(context, "success", message); 38 | } 39 | 40 | ///显示操作失败的提示框 41 | void showError(BuildContext context,String message){ 42 | showResult(context, "error", message); 43 | } -------------------------------------------------------------------------------- /data_plugin/lib/utils/file_picker.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutter/services.dart'; 5 | 6 | enum FileType { 7 | ANY, 8 | IMAGE, 9 | VIDEO, 10 | AUDIO, 11 | CUSTOM, 12 | } 13 | 14 | class FilePicker { 15 | static const MethodChannel _channel = const MethodChannel('data_plugin'); 16 | static const String _tag = 'FilePicker'; 17 | 18 | FilePicker._(); 19 | 20 | /// Returns an iterable `Map` where the `key` is the name of the file 21 | /// and the `value` the path. 22 | /// 23 | /// A [fileExtension] can be provided to filter the picking results. 24 | /// If provided, it will be use the `FileType.CUSTOM` for that [fileExtension]. 25 | /// If not, `FileType.ANY` will be used and any combination of files can be multi picked at once. 26 | static Future?> getMultiFilePath( 27 | {FileType type = FileType.ANY, String? fileExtension}) async => 28 | await (_getPath(_handleType(type, fileExtension), true) as FutureOr?>); 29 | 30 | /// Returns an absolute file path from the calling platform. 31 | /// 32 | /// A [type] must be provided to filter the picking results. 33 | /// Can be used a custom file type with `FileType.CUSTOM`. A [fileExtension] must be provided (e.g. PDF, SVG, etc.) 34 | /// Defaults to `FileType.ANY` which will display all file types. 35 | static Future getFilePath( 36 | {FileType type = FileType.ANY, String? fileExtension}) async => 37 | await (_getPath(_handleType(type, fileExtension), false) as FutureOr); 38 | 39 | /// Returns a `File` object from the selected file path. 40 | /// 41 | /// This is an utility method that does the same of `getFilePath()` but saving some boilerplate if 42 | /// you are planing to create a `File` for the returned path. 43 | static Future getFile( 44 | {FileType type = FileType.ANY, String? fileExtension}) async { 45 | final String? filePath = 46 | await (_getPath(_handleType(type, fileExtension), false) as FutureOr); 47 | return filePath != null ? File(filePath) : null; 48 | } 49 | 50 | static Future _getPath(String type, bool multipleSelection) async { 51 | try { 52 | Map map = {"type": type, "multi": multipleSelection}; 53 | dynamic result = 54 | await _channel.invokeMethod("filePicker", map); 55 | if (result != null && multipleSelection) { 56 | if (result is String) { 57 | result = [result]; 58 | } 59 | return Map.fromIterable(result, 60 | key: (path) => path.split('/').last, value: (path) => path); 61 | } 62 | return result; 63 | } on PlatformException catch (e) { 64 | print('[$_tag] Platform exception: ' + e.toString()); 65 | } catch (e) { 66 | print( 67 | '[$_tag] Unsupported operation. Method not found. The exception thrown was: ' + 68 | e.toString()); 69 | } 70 | return null; 71 | } 72 | 73 | static String _handleType(FileType type, String? fileExtension) { 74 | switch (type) { 75 | case FileType.IMAGE: 76 | return 'IMAGE'; 77 | case FileType.AUDIO: 78 | return 'AUDIO'; 79 | case FileType.VIDEO: 80 | return 'VIDEO'; 81 | case FileType.ANY: 82 | return 'ANY'; 83 | case FileType.CUSTOM: 84 | return '__CUSTOM_' + (fileExtension ?? ''); 85 | default: 86 | return 'ANY'; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /data_plugin/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: data_plugin 2 | description: Bmob Data Flutter plugin. 3 | version: 0.0.19 4 | author: chaozhouzhang <13760289294@139.com> 5 | homepage: https://github.com/chaozhouzhang 6 | 7 | environment: 8 | sdk: '>=2.12.0 <3.0.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | cupertino_icons: ^1.0.3 14 | dio: ^4.0.0 15 | flutter_spinkit: ^5.1.0 16 | json_annotation: ^4.1.0 17 | web_socket_channel: ^2.1.0 18 | shared_preferences: ^2.0.20 19 | crypto: ^3.0.1 20 | convert: ^3.0.1 21 | 22 | dev_dependencies: 23 | flutter_test: 24 | sdk: flutter 25 | build_runner: ^2.1.2 26 | json_serializable: ^5.0.1 27 | 28 | # For information on the generic Dart part of this file, see the 29 | # following page: https://www.dartlang.org/tools/pub/pubspec 30 | 31 | # The following section is specific to Flutter. 32 | flutter: 33 | # This section identifies this Flutter project as a plugin project. 34 | # The androidPackage and pluginClass identifiers should not ordinarily 35 | # be modified. They are used by the tooling to maintain consistency whenyy 36 | # adding or updating assets for this project. 37 | plugin: 38 | androidPackage: cn.bmob.data_plugin 39 | pluginClass: DataPlugin 40 | 41 | 42 | # To add assets to your plugin package, add an assets section, like this: 43 | # assets: 44 | # - images/a_dot_burr.jpeg 45 | # - images/a_dot_ham.jpeg 46 | # 47 | # For details regarding assets in packages, see 48 | # https://flutter.io/assets-and-images/#from-packages 49 | # 50 | # An image asset can refer to one or more resolution-specific "variants", see 51 | # https://flutter.io/assets-and-images/#resolution-aware. 52 | 53 | # To add custom fonts to your plugin package, add a fonts section here, 54 | # in this "flutter" section. Each entry in this list should have a 55 | # "family" key with the font family name, and a "fonts" key with a 56 | # list giving the asset and other descriptors for the font. For 57 | # example: 58 | # fonts: 59 | # - family: Schyler 60 | # fonts: 61 | # - asset: fonts/Schyler-Regular.ttf 62 | # - asset: fonts/Schyler-Italic.ttf 63 | # style: italic 64 | # - family: Trajan Pro 65 | # fonts: 66 | # - asset: fonts/TrajanPro.ttf 67 | # - asset: fonts/TrajanPro_Bold.ttf 68 | # weight: 700 69 | # 70 | # For details regarding fonts in packages, see 71 | # https://flutter.io/custom-fonts/#from-packages 72 | -------------------------------------------------------------------------------- /data_plugin/res/values/strings_en.arb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmob/bmob-flutter-sdk/3b71808a12e02e2563d41fc129f6771b0cc2a9fa/data_plugin/res/values/strings_en.arb -------------------------------------------------------------------------------- /data_plugin/test/data_plugin_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:data_plugin/data_plugin.dart'; 4 | 5 | void main() { 6 | const MethodChannel channel = MethodChannel('data_plugin'); 7 | 8 | setUp(() { 9 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 10 | return '42'; 11 | }); 12 | }); 13 | 14 | tearDown(() { 15 | channel.setMockMethodCallHandler(null); 16 | }); 17 | 18 | test('getPlatformVersion', () async { 19 | expect(await DataPlugin.platformVersion, '42'); 20 | }); 21 | } 22 | --------------------------------------------------------------------------------