├── .all-contributorsrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ └── widget_test.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── 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 │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── lib └── flutter_switch.dart ├── pubspec.lock ├── pubspec.yaml └── test └── flutter_switch_test.dart /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "boringdeveloper", 10 | "name": "Nickr", 11 | "avatar_url": "https://avatars.githubusercontent.com/u/21273958?v=4", 12 | "profile": "https://github.com/boringdeveloper", 13 | "contributions": [ 14 | "code", 15 | "doc", 16 | "maintenance", 17 | "test" 18 | ] 19 | }, 20 | { 21 | "login": "LucasED78", 22 | "name": "Lucas Eduardo", 23 | "avatar_url": "https://avatars.githubusercontent.com/u/30601688?v=4", 24 | "profile": "https://github.com/LucasED78", 25 | "contributions": [ 26 | "code" 27 | ] 28 | }, 29 | { 30 | "login": "douglasramos", 31 | "name": "Douglas Ramos", 32 | "avatar_url": "https://avatars.githubusercontent.com/u/12133412?v=4", 33 | "profile": "https://github.com/douglasramos", 34 | "contributions": [ 35 | "code" 36 | ] 37 | }, 38 | { 39 | "login": "solid-daniyilyevtyushkin", 40 | "name": "Daniyil Yevtyushkin", 41 | "avatar_url": "https://avatars.githubusercontent.com/u/69351065?v=4", 42 | "profile": "https://github.com/solid-daniyilyevtyushkin", 43 | "contributions": [ 44 | "code", 45 | "test" 46 | ] 47 | }, 48 | { 49 | "login": "Maksim-Nikolaev", 50 | "name": "Maksim Nikolaev", 51 | "avatar_url": "https://avatars.githubusercontent.com/u/45855362?v=4", 52 | "profile": "https://github.com/Maksim-Nikolaev", 53 | "contributions": [ 54 | "code" 55 | ] 56 | } 57 | ], 58 | "contributorsPerLine": 7, 59 | "projectName": "FlutterSwitch", 60 | "projectOwner": "boringdeveloper", 61 | "repoType": "github", 62 | "repoHost": "https://github.com", 63 | "skipCi": true 64 | } 65 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/widget_test.yml: -------------------------------------------------------------------------------- 1 | name: Widget Test 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: actions/setup-java@v1 15 | with: 16 | java-version: '12.x' 17 | - uses: subosito/flutter-action@v1 18 | with: 19 | channel: 'stable' 20 | - run: flutter pub get 21 | - run: flutter test 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 76 | -------------------------------------------------------------------------------- /.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: f139b11009aeb8ed2a3a3aa8b0066e482709dde3 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.3.1] - April 12, 2021 2 | 3 | * Revised the activeIcon and inactiveIcon to accept other types of widget including Images, Icon and FontAwesome Icons. 4 | 5 | ## [0.3.0] - March 06, 2021 6 | 7 | * Migrated to null safety. Beware for possible breaking changes. 8 | * Added disabled property that expects a true or false value. Defaults to false if no value was passed. 9 | 10 | ## [0.3.0-nullsafety.0] - March 06, 2021 11 | 12 | * Migrated to null safety. Beware for possible breaking changes. 13 | 14 | ## [0.2.2] - March 06, 2021 15 | 16 | * Made toggle animation smoother 17 | * Opacity animation for switch texts and icons 18 | * Added duration property 19 | 20 | ## [0.2.1] - February 16, 2021 21 | 22 | * Handling the display of the switch in the AppBar 23 | 24 | ## [0.2.0] - December 12, 2020 25 | 26 | * Added switch and toggle border property. Now you can try to give your switch a toon-like feel 27 | * Update Readme 28 | * Added toggle icon property 29 | * Added sample usage of custom border and icons in /example 30 | 31 | ## [0.1.5] - October 25, 2020 32 | 33 | * Fix an issue where the conditional statement is ignored in the first tap of the switch 34 | 35 | ## [0.1.4] - October 25, 2020 36 | 37 | * Handling of state when no changes was made 38 | 39 | ## [0.1.3] - September 26, 2020 40 | 41 | * Handling of state was fixed 42 | * Added comments for each property 43 | * Added active and inactive font weight property 44 | 45 | ## [0.1.2] - September 21, 2020 46 | 47 | * Dispose of animation controller 48 | 49 | ## [0.1.1] - June 28, 2020 50 | 51 | * Custom switch active and inactive text 52 | 53 | ## [0.1.0] - May 10, 2020 54 | 55 | * Custom switch height and width 56 | * Custom acitve or inactive switch color 57 | * Custom toggle color 58 | * Custom toggle size 59 | * Custom switch border radius 60 | * Custom switch padding 61 | * Choice to display 'on' or 'off' value inside the switch 62 | * Custom active or inactive value color 63 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at romero.nicholejohn@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Nichole John Romero 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_switch 2 | 3 | [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-) 4 | 5 | 6 | [![pub package](https://img.shields.io/pub/v/flutter_switch.svg)](https://pub.dev/packages/flutter_switch) [![pub points](https://badges.bar/flutter_switch/pub%20points)](https://pub.dev/packages/flutter_switch/score) [![popularity](https://badges.bar/flutter_switch/popularity)](https://pub.dev/packages/flutter_switch/score) [![likes](https://badges.bar/flutter_switch/likes)](https://pub.dev/packages/flutter_switch/score) 7 | 8 | An easy to implement custom switch created for Flutter. Give it a custom height and width, border for the switch and toggle, border radius, colors, toggle size, a choice to display an 'On' and 'Off' text and able to add an icon inside the toggle. 9 | 10 | [![GitHub followers](https://img.shields.io/github/followers/boringdeveloper.svg?style=social&label=Follow)](https://github.com/boringdeveloper) 11 | 12 | ## Demo 13 | 14 | ![flutter_switch](https://media0.giphy.com/media/zQ7AwA3SiAzqiFCW1o/giphy.gif) 15 | 16 | Video version: https://youtu.be/JqJnxjE6Efc 17 | 18 | 19 | ## Use this package as a library 20 | 21 | Add this to your package's `pubspec.yaml` file: 22 | 23 | ```yaml 24 | dependencies: 25 | flutter_switch: ^0.3.1 26 | ``` 27 | 28 | You can install packages from the command line with Flutter: 29 | ```bash 30 | $ flutter pub get 31 | ``` 32 | 33 | Import in your project: 34 | ```dart 35 | import 'package:flutter_switch/flutter_switch.dart'; 36 | ``` 37 | 38 | ## Sample Usage 39 | ```dart 40 | class MyHomePage extends StatefulWidget { 41 | @override 42 | _MyHomePageState createState() => _MyHomePageState(); 43 | } 44 | 45 | class _MyHomePageState extends State { 46 | bool status = false; 47 | 48 | @override 49 | Widget build(BuildContext context) { 50 | return Scaffold( 51 | appBar: AppBar( 52 | title: Text("FlutterSwitch Demo"), 53 | ), 54 | body: Center( 55 | child: Container( 56 | child: FlutterSwitch( 57 | width: 125.0, 58 | height: 55.0, 59 | valueFontSize: 25.0, 60 | toggleSize: 45.0, 61 | value: status, 62 | borderRadius: 30.0, 63 | padding: 8.0, 64 | showOnOff: true, 65 | onToggle: (val) { 66 | setState(() { 67 | status = val; 68 | }); 69 | }, 70 | ), 71 | ), 72 | ), 73 | ); 74 | } 75 | } 76 | ``` 77 | 78 | ## Want to Contribute? 79 | 80 | Contributions to this project is very much welcome. Let's work together to maintain and improve the project 81 | Simply Fork the repository, Commit and Push your changes and create a new Pull Request. 82 | 83 | Don't forget to try out the example project under the ./example folder. 84 | 85 | Also test your changes by running this command. 86 | ```bash 87 | $ flutter test 88 | ``` 89 | 90 | If you have some suggestions, you can reach me at romero.nicholejohn@gmail.com 91 | 92 | # License 93 | 94 | BSD 3-Clause License 95 | 96 | Copyright (c) 2020, Nichole John Romero 97 | All rights reserved. 98 | 99 | Redistribution and use in source and binary forms, with or without 100 | modification, are permitted provided that the following conditions are met: 101 | 102 | 1. Redistributions of source code must retain the above copyright notice, this 103 | list of conditions and the following disclaimer. 104 | 105 | 2. Redistributions in binary form must reproduce the above copyright notice, 106 | this list of conditions and the following disclaimer in the documentation 107 | and/or other materials provided with the distribution. 108 | 109 | 3. Neither the name of the copyright holder nor the names of its 110 | contributors may be used to endorse or promote products derived from 111 | this software without specific prior written permission. 112 | 113 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 114 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 115 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 116 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 117 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 118 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 119 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 120 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 121 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 122 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 123 | 124 | ## Contributors ✨ 125 | 126 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 |

