Coder Social home page Coder Social logo

boringdeveloper / flutterswitch Goto Github PK

View Code? Open in Web Editor NEW
76.0 2.0 62.0 179 KB

A Custom Switch package created for Flutter.

Home Page: https://pub.dev/packages/flutter_switch

License: BSD 3-Clause "New" or "Revised" License

Kotlin 1.15% Swift 1.13% Objective-C 0.10% Dart 97.61%
dart custom-switch flutter dart-package flutter-package flutter-widget pub

flutterswitch's Introduction

Hi there  

Yo! I'm Nichole John Romero, a Mobile and Web Developer from the Philippines. I'm currently a UI Specialist at PageUp. I was formerly a Mobile Analyst Programmer at Sun Life Financial Asia Services Limited. Formerly a UI Developer and Mobile Support Consultant, 🗣️ at Yondu, Inc. deployed as a Contractor for Sunlife PH. I'm also a Former Software Developer 👨‍💻 at Cloud Panda PH, Inc. and a Former Web Developer Intern 👨‍🎓 at Prople BPO Inc.. During my spare time I self-study Flutter development 👨‍🏫

Developer GIF

🔭 I’m currently working on

some projects using Flutter.
and also doing some clone of famous apps
Grab Food UI Clone

🌱 I’m currently learning

how to develop using Angular and NodeJS

💻 I'm using these languages and tools

📫 How to reach me:

📧 [email protected]
🗨️ Discord: Nickr#7895
Nick's LinkdeIn Nick's LinkdeIn


boringdeveloper achievements

boringdeveloper github stats

flutterswitch's People

Contributors

allcontributors[bot] avatar boringdeveloper avatar douglasramos avatar lucased78 avatar nickr-dev avatar solid-daniyilyevtyushkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutterswitch's Issues

Widget Disable Parameter

I am using this switch in one of the main sections of my app and sometimes, in some occasions, it would be very helpful to be able to disable the flutter_switch until some other parameters or inputs get ready or became available.
It looks like there is no property available to disable/enable the flutter_switch widget at the moment and I think it would be great to be able to do so.

Thanks for your great job.

check state on app restart

Hi there,

I can't find any controller to change the switch's state outside the widget.
I want to check status of some parameters on app start and then toggle switches respectively without calling the onToggle() call routine, but I can't find any way to do so.

I would appreciate any suggestion/solution.

Thanks.

Switch with motion event (Swipe gesture should invoke switch toggle moving)

Hey, first of all I would like to say thank for all of you guys, you did nice job. Really appreciate that!

The thing I've notice is that:
The Switch doesn't move by swipe gesture from left to right and opposite.

Does the widget have such kind of feature? Maybe I missed that, not sure...

Anyway, this one should be present I suppose.
Are someone doing something like that?
I can basically contribute that.

Thank you

Reduce padding between toggle and edges to 0

I am trying to create a switch like in this image:
image

However, I cannot find a way to reduce the distance between the toggle and the edges to 0.
It ends up looking like this:
image

It would be nice if there was a setting that allows to remove this little bit of padding.

I have already looked at the code and by subtracting 9 from the Container width on line 382 I get the following:
image

This is certainly better, but the 9 is hardcoded for my specific toggle size.

size is not properly manage by default

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

impossible to use with sharedpreference

hello, when I save bool statuts with sharedpreference and I load last value of statut I havn't change...

For exemple If my last statuts is true, and I load statut at the initStat I this print statuts : true but there is no switch of button...

The image not fill all toggle space

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. create the switch with active icon = Image.asset.
  2. change toggleColor: Colors.red (to make it more visible)
  3. See error

Expected behavior
The image should be filled and have a fixed height and width (no red color).

Screenshots
image

Smartphone (please complete the following information):

  • Device: iPhone Xr
  • OS: iOS15

Additional context
Source code:

return FlutterSwitch(
      value: _currentValue,
      onToggle: (newValue) {
        setState(() {
          _currentValue = newValue;
        });
      },
      height: 30,
      activeIcon: Image.asset(
        'slider-thumb'.pngAssetsPath,
        height: 30,
      ),
      inactiveIcon: Image.asset(
        'slider-thumb'.pngAssetsPath,
        height: 30,
      ),
      toggleColor: Colors.red,
      activeColor: CustomColors.greenIndicator,
      inactiveColor: CustomColors.pinkIndicator,
);