Nickr

💻 📖 🚧 ⚠️

Lucas Eduardo

💻

Douglas Ramos

💻

Daniyil Yevtyushkin

💻 ⚠️

Maksim Nikolaev

💻
140 | 141 | 142 | 143 | 144 | 145 | 146 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 147 | -------------------------------------------------------------------------------- /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 | # 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 | -------------------------------------------------------------------------------- /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: f139b11009aeb8ed2a3a3aa8b0066e482709dde3 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'androidx.test:runner:1.1.1' 66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 67 | } 68 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import androidx.annotation.NonNull; 4 | import io.flutter.embedding.android.FlutterActivity 5 | import io.flutter.embedding.engine.FlutterEngine 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { 10 | GeneratedPluginRegistrant.registerWith(flutterEngine); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /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-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 18 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 19 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXCopyFilesBuildPhase section */ 23 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 24 | isa = PBXCopyFilesBuildPhase; 25 | buildActionMask = 2147483647; 26 | dstPath = ""; 27 | dstSubfolderSpec = 10; 28 | files = ( 29 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 30 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 31 | ); 32 | name = "Embed Frameworks"; 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXCopyFilesBuildPhase section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 39 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 40 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 41 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 42 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 43 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 44 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 45 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 46 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 47 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 48 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | /* End PBXFileReference section */ 54 | 55 | /* Begin PBXFrameworksBuildPhase section */ 56 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 61 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | 9740EEB11CF90186004384FC /* Flutter */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 3B80C3931E831B6300D905FE /* App.framework */, 72 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 73 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 74 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 75 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 76 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 77 | ); 78 | name = Flutter; 79 | sourceTree = ""; 80 | }; 81 | 97C146E51CF9000F007C117D = { 82 | isa = PBXGroup; 83 | children = ( 84 | 9740EEB11CF90186004384FC /* Flutter */, 85 | 97C146F01CF9000F007C117D /* Runner */, 86 | 97C146EF1CF9000F007C117D /* Products */, 87 | ); 88 | sourceTree = ""; 89 | }; 90 | 97C146EF1CF9000F007C117D /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 97C146EE1CF9000F007C117D /* Runner.app */, 94 | ); 95 | name = Products; 96 | sourceTree = ""; 97 | }; 98 | 97C146F01CF9000F007C117D /* Runner */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 102 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 103 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 104 | 97C147021CF9000F007C117D /* Info.plist */, 105 | 97C146F11CF9000F007C117D /* Supporting Files */, 106 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 107 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 108 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 109 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 110 | ); 111 | path = Runner; 112 | sourceTree = ""; 113 | }; 114 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | ); 118 | name = "Supporting Files"; 119 | sourceTree = ""; 120 | }; 121 | /* End PBXGroup section */ 122 | 123 | /* Begin PBXNativeTarget section */ 124 | 97C146ED1CF9000F007C117D /* Runner */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 127 | buildPhases = ( 128 | 9740EEB61CF901F6004384FC /* Run Script */, 129 | 97C146EA1CF9000F007C117D /* Sources */, 130 | 97C146EB1CF9000F007C117D /* Frameworks */, 131 | 97C146EC1CF9000F007C117D /* Resources */, 132 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 133 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 134 | ); 135 | buildRules = ( 136 | ); 137 | dependencies = ( 138 | ); 139 | name = Runner; 140 | productName = Runner; 141 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 142 | productType = "com.apple.product-type.application"; 143 | }; 144 | /* End PBXNativeTarget section */ 145 | 146 | /* Begin PBXProject section */ 147 | 97C146E61CF9000F007C117D /* Project object */ = { 148 | isa = PBXProject; 149 | attributes = { 150 | LastUpgradeCheck = 1020; 151 | ORGANIZATIONNAME = "The Chromium Authors"; 152 | TargetAttributes = { 153 | 97C146ED1CF9000F007C117D = { 154 | CreatedOnToolsVersion = 7.3.1; 155 | LastSwiftMigration = 1100; 156 | }; 157 | }; 158 | }; 159 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 160 | compatibilityVersion = "Xcode 3.2"; 161 | developmentRegion = en; 162 | hasScannedForEncodings = 0; 163 | knownRegions = ( 164 | en, 165 | Base, 166 | ); 167 | mainGroup = 97C146E51CF9000F007C117D; 168 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 169 | projectDirPath = ""; 170 | projectRoot = ""; 171 | targets = ( 172 | 97C146ED1CF9000F007C117D /* Runner */, 173 | ); 174 | }; 175 | /* End PBXProject section */ 176 | 177 | /* Begin PBXResourcesBuildPhase section */ 178 | 97C146EC1CF9000F007C117D /* Resources */ = { 179 | isa = PBXResourcesBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 183 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 184 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 185 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXResourcesBuildPhase section */ 190 | 191 | /* Begin PBXShellScriptBuildPhase section */ 192 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 193 | isa = PBXShellScriptBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | ); 197 | inputPaths = ( 198 | ); 199 | name = "Thin Binary"; 200 | outputPaths = ( 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | shellPath = /bin/sh; 204 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 205 | }; 206 | 9740EEB61CF901F6004384FC /* Run Script */ = { 207 | isa = PBXShellScriptBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | ); 211 | inputPaths = ( 212 | ); 213 | name = "Run Script"; 214 | outputPaths = ( 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | shellPath = /bin/sh; 218 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 219 | }; 220 | /* End PBXShellScriptBuildPhase section */ 221 | 222 | /* Begin PBXSourcesBuildPhase section */ 223 | 97C146EA1CF9000F007C117D /* Sources */ = { 224 | isa = PBXSourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 228 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXVariantGroup section */ 235 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 236 | isa = PBXVariantGroup; 237 | children = ( 238 | 97C146FB1CF9000F007C117D /* Base */, 239 | ); 240 | name = Main.storyboard; 241 | sourceTree = ""; 242 | }; 243 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | 97C147001CF9000F007C117D /* Base */, 247 | ); 248 | name = LaunchScreen.storyboard; 249 | sourceTree = ""; 250 | }; 251 | /* End PBXVariantGroup section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 255 | isa = XCBuildConfiguration; 256 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 257 | buildSettings = { 258 | ALWAYS_SEARCH_USER_PATHS = NO; 259 | CLANG_ANALYZER_NONNULL = YES; 260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 261 | CLANG_CXX_LIBRARY = "libc++"; 262 | CLANG_ENABLE_MODULES = YES; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 265 | CLANG_WARN_BOOL_CONVERSION = YES; 266 | CLANG_WARN_COMMA = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 269 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 270 | CLANG_WARN_EMPTY_BODY = YES; 271 | CLANG_WARN_ENUM_CONVERSION = YES; 272 | CLANG_WARN_INFINITE_RECURSION = YES; 273 | CLANG_WARN_INT_CONVERSION = YES; 274 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 275 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 276 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 278 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 279 | CLANG_WARN_STRICT_PROTOTYPES = YES; 280 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 284 | COPY_PHASE_STRIP = NO; 285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 286 | ENABLE_NS_ASSERTIONS = NO; 287 | ENABLE_STRICT_OBJC_MSGSEND = YES; 288 | GCC_C_LANGUAGE_STANDARD = gnu99; 289 | GCC_NO_COMMON_BLOCKS = YES; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 297 | MTL_ENABLE_DEBUG_INFO = NO; 298 | SDKROOT = iphoneos; 299 | SUPPORTED_PLATFORMS = iphoneos; 300 | TARGETED_DEVICE_FAMILY = "1,2"; 301 | VALIDATE_PRODUCT = YES; 302 | }; 303 | name = Profile; 304 | }; 305 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 306 | isa = XCBuildConfiguration; 307 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 308 | buildSettings = { 309 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 310 | CLANG_ENABLE_MODULES = YES; 311 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 312 | ENABLE_BITCODE = NO; 313 | FRAMEWORK_SEARCH_PATHS = ( 314 | "$(inherited)", 315 | "$(PROJECT_DIR)/Flutter", 316 | ); 317 | INFOPLIST_FILE = Runner/Info.plist; 318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 319 | LIBRARY_SEARCH_PATHS = ( 320 | "$(inherited)", 321 | "$(PROJECT_DIR)/Flutter", 322 | ); 323 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 326 | SWIFT_VERSION = 5.0; 327 | VERSIONING_SYSTEM = "apple-generic"; 328 | }; 329 | name = Profile; 330 | }; 331 | 97C147031CF9000F007C117D /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 334 | buildSettings = { 335 | ALWAYS_SEARCH_USER_PATHS = NO; 336 | CLANG_ANALYZER_NONNULL = YES; 337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 338 | CLANG_CXX_LIBRARY = "libc++"; 339 | CLANG_ENABLE_MODULES = YES; 340 | CLANG_ENABLE_OBJC_ARC = YES; 341 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 342 | CLANG_WARN_BOOL_CONVERSION = YES; 343 | CLANG_WARN_COMMA = YES; 344 | CLANG_WARN_CONSTANT_CONVERSION = YES; 345 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 347 | CLANG_WARN_EMPTY_BODY = YES; 348 | CLANG_WARN_ENUM_CONVERSION = YES; 349 | CLANG_WARN_INFINITE_RECURSION = YES; 350 | CLANG_WARN_INT_CONVERSION = YES; 351 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 352 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 353 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 354 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 355 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 356 | CLANG_WARN_STRICT_PROTOTYPES = YES; 357 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 358 | CLANG_WARN_UNREACHABLE_CODE = YES; 359 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 360 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 361 | COPY_PHASE_STRIP = NO; 362 | DEBUG_INFORMATION_FORMAT = dwarf; 363 | ENABLE_STRICT_OBJC_MSGSEND = YES; 364 | ENABLE_TESTABILITY = YES; 365 | GCC_C_LANGUAGE_STANDARD = gnu99; 366 | GCC_DYNAMIC_NO_PIC = NO; 367 | GCC_NO_COMMON_BLOCKS = YES; 368 | GCC_OPTIMIZATION_LEVEL = 0; 369 | GCC_PREPROCESSOR_DEFINITIONS = ( 370 | "DEBUG=1", 371 | "$(inherited)", 372 | ); 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 375 | GCC_WARN_UNDECLARED_SELECTOR = YES; 376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 377 | GCC_WARN_UNUSED_FUNCTION = YES; 378 | GCC_WARN_UNUSED_VARIABLE = YES; 379 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 380 | MTL_ENABLE_DEBUG_INFO = YES; 381 | ONLY_ACTIVE_ARCH = YES; 382 | SDKROOT = iphoneos; 383 | TARGETED_DEVICE_FAMILY = "1,2"; 384 | }; 385 | name = Debug; 386 | }; 387 | 97C147041CF9000F007C117D /* Release */ = { 388 | isa = XCBuildConfiguration; 389 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_ANALYZER_NONNULL = YES; 393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 394 | CLANG_CXX_LIBRARY = "libc++"; 395 | CLANG_ENABLE_MODULES = YES; 396 | CLANG_ENABLE_OBJC_ARC = YES; 397 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 398 | CLANG_WARN_BOOL_CONVERSION = YES; 399 | CLANG_WARN_COMMA = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INFINITE_RECURSION = YES; 406 | CLANG_WARN_INT_CONVERSION = YES; 407 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 408 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 409 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 411 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 412 | CLANG_WARN_STRICT_PROTOTYPES = YES; 413 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 414 | CLANG_WARN_UNREACHABLE_CODE = YES; 415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 416 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 417 | COPY_PHASE_STRIP = NO; 418 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 419 | ENABLE_NS_ASSERTIONS = NO; 420 | ENABLE_STRICT_OBJC_MSGSEND = YES; 421 | GCC_C_LANGUAGE_STANDARD = gnu99; 422 | GCC_NO_COMMON_BLOCKS = YES; 423 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 424 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 425 | GCC_WARN_UNDECLARED_SELECTOR = YES; 426 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 427 | GCC_WARN_UNUSED_FUNCTION = YES; 428 | GCC_WARN_UNUSED_VARIABLE = YES; 429 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 430 | MTL_ENABLE_DEBUG_INFO = NO; 431 | SDKROOT = iphoneos; 432 | SUPPORTED_PLATFORMS = iphoneos; 433 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 434 | TARGETED_DEVICE_FAMILY = "1,2"; 435 | VALIDATE_PRODUCT = YES; 436 | }; 437 | name = Release; 438 | }; 439 | 97C147061CF9000F007C117D /* Debug */ = { 440 | isa = XCBuildConfiguration; 441 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 442 | buildSettings = { 443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 444 | CLANG_ENABLE_MODULES = YES; 445 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 446 | ENABLE_BITCODE = NO; 447 | FRAMEWORK_SEARCH_PATHS = ( 448 | "$(inherited)", 449 | "$(PROJECT_DIR)/Flutter", 450 | ); 451 | INFOPLIST_FILE = Runner/Info.plist; 452 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 453 | LIBRARY_SEARCH_PATHS = ( 454 | "$(inherited)", 455 | "$(PROJECT_DIR)/Flutter", 456 | ); 457 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 460 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 461 | SWIFT_VERSION = 5.0; 462 | VERSIONING_SYSTEM = "apple-generic"; 463 | }; 464 | name = Debug; 465 | }; 466 | 97C147071CF9000F007C117D /* Release */ = { 467 | isa = XCBuildConfiguration; 468 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 469 | buildSettings = { 470 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 471 | CLANG_ENABLE_MODULES = YES; 472 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 473 | ENABLE_BITCODE = NO; 474 | FRAMEWORK_SEARCH_PATHS = ( 475 | "$(inherited)", 476 | "$(PROJECT_DIR)/Flutter", 477 | ); 478 | INFOPLIST_FILE = Runner/Info.plist; 479 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 480 | LIBRARY_SEARCH_PATHS = ( 481 | "$(inherited)", 482 | "$(PROJECT_DIR)/Flutter", 483 | ); 484 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 487 | SWIFT_VERSION = 5.0; 488 | VERSIONING_SYSTEM = "apple-generic"; 489 | }; 490 | name = Release; 491 | }; 492 | /* End XCBuildConfiguration section */ 493 | 494 | /* Begin XCConfigurationList section */ 495 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 97C147031CF9000F007C117D /* Debug */, 499 | 97C147041CF9000F007C117D /* Release */, 500 | 249021D3217E4FDB00AE95B9 /* Profile */, 501 | ); 502 | defaultConfigurationIsVisible = 0; 503 | defaultConfigurationName = Release; 504 | }; 505 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 506 | isa = XCConfigurationList; 507 | buildConfigurations = ( 508 | 97C147061CF9000F007C117D /* Debug */, 509 | 97C147071CF9000F007C117D /* Release */, 510 | 249021D4217E4FDB00AE95B9 /* Profile */, 511 | ); 512 | defaultConfigurationIsVisible = 0; 513 | defaultConfigurationName = Release; 514 | }; 515 | /* End XCConfigurationList section */ 516 | }; 517 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 518 | } 519 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boringdeveloper/FlutterSwitch/001a3ce04c7a873682f058bf82c3b125d1526a6a/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | 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 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_switch/flutter_switch.dart'; 3 | 4 | void main() => runApp(MyApp()); 5 | 6 | class MyApp extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return MaterialApp( 10 | theme: ThemeData( 11 | primarySwatch: Colors.blue, 12 | ), 13 | home: MyHomePage(), 14 | ); 15 | } 16 | } 17 | 18 | class MyHomePage extends StatefulWidget { 19 | @override 20 | _MyHomePageState createState() => _MyHomePageState(); 21 | } 22 | 23 | class _MyHomePageState extends State { 24 | bool status1 = false; 25 | bool status2 = true; 26 | bool status3 = false; 27 | bool status4 = false; 28 | bool status5 = false; 29 | bool status6 = false; 30 | bool status7 = false; 31 | bool status8 = false; 32 | bool isSwitchOn = false; 33 | 34 | Color _textColor = Colors.black; 35 | Color _appBarColor = Color.fromRGBO(36, 41, 46, 1); 36 | Color _scaffoldBgcolor = Colors.white; 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | return Theme( 41 | data: ThemeData( 42 | textTheme: TextTheme( 43 | bodyText1: TextStyle(color: _textColor), 44 | bodyText2: TextStyle(color: _textColor), 45 | ), 46 | ), 47 | child: Scaffold( 48 | backgroundColor: _scaffoldBgcolor, 49 | appBar: AppBar( 50 | backgroundColor: _appBarColor, 51 | title: Text( 52 | "FlutterSwitch Demo", 53 | style: TextStyle(color: Colors.white), 54 | ), 55 | actions: [ 56 | FlutterSwitch( 57 | value: isSwitchOn, 58 | onToggle: (value) { 59 | setState(() { 60 | isSwitchOn = value; 61 | }); 62 | }, 63 | ), 64 | ], 65 | ), 66 | body: SingleChildScrollView( 67 | child: Padding( 68 | padding: EdgeInsets.all(10.0), 69 | child: Column( 70 | crossAxisAlignment: CrossAxisAlignment.start, 71 | children: [ 72 | Text("Default"), 73 | SizedBox(height: 10.0), 74 | Row( 75 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 76 | children: [ 77 | FlutterSwitch( 78 | value: status1, 79 | onToggle: (val) { 80 | setState(() { 81 | status1 = val; 82 | }); 83 | }, 84 | ), 85 | Container( 86 | alignment: Alignment.centerRight, 87 | child: Text( 88 | "Value: $status1", 89 | ), 90 | ), 91 | ], 92 | ), 93 | SizedBox(height: 20.0), 94 | Text("Custom Colors and Borders"), 95 | SizedBox(height: 10.0), 96 | Row( 97 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 98 | children: [ 99 | FlutterSwitch( 100 | width: 100.0, 101 | height: 55.0, 102 | toggleSize: 45.0, 103 | value: status2, 104 | borderRadius: 30.0, 105 | padding: 2.0, 106 | toggleColor: Color.fromRGBO(225, 225, 225, 1), 107 | switchBorder: Border.all( 108 | color: Color.fromRGBO(2, 107, 206, 1), 109 | width: 6.0, 110 | ), 111 | toggleBorder: Border.all( 112 | color: Color.fromRGBO(2, 107, 206, 1), 113 | width: 5.0, 114 | ), 115 | activeColor: Color.fromRGBO(51, 226, 255, 1), 116 | inactiveColor: Colors.black38, 117 | onToggle: (val) { 118 | setState(() { 119 | status2 = val; 120 | }); 121 | }, 122 | ), 123 | Container( 124 | alignment: Alignment.centerRight, 125 | child: Text( 126 | "Value: $status2", 127 | ), 128 | ), 129 | ], 130 | ), 131 | SizedBox(height: 20.0), 132 | Text("With 'On' and 'Off' text and custom text colors"), 133 | SizedBox(height: 10.0), 134 | Row( 135 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 136 | children: [ 137 | FlutterSwitch( 138 | showOnOff: true, 139 | activeTextColor: Colors.black, 140 | inactiveTextColor: Colors.blue[50], 141 | value: status3, 142 | onToggle: (val) { 143 | setState(() { 144 | status3 = val; 145 | }); 146 | }, 147 | ), 148 | Container( 149 | alignment: Alignment.centerRight, 150 | child: Text( 151 | "Value: $status3", 152 | ), 153 | ), 154 | ], 155 | ), 156 | SizedBox(height: 20.0), 157 | Text("Custom size"), 158 | SizedBox(height: 10.0), 159 | Row( 160 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 161 | children: [ 162 | FlutterSwitch( 163 | width: 55.0, 164 | height: 25.0, 165 | valueFontSize: 12.0, 166 | toggleSize: 18.0, 167 | value: status4, 168 | onToggle: (val) { 169 | setState(() { 170 | status4 = val; 171 | }); 172 | }, 173 | ), 174 | Container( 175 | alignment: Alignment.centerRight, 176 | child: Text( 177 | "Value: $status4", 178 | ), 179 | ), 180 | ], 181 | ), 182 | SizedBox(height: 20.0), 183 | Text("Custom border radius and padding"), 184 | SizedBox(height: 10.0), 185 | Row( 186 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 187 | children: [ 188 | FlutterSwitch( 189 | width: 125.0, 190 | height: 55.0, 191 | valueFontSize: 25.0, 192 | toggleSize: 45.0, 193 | value: status5, 194 | borderRadius: 30.0, 195 | padding: 8.0, 196 | showOnOff: true, 197 | onToggle: (val) { 198 | setState(() { 199 | status5 = val; 200 | }); 201 | }, 202 | ), 203 | Container( 204 | alignment: Alignment.centerRight, 205 | child: Text( 206 | "Value: $status5", 207 | ), 208 | ), 209 | ], 210 | ), 211 | SizedBox(height: 20.0), 212 | Text("Custom text"), 213 | SizedBox(height: 10.0), 214 | Row( 215 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 216 | children: [ 217 | FlutterSwitch( 218 | activeText: "All Good. Negative.", 219 | inactiveText: "Under Quarantine.", 220 | value: status6, 221 | valueFontSize: 10.0, 222 | width: 110, 223 | borderRadius: 30.0, 224 | showOnOff: true, 225 | onToggle: (val) { 226 | setState(() { 227 | status6 = val; 228 | }); 229 | }, 230 | ), 231 | Container( 232 | alignment: Alignment.centerRight, 233 | child: Text( 234 | "Value: $status6", 235 | ), 236 | ), 237 | ], 238 | ), 239 | SizedBox(height: 20.0), 240 | Text("Icon in toggle"), 241 | Text( 242 | "Inspired by the colors from Github Dark Mode switch", 243 | style: TextStyle( 244 | fontSize: 12.0, 245 | fontStyle: FontStyle.italic, 246 | ), 247 | ), 248 | SizedBox(height: 10.0), 249 | Row( 250 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 251 | children: [ 252 | FlutterSwitch( 253 | width: 100.0, 254 | height: 55.0, 255 | toggleSize: 45.0, 256 | value: status7, 257 | borderRadius: 30.0, 258 | padding: 2.0, 259 | activeToggleColor: Color(0xFF6E40C9), 260 | inactiveToggleColor: Color(0xFF2F363D), 261 | activeSwitchBorder: Border.all( 262 | color: Color(0xFF3C1E70), 263 | width: 6.0, 264 | ), 265 | inactiveSwitchBorder: Border.all( 266 | color: Color(0xFFD1D5DA), 267 | width: 6.0, 268 | ), 269 | activeColor: Color(0xFF271052), 270 | inactiveColor: Colors.white, 271 | activeIcon: Icon( 272 | Icons.nightlight_round, 273 | color: Color(0xFFF8E3A1), 274 | ), 275 | inactiveIcon: Icon( 276 | Icons.wb_sunny, 277 | color: Color(0xFFFFDF5D), 278 | ), 279 | onToggle: (val) { 280 | setState(() { 281 | status7 = val; 282 | 283 | if (val) { 284 | _textColor = Colors.white; 285 | _appBarColor = Color.fromRGBO(22, 27, 34, 1); 286 | _scaffoldBgcolor = Color(0xFF0D1117); 287 | } else { 288 | _textColor = Colors.black; 289 | _appBarColor = Color.fromRGBO(36, 41, 46, 1); 290 | _scaffoldBgcolor = Colors.white; 291 | } 292 | }); 293 | }, 294 | ), 295 | Container( 296 | alignment: Alignment.centerRight, 297 | child: Text("Value: $status7"), 298 | ), 299 | ], 300 | ), 301 | SizedBox(height: 20.0), 302 | Text("Image as toggle icon"), 303 | SizedBox(height: 10.0), 304 | Row( 305 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 306 | children: [ 307 | FlutterSwitch( 308 | width: 100.0, 309 | height: 55.0, 310 | toggleSize: 45.0, 311 | value: status8, 312 | borderRadius: 30.0, 313 | padding: 2.0, 314 | activeToggleColor: Color(0xFF0082C8), 315 | inactiveToggleColor: Color(0xFF01579B), 316 | activeSwitchBorder: Border.all( 317 | color: Color(0xFF00D2B8), 318 | width: 6.0, 319 | ), 320 | inactiveSwitchBorder: Border.all( 321 | color: Color(0xFF29B6F6), 322 | width: 6.0, 323 | ), 324 | activeColor: Color(0xFF55DDCA), 325 | inactiveColor: Color(0xFF54C5F8), 326 | activeIcon: Image.network( 327 | "https://img2.pngio.com/functional-bits-in-flutter-flutter-community-medium-flutter-png-1000_1000.png", 328 | ), 329 | inactiveIcon: Image.network( 330 | "https://upload.wikimedia.org/wikipedia/commons/7/7e/Dart-logo.png", 331 | ), 332 | onToggle: (val) { 333 | setState(() { 334 | status8 = val; 335 | }); 336 | }, 337 | ), 338 | Container( 339 | alignment: Alignment.centerRight, 340 | child: Text("Value: $status8"), 341 | ), 342 | ], 343 | ), 344 | ], 345 | ), 346 | ), 347 | ), 348 | ), 349 | ); 350 | } 351 | } 352 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.5.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "0.1.3" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.2.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_switch: 66 | dependency: "direct main" 67 | description: 68 | path: ".." 69 | relative: true 70 | source: path 71 | version: "0.3.1" 72 | flutter_test: 73 | dependency: "direct dev" 74 | description: flutter 75 | source: sdk 76 | version: "0.0.0" 77 | matcher: 78 | dependency: transitive 79 | description: 80 | name: matcher 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "0.12.10" 84 | meta: 85 | dependency: transitive 86 | description: 87 | name: meta 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "1.3.0" 91 | path: 92 | dependency: transitive 93 | description: 94 | name: path 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "1.8.0" 98 | sky_engine: 99 | dependency: transitive 100 | description: flutter 101 | source: sdk 102 | version: "0.0.99" 103 | source_span: 104 | dependency: transitive 105 | description: 106 | name: source_span 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "1.8.0" 110 | stack_trace: 111 | dependency: transitive 112 | description: 113 | name: stack_trace 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.10.0" 117 | stream_channel: 118 | dependency: transitive 119 | description: 120 | name: stream_channel 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "2.1.0" 124 | string_scanner: 125 | dependency: transitive 126 | description: 127 | name: string_scanner 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "1.1.0" 131 | term_glyph: 132 | dependency: transitive 133 | description: 134 | name: term_glyph 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.2.0" 138 | test_api: 139 | dependency: transitive 140 | description: 141 | name: test_api 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "0.2.19" 145 | typed_data: 146 | dependency: transitive 147 | description: 148 | name: typed_data 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "1.3.0" 152 | vector_math: 153 | dependency: transitive 154 | description: 155 | name: vector_math 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "2.1.0" 159 | sdks: 160 | dart: ">=2.12.0 <3.0.0" 161 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: FlutterSwitch Demo App 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: 1.0.0+1 15 | 16 | environment: 17 | sdk: ">=2.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | cupertino_icons: ^0.1.2 26 | flutter_switch: 27 | path: ../ 28 | 29 | dev_dependencies: 30 | flutter_test: 31 | sdk: flutter 32 | 33 | 34 | # For information on the generic Dart part of this file, see the 35 | # following page: https://dart.dev/tools/pub/pubspec 36 | 37 | # The following section is specific to Flutter. 38 | flutter: 39 | 40 | # The following line ensures that the Material Icons font is 41 | # included with your application, so that you can use the icons in 42 | # the material Icons class. 43 | uses-material-design: true 44 | 45 | # To add assets to your application, add an assets section, like this: 46 | # assets: 47 | # - images/a_dot_burr.jpeg 48 | # - images/a_dot_ham.jpeg 49 | 50 | # An image asset can refer to one or more resolution-specific "variants", see 51 | # https://flutter.dev/assets-and-images/#resolution-aware. 52 | 53 | # For details regarding adding assets from package dependencies, see 54 | # https://flutter.dev/assets-and-images/#from-packages 55 | 56 | # To add custom fonts to your application, add a fonts section here, 57 | # in this "flutter" section. Each entry in this list should have a 58 | # "family" key with the font family name, and a "fonts" key with a 59 | # list giving the asset and other descriptors for the font. For 60 | # example: 61 | # fonts: 62 | # - family: Schyler 63 | # fonts: 64 | # - asset: fonts/Schyler-Regular.ttf 65 | # - asset: fonts/Schyler-Italic.ttf 66 | # style: italic 67 | # - family: Trajan Pro 68 | # fonts: 69 | # - asset: fonts/TrajanPro.ttf 70 | # - asset: fonts/TrajanPro_Bold.ttf 71 | # weight: 700 72 | # 73 | # For details regarding fonts from package dependencies, 74 | # see https://flutter.dev/custom-fonts/#from-packages 75 | -------------------------------------------------------------------------------- /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 | 11 | import 'package:example/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 | -------------------------------------------------------------------------------- /lib/flutter_switch.dart: -------------------------------------------------------------------------------- 1 | library flutter_switch; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | class FlutterSwitch extends StatefulWidget { 6 | /// Creates a material design switch. 7 | /// 8 | /// The following arguments are required: 9 | /// 10 | /// * [value] determines whether this switch is on or off. 11 | /// * [onToggle] is called when the user toggles the switch on or off. 12 | /// 13 | 14 | const FlutterSwitch({ 15 | Key? key, 16 | required this.value, 17 | required this.onToggle, 18 | this.activeColor = Colors.blue, 19 | this.inactiveColor = Colors.grey, 20 | this.activeTextColor = Colors.white70, 21 | this.inactiveTextColor = Colors.white70, 22 | this.toggleColor = Colors.white, 23 | this.activeToggleColor, 24 | this.inactiveToggleColor, 25 | this.width = 70.0, 26 | this.height = 35.0, 27 | this.toggleSize = 25.0, 28 | this.valueFontSize = 16.0, 29 | this.borderRadius = 20.0, 30 | this.padding = 4.0, 31 | this.showOnOff = false, 32 | this.activeText, 33 | this.inactiveText, 34 | this.activeTextFontWeight, 35 | this.inactiveTextFontWeight, 36 | this.switchBorder, 37 | this.activeSwitchBorder, 38 | this.inactiveSwitchBorder, 39 | this.toggleBorder, 40 | this.activeToggleBorder, 41 | this.inactiveToggleBorder, 42 | this.activeIcon, 43 | this.inactiveIcon, 44 | this.duration = const Duration(milliseconds: 200), 45 | this.disabled = false, 46 | }) : assert( 47 | (switchBorder == null || activeSwitchBorder == null) && 48 | (switchBorder == null || inactiveSwitchBorder == null), 49 | 'Cannot provide switchBorder when an activeSwitchBorder or inactiveSwitchBorder was given\n' 50 | 'To give the switch a border, use "activeSwitchBorder: border" or "inactiveSwitchBorder: border".'), 51 | assert( 52 | (toggleBorder == null || activeToggleBorder == null) && 53 | (toggleBorder == null || inactiveToggleBorder == null), 54 | 'Cannot provide toggleBorder when an activeToggleBorder or inactiveToggleBorder was given\n' 55 | 'To give the toggle a border, use "activeToggleBorder: color" or "inactiveToggleBorder: color".'), 56 | super(key: key); 57 | 58 | /// Determines if the switch is on or off. 59 | /// 60 | /// This property is required. 61 | final bool value; 62 | 63 | /// Called when the user toggles the switch. 64 | /// 65 | /// This property is required. 66 | /// 67 | /// [onToggle] should update the state of the parent [StatefulWidget] 68 | /// using the [setState] method, so that the parent gets rebuilt; for example: 69 | /// 70 | /// ```dart 71 | /// FlutterSwitch( 72 | /// value: _status, 73 | /// width: 110, 74 | /// borderRadius: 30.0, 75 | /// onToggle: (val) { 76 | /// setState(() { 77 | /// _status = val; 78 | /// }); 79 | /// }, 80 | /// ), 81 | /// ``` 82 | final ValueChanged onToggle; 83 | 84 | /// Displays an on or off text. 85 | /// 86 | /// Text value can be override by the [activeText] and 87 | /// [inactiveText] properties. 88 | /// 89 | /// Defaults to 'false' if no value was given. 90 | final bool showOnOff; 91 | 92 | /// The text to display when the switch is on. 93 | /// This parameter is only necessary when [showOnOff] property is true. 94 | /// 95 | /// Defaults to 'On' if no value was given. 96 | /// 97 | /// To change value style, the following properties are available 98 | /// 99 | /// [activeTextColor] - The color to use on the text value when the switch is on. 100 | /// [activeTextFontWeight] - The font weight to use on the text value when the switch is on. 101 | final String? activeText; 102 | 103 | /// The text to display when the switch is off. 104 | /// This parameter is only necessary when [showOnOff] property is true. 105 | /// 106 | /// Defaults to 'Off' if no value was given. 107 | /// 108 | /// To change value style, the following properties are available 109 | /// 110 | /// [inactiveTextColor] - The color to use on the text value when the switch is off. 111 | /// [inactiveTextFontWeight] - The font weight to use on the text value when the switch is off. 112 | final String? inactiveText; 113 | 114 | /// The color to use on the switch when the switch is on. 115 | /// 116 | /// Defaults to [Colors.blue]. 117 | final Color activeColor; 118 | 119 | /// The color to use on the switch when the switch is off. 120 | /// 121 | /// Defaults to [Colors.grey]. 122 | final Color inactiveColor; 123 | 124 | /// The color to use on the text value when the switch is on. 125 | /// This parameter is only necessary when [showOnOff] property is true. 126 | /// 127 | /// Defaults to [Colors.white70]. 128 | final Color activeTextColor; 129 | 130 | /// The color to use on the text value when the switch is off. 131 | /// This parameter is only necessary when [showOnOff] property is true. 132 | /// 133 | /// Defaults to [Colors.white70]. 134 | final Color inactiveTextColor; 135 | 136 | /// The font weight to use on the text value when the switch is on. 137 | /// This parameter is only necessary when [showOnOff] property is true. 138 | /// 139 | /// Defaults to [FontWeight.w900]. 140 | final FontWeight? activeTextFontWeight; 141 | 142 | /// The font weight to use on the text value when the switch is off. 143 | /// This parameter is only necessary when [showOnOff] property is true. 144 | /// 145 | /// Defaults to [FontWeight.w900]. 146 | final FontWeight? inactiveTextFontWeight; 147 | 148 | /// The color to use on the toggle of the switch. 149 | /// 150 | /// Defaults to [Colors.white]. 151 | /// 152 | /// If the [activeSwitchBorder] or [inactiveSwitchBorder] is used, this property must be null. 153 | final Color toggleColor; 154 | 155 | /// The color to use on the toggle of the switch when the given value is true. 156 | /// 157 | /// If [inactiveToggleColor] is used and this property is null. the value of 158 | /// [Colors.white] will be used. 159 | final Color? activeToggleColor; 160 | 161 | /// The color to use on the toggle of the switch when the given value is false. 162 | /// 163 | /// If [activeToggleColor] is used and this property is null. the value of 164 | /// [Colors.white] will be used. 165 | final Color? inactiveToggleColor; 166 | 167 | /// The given width of the switch. 168 | /// 169 | /// Defaults to a width of 70.0. 170 | final double width; 171 | 172 | /// The given height of the switch. 173 | /// 174 | /// Defaults to a height of 35.0. 175 | final double height; 176 | 177 | /// The size of the toggle of the switch. 178 | /// 179 | /// Defaults to a size of 25.0. 180 | final double toggleSize; 181 | 182 | /// The font size of the values of the switch. 183 | /// This parameter is only necessary when [showOnOff] property is true. 184 | /// 185 | /// Defaults to a size of 16.0. 186 | final double valueFontSize; 187 | 188 | /// The border radius of the switch. 189 | /// 190 | /// Defaults to the value of 20.0. 191 | final double borderRadius; 192 | 193 | /// The padding of the switch. 194 | /// 195 | /// Defaults to the value of 4.0. 196 | final double padding; 197 | 198 | /// The border of the switch. 199 | /// 200 | /// This property will give a uniform border to both states of the toggle 201 | /// 202 | /// If the [activeSwitchBorder] or [inactiveSwitchBorder] is used, this property must be null. 203 | final BoxBorder? switchBorder; 204 | 205 | /// The border of the switch when the given value is true. 206 | /// 207 | /// This property is optional. 208 | final BoxBorder? activeSwitchBorder; 209 | 210 | /// The border of the switch when the given value is false. 211 | /// 212 | /// This property is optional. 213 | final BoxBorder? inactiveSwitchBorder; 214 | 215 | /// The border of the toggle. 216 | /// 217 | /// This property will give a uniform border to both states of the toggle 218 | /// 219 | /// If the [activeToggleBorder] or [inactiveToggleBorder] is used, this property must be null. 220 | final BoxBorder? toggleBorder; 221 | 222 | /// The border of the toggle when the given value is true. 223 | /// 224 | /// This property is optional. 225 | final BoxBorder? activeToggleBorder; 226 | 227 | /// The border of the toggle when the given value is false. 228 | /// 229 | /// This property is optional. 230 | final BoxBorder? inactiveToggleBorder; 231 | 232 | /// The icon inside the toggle when the given value is true. 233 | /// activeIcon can be an Icon Widget, an Image or Fontawesome Icons. 234 | /// 235 | /// This property is optional. 236 | final Widget? activeIcon; 237 | 238 | /// The icon inside the toggle when the given value is false. 239 | /// inactiveIcon can be an Icon Widget, an Image or Fontawesome Icons. 240 | /// 241 | /// This property is optional. 242 | final Widget? inactiveIcon; 243 | 244 | /// The duration in milliseconds to change the state of the switch 245 | /// 246 | /// Defaults to the value of 200 milliseconds. 247 | final Duration duration; 248 | 249 | /// Determines whether the switch is disabled. 250 | /// 251 | /// Defaults to the value of false. 252 | final bool disabled; 253 | 254 | @override 255 | _FlutterSwitchState createState() => _FlutterSwitchState(); 256 | } 257 | 258 | class _FlutterSwitchState extends State 259 | with SingleTickerProviderStateMixin { 260 | late final Animation _toggleAnimation; 261 | late final AnimationController _animationController; 262 | 263 | @override 264 | void initState() { 265 | super.initState(); 266 | _animationController = AnimationController( 267 | vsync: this, 268 | value: widget.value ? 1.0 : 0.0, 269 | duration: widget.duration, 270 | ); 271 | _toggleAnimation = AlignmentTween( 272 | begin: Alignment.centerLeft, 273 | end: Alignment.centerRight, 274 | ).animate( 275 | CurvedAnimation( 276 | parent: _animationController, 277 | curve: Curves.linear, 278 | ), 279 | ); 280 | } 281 | 282 | @override 283 | void dispose() { 284 | _animationController.dispose(); 285 | super.dispose(); 286 | } 287 | 288 | @override 289 | void didUpdateWidget(FlutterSwitch oldWidget) { 290 | super.didUpdateWidget(oldWidget); 291 | 292 | if (oldWidget.value == widget.value) return; 293 | 294 | if (widget.value) 295 | _animationController.forward(); 296 | else 297 | _animationController.reverse(); 298 | } 299 | 300 | @override 301 | Widget build(BuildContext context) { 302 | Color _toggleColor = Colors.white; 303 | Color _switchColor = Colors.white; 304 | Border? _switchBorder; 305 | Border? _toggleBorder; 306 | 307 | if (widget.value) { 308 | _toggleColor = widget.activeToggleColor ?? widget.toggleColor; 309 | _switchColor = widget.activeColor; 310 | _switchBorder = widget.activeSwitchBorder as Border? ?? 311 | widget.switchBorder as Border?; 312 | _toggleBorder = widget.activeToggleBorder as Border? ?? 313 | widget.toggleBorder as Border?; 314 | } else { 315 | _toggleColor = widget.inactiveToggleColor ?? widget.toggleColor; 316 | _switchColor = widget.inactiveColor; 317 | _switchBorder = widget.inactiveSwitchBorder as Border? ?? 318 | widget.switchBorder as Border?; 319 | _toggleBorder = widget.inactiveToggleBorder as Border? ?? 320 | widget.toggleBorder as Border?; 321 | } 322 | 323 | double _textSpace = widget.width - widget.toggleSize; 324 | 325 | return AnimatedBuilder( 326 | animation: _animationController, 327 | builder: (context, child) { 328 | return Container( 329 | width: widget.width, 330 | child: Align( 331 | child: GestureDetector( 332 | onTap: () { 333 | if (!widget.disabled) { 334 | if (widget.value) 335 | _animationController.forward(); 336 | else 337 | _animationController.reverse(); 338 | 339 | widget.onToggle(!widget.value); 340 | } 341 | }, 342 | child: Opacity( 343 | opacity: widget.disabled ? 0.6 : 1, 344 | child: Container( 345 | width: widget.width, 346 | height: widget.height, 347 | padding: EdgeInsets.all(widget.padding), 348 | decoration: BoxDecoration( 349 | borderRadius: BorderRadius.circular(widget.borderRadius), 350 | color: _switchColor, 351 | border: _switchBorder, 352 | ), 353 | child: Stack( 354 | children: [ 355 | AnimatedOpacity( 356 | opacity: widget.value ? 1.0 : 0.0, 357 | duration: widget.duration, 358 | child: Container( 359 | width: _textSpace, 360 | padding: EdgeInsets.symmetric(horizontal: 4.0), 361 | alignment: Alignment.centerLeft, 362 | child: _activeText, 363 | ), 364 | ), 365 | Align( 366 | alignment: Alignment.centerRight, 367 | child: AnimatedOpacity( 368 | opacity: !widget.value ? 1.0 : 0.0, 369 | duration: widget.duration, 370 | child: Container( 371 | width: _textSpace, 372 | padding: EdgeInsets.symmetric(horizontal: 4.0), 373 | alignment: Alignment.centerRight, 374 | child: _inactiveText, 375 | ), 376 | ), 377 | ), 378 | Container( 379 | child: Align( 380 | alignment: _toggleAnimation.value, 381 | child: Container( 382 | width: widget.toggleSize, 383 | height: widget.toggleSize, 384 | padding: EdgeInsets.all(4.0), 385 | decoration: BoxDecoration( 386 | shape: BoxShape.circle, 387 | color: _toggleColor, 388 | border: _toggleBorder, 389 | ), 390 | child: FittedBox( 391 | fit: BoxFit.contain, 392 | child: Container( 393 | child: Stack( 394 | children: [ 395 | Center( 396 | child: AnimatedOpacity( 397 | opacity: widget.value ? 1.0 : 0.0, 398 | duration: widget.duration, 399 | child: widget.activeIcon, 400 | ), 401 | ), 402 | Center( 403 | child: AnimatedOpacity( 404 | opacity: !widget.value ? 1.0 : 0.0, 405 | duration: widget.duration, 406 | child: widget.inactiveIcon, 407 | ), 408 | ), 409 | ], 410 | ), 411 | ), 412 | ), 413 | ), 414 | ), 415 | ), 416 | ], 417 | ), 418 | ), 419 | ), 420 | ), 421 | ), 422 | ); 423 | }, 424 | ); 425 | } 426 | 427 | FontWeight get _activeTextFontWeight => 428 | widget.activeTextFontWeight ?? FontWeight.w900; 429 | FontWeight get _inactiveTextFontWeight => 430 | widget.inactiveTextFontWeight ?? FontWeight.w900; 431 | 432 | Widget get _activeText { 433 | if (widget.showOnOff) { 434 | return Text( 435 | widget.activeText ?? "On", 436 | style: TextStyle( 437 | color: widget.activeTextColor, 438 | fontWeight: _activeTextFontWeight, 439 | fontSize: widget.valueFontSize, 440 | ), 441 | ); 442 | } 443 | 444 | return Text(""); 445 | } 446 | 447 | Widget get _inactiveText { 448 | if (widget.showOnOff) { 449 | return Text( 450 | widget.inactiveText ?? "Off", 451 | style: TextStyle( 452 | color: widget.inactiveTextColor, 453 | fontWeight: _inactiveTextFontWeight, 454 | fontSize: widget.valueFontSize, 455 | ), 456 | textAlign: TextAlign.right, 457 | ); 458 | } 459 | 460 | return Text(""); 461 | } 462 | } 463 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.5.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0" 46 | fake_async: 47 | dependency: transitive 48 | description: 49 | name: fake_async 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.2.0" 53 | flutter: 54 | dependency: "direct main" 55 | description: flutter 56 | source: sdk 57 | version: "0.0.0" 58 | flutter_test: 59 | dependency: "direct dev" 60 | description: flutter 61 | source: sdk 62 | version: "0.0.0" 63 | matcher: 64 | dependency: transitive 65 | description: 66 | name: matcher 67 | url: "https://pub.dartlang.org" 68 | source: hosted 69 | version: "0.12.10" 70 | meta: 71 | dependency: transitive 72 | description: 73 | name: meta 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "1.3.0" 77 | path: 78 | dependency: transitive 79 | description: 80 | name: path 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.8.0" 84 | sky_engine: 85 | dependency: transitive 86 | description: flutter 87 | source: sdk 88 | version: "0.0.99" 89 | source_span: 90 | dependency: transitive 91 | description: 92 | name: source_span 93 | url: "https://pub.dartlang.org" 94 | source: hosted 95 | version: "1.8.0" 96 | stack_trace: 97 | dependency: transitive 98 | description: 99 | name: stack_trace 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "1.10.0" 103 | stream_channel: 104 | dependency: transitive 105 | description: 106 | name: stream_channel 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "2.1.0" 110 | string_scanner: 111 | dependency: transitive 112 | description: 113 | name: string_scanner 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.1.0" 117 | term_glyph: 118 | dependency: transitive 119 | description: 120 | name: term_glyph 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.2.0" 124 | test_api: 125 | dependency: transitive 126 | description: 127 | name: test_api 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "0.2.19" 131 | typed_data: 132 | dependency: transitive 133 | description: 134 | name: typed_data 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.3.0" 138 | vector_math: 139 | dependency: transitive 140 | description: 141 | name: vector_math 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "2.1.0" 145 | sdks: 146 | dart: ">=2.12.0 <3.0.0" 147 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_switch 2 | description: A custom switch widget that can have a custom height and width, borders, border radius, colors, toggle size, custom text and icons inside the toggle. 3 | version: 0.3.1 4 | homepage: https://github.com/boringdeveloper/FlutterSwitch 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | dev_dependencies: 14 | flutter_test: 15 | sdk: flutter 16 | 17 | # For information on the generic Dart part of this file, see the 18 | # following page: https://dart.dev/tools/pub/pubspec 19 | 20 | # The following section is specific to Flutter. 21 | flutter: 22 | 23 | # To add assets to your package, add an assets section, like this: 24 | # assets: 25 | # - images/a_dot_burr.jpeg 26 | # - images/a_dot_ham.jpeg 27 | # 28 | # For details regarding assets in packages, see 29 | # https://flutter.dev/assets-and-images/#from-packages 30 | # 31 | # An image asset can refer to one or more resolution-specific "variants", see 32 | # https://flutter.dev/assets-and-images/#resolution-aware. 33 | 34 | # To add custom fonts to your package, add a fonts section here, 35 | # in this "flutter" section. Each entry in this list should have a 36 | # "family" key with the font family name, and a "fonts" key with a 37 | # list giving the asset and other descriptors for the font. For 38 | # example: 39 | # fonts: 40 | # - family: Schyler 41 | # fonts: 42 | # - asset: fonts/Schyler-Regular.ttf 43 | # - asset: fonts/Schyler-Italic.ttf 44 | # style: italic 45 | # - family: Trajan Pro 46 | # fonts: 47 | # - asset: fonts/TrajanPro.ttf 48 | # - asset: fonts/TrajanPro_Bold.ttf 49 | # weight: 700 50 | # 51 | # For details regarding fonts in packages, see 52 | # https://flutter.dev/custom-fonts/#from-packages 53 | -------------------------------------------------------------------------------- /test/flutter_switch_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | 4 | import '../lib/flutter_switch.dart'; 5 | 6 | void main() { 7 | group("FlutterSwitch", () { 8 | final alignToggleIndicatorFinder = find.byWidgetPredicate( 9 | (widget) => widget is Align && widget.child is Container); 10 | 11 | testWidgets( 12 | "displays the toggle indicator on the right if the given value is true", 13 | (WidgetTester tester) async { 14 | await tester.pumpWidget( 15 | _FlutterSwitchTest( 16 | status: true, 17 | ), 18 | ); 19 | 20 | final align = tester.widget(alignToggleIndicatorFinder); 21 | 22 | expect(align.alignment, equals(Alignment.centerRight)); 23 | }, 24 | ); 25 | 26 | testWidgets( 27 | "displays the toggle indicator on the left if the given value is false", 28 | (WidgetTester tester) async { 29 | await tester.pumpWidget( 30 | _FlutterSwitchTest( 31 | status: false, 32 | ), 33 | ); 34 | 35 | final align = tester.widget(alignToggleIndicatorFinder); 36 | 37 | expect(align.alignment, equals(Alignment.centerLeft)); 38 | }, 39 | ); 40 | 41 | testWidgets( 42 | "changes the toggle indicator alignment to the right on tap when the initial value is false", 43 | (WidgetTester tester) async { 44 | await tester.pumpWidget( 45 | new _FlutterSwitchTest( 46 | status: false, 47 | ), 48 | ); 49 | 50 | await tester.tap(find.byType(FlutterSwitch)); 51 | await tester.pumpAndSettle(); 52 | 53 | final align = tester.widget(alignToggleIndicatorFinder); 54 | 55 | expect(align.alignment, equals(Alignment.centerRight)); 56 | }, 57 | ); 58 | 59 | testWidgets( 60 | "changes the toggle indicator alignment to the left on tap when the initial value is true", 61 | (WidgetTester tester) async { 62 | await tester.pumpWidget( 63 | _FlutterSwitchTest( 64 | status: true, 65 | ), 66 | ); 67 | 68 | await tester.tap(find.byType(FlutterSwitch)); 69 | await tester.pumpAndSettle(); 70 | 71 | final align = tester.widget(alignToggleIndicatorFinder); 72 | 73 | expect(align.alignment, equals(Alignment.centerLeft)); 74 | }, 75 | ); 76 | 77 | testWidgets( 78 | "throws an assertion error when both switchBorder and activeSwitchBorder property is not null", 79 | (WidgetTester tester) async { 80 | await tester.pumpWidget( 81 | _FlutterSwitchTest( 82 | status: false, 83 | switchBorder: Border.all( 84 | color: Colors.black, 85 | width: 6.0, 86 | ), 87 | activeSwitchBorder: Border.all( 88 | color: Colors.blue, 89 | width: 6.0, 90 | ), 91 | ), 92 | ); 93 | 94 | final assertion = tester.takeException(); 95 | 96 | expect(assertion, isAssertionError); 97 | }, 98 | ); 99 | 100 | testWidgets( 101 | "throws an assertion error when both switchBorder and inactiveSwitchBorder property is not null", 102 | (WidgetTester tester) async { 103 | await tester.pumpWidget( 104 | _FlutterSwitchTest( 105 | status: false, 106 | switchBorder: Border.all( 107 | color: Colors.black, 108 | width: 6.0, 109 | ), 110 | inactiveSwitchBorder: Border.all( 111 | color: Colors.blueGrey, 112 | width: 6.0, 113 | ), 114 | ), 115 | ); 116 | 117 | final assertion = tester.takeException(); 118 | 119 | expect(assertion, isAssertionError); 120 | }, 121 | ); 122 | 123 | testWidgets( 124 | "throws an assertion error when both toggleBorder and activeToggleBorder property is not null", 125 | (WidgetTester tester) async { 126 | await tester.pumpWidget( 127 | _FlutterSwitchTest( 128 | status: false, 129 | toggleBorder: Border.all( 130 | color: Colors.black, 131 | width: 6.0, 132 | ), 133 | activeToggleBorder: Border.all( 134 | color: Colors.blue, 135 | width: 6.0, 136 | ), 137 | ), 138 | ); 139 | 140 | final assertion = tester.takeException(); 141 | 142 | expect(assertion, isAssertionError); 143 | }, 144 | ); 145 | 146 | testWidgets( 147 | "throws an assertion error when both toggleBorder and inactiveToggleBorder property is not null", 148 | (WidgetTester tester) async { 149 | await tester.pumpWidget( 150 | _FlutterSwitchTest( 151 | status: false, 152 | toggleBorder: Border.all( 153 | color: Colors.black, 154 | width: 6.0, 155 | ), 156 | inactiveToggleBorder: Border.all( 157 | color: Colors.blueGrey, 158 | width: 6.0, 159 | ), 160 | ), 161 | ); 162 | 163 | final assertion = tester.takeException(); 164 | 165 | expect(assertion, isAssertionError); 166 | }, 167 | ); 168 | }); 169 | } 170 | 171 | /// A testbed class needed to test the [FlutterSwitch] widget. 172 | class _FlutterSwitchTest extends StatefulWidget { 173 | final bool status; 174 | final Border? switchBorder; 175 | final Border? activeSwitchBorder; 176 | final Border? inactiveSwitchBorder; 177 | final Border? toggleBorder; 178 | final Border? activeToggleBorder; 179 | final Border? inactiveToggleBorder; 180 | 181 | _FlutterSwitchTest({ 182 | Key? key, 183 | required this.status, 184 | this.switchBorder, 185 | this.activeSwitchBorder, 186 | this.inactiveSwitchBorder, 187 | this.toggleBorder, 188 | this.activeToggleBorder, 189 | this.inactiveToggleBorder, 190 | }) : super(key: key); 191 | 192 | @override 193 | __FlutterSwitchTestState createState() => __FlutterSwitchTestState(); 194 | } 195 | 196 | class __FlutterSwitchTestState extends State<_FlutterSwitchTest> { 197 | bool _status = false; 198 | 199 | @override 200 | void initState() { 201 | super.initState(); 202 | 203 | setState(() { 204 | _status = widget.status; 205 | }); 206 | } 207 | 208 | @override 209 | Widget build(BuildContext context) { 210 | return MaterialApp( 211 | home: Scaffold( 212 | body: FlutterSwitch( 213 | value: _status, 214 | switchBorder: widget.switchBorder, 215 | activeSwitchBorder: widget.activeSwitchBorder, 216 | inactiveSwitchBorder: widget.inactiveSwitchBorder, 217 | toggleBorder: widget.toggleBorder, 218 | activeToggleBorder: widget.activeToggleBorder, 219 | inactiveToggleBorder: widget.inactiveToggleBorder, 220 | onToggle: (val) { 221 | setState(() { 222 | _status = val; 223 | }); 224 | }, 225 | ), 226 | ), 227 | ); 228 | } 229 | } 230 | --------------------------------------------------------------------------------