Thanks

Switching animation only has 3 frames

I notice the animation is not smooth when I use this widget. then I enable slow animations to observe the animation, I found the animation only has 3 frames.
To solve this problem, I changed part of the code to the following figure.
image

It works well for me now.

Tickers used by AnimationControllers should be disposed by calling dispose()

Your widget doesn't have AnimationControllers.dispose() and always is falling down

_FlutterSwitchState#e50c7(ticker active) was disposed with an active Ticker.
I/flutter (20111): _FlutterSwitchState created a Ticker via its SingleTickerProviderStateMixin, but at the time
I/flutter (20111): dispose() was called on the mixin, that Ticker was still active. The Ticker must be disposed before
I/flutter (20111): calling super.dispose().
I/flutter (20111): Tickers used by AnimationControllers should be disposed by calling dispose() on the
I/flutter (20111): AnimationController itself. Otherwise, the ticker will leak.

while testing on iOS, in my crashlytics this message is shown every time I use the switch

_FlutterSwitchState#3fb33(ticker active) was disposed with an active Ticker. _FlutterSwitchState created a Ticker via its SingleTickerProviderStateMixin, but at the time dispose() was called on the mixin, that Ticker was still active. The Ticker must be disposed before calling super.dispose(). Tickers used by AnimationControllers should be disposed by calling dispose() on the AnimationController itself. Otherwise, the ticker will leak. The offending ticker was: Ticker(created by _FlutterSwitchState#3fb33(lifecycle state: created)) The stack trace when the Ticker was actually created was: #0 new Ticker.<anonymous closure> (package:flutter/src/scheduler/ticker.dart:67:40) #1 new Ticker (package:flutter/src/scheduler/ticker.dart:69:6) #2 SingleTickerProviderStateMixin.createTicker (package:flutter/src/widgets/ticker_provider.dart:131:15) #3 new AnimationController (package:flutter/src/animation/animation_controller.dart:248:21) #4 _FlutterSwitchState.initState (package:flutter_switch/flutter_switch.dart:44:28) #5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58) #6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5) #7 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) #8 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6236:32) ... Normal element mounting (4 frames) #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) #13 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6236:32) ... Normal element mounting (16 frames) #29 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) #30 Element.updateChild (package:flutter/src/widgets/framework.dart:3324:20) #31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4652:16) #32 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:48 <fn>

Missing RTL support

Describe the bug
When changing language to Arabic or any RTL language the text overlaps with button.

To Reproduce
Steps to reproduce the behavior:

  1. Set language to Arabic
  2. Toggle the switch
  3. The text in the toggle will overflow with button.

Expected behavior
It should follow RTL layout.

Screenshots
Screenshot_20211123-161424.jpg

Smartphone (please complete the following information):

  • Device: [OnePlus 6T]
  • OS: [Android 11]

Additional context
Screenshot_20211123-161538.jpg

In LTR everything looks fine.

Custom Text Switch with custom shape toggle might be good

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Null Safety

Dart 2.12 and Flutter 2 now support sound null safety (https://dart.dev/null-safety). We're using FlutterSwitch and looking to move everything to be null safe. Could you give me an idea of if/when you plan on supporting? Thanks!

Fist Switch action is not checking conditions in "onToggle"

I'm checking some conditions before witching the button. But when Switch the button for the first time (ON to OFF or OFF to ON), It is not checking the conditions in onToggle

 child: FlutterSwitch(
          width: 125.0,
          height: 55.0,
          valueFontSize: 25.0,
          toggleSize: 45.0,
          value: value,
          borderRadius: 30.0,
          padding: 8.0,
          showOnOff: true,
          onToggle: (val) {
            if (conditions) {
              setState(() {
                this.value = val;
              });
            } else {
              setState(() {
                this.value = !val;
              });
            }
          },
        ),

Version used

pubspec.yaml

flutter_switch: ^0.1.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.