Code Monkey home page Code Monkey logo

spinner_input's Introduction

profile

spinner_input's People

Contributors

ali-azmoud avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

spinner_input's Issues

Problem with spinner input value updating

When you update the value of the variable affected by a SpinnerInput widget with an action from another widget, at first the value is changed correctly, but then when you use the spinner's buttons again, it acts as though the update never happened.

I don't think I am missing anything about how the SpinnerInput is supposed to be used, and I have tried several things to address this problem, but nothing seems to work.

I have included a complete minimal app below showing the problem, but here is the key bit of the code:

            SpinnerInput(
              minValue: 1,
              maxValue: 50,
              step: 1,
              spinnerValue: _spinnervalue,
              onChange: (value) {setState(() {_spinnervalue = value;});},
            ),
            RaisedButton(
                onPressed: () {setState(() {_spinnervalue = initialvalue;});},
              child: Text('Clear')
            ),

In the running app, click the "+" button a few times, say to take the value from 20 up to 25. Then click the "Clear" button -- this sets the value of the spinner back to its initial value of 20. Then click "+" again, just once, and it shows... 26?! It's like you never hit the "Clear" button.

If I'm just doing something wrong here, please let me know, but I think the problem is deeper than that.

Here is the complete Flutter app code:

import 'package:flutter/material.dart';
import 'package:spinner_input/spinner_input.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Spinner Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Spinner Test Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double _spinnervalue = 20;
  final double _initialvalue = 20;

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SpinnerInput(
              minValue: 1,
              maxValue: 50,
              step: 1,
              spinnerValue: _spinnervalue,
              onChange: (value) {setState(() {_spinnervalue = value;});},
            ),
            RaisedButton(
                onPressed: () {setState(() {_spinnervalue = _initialvalue;});},
              child: Text('Clear')
            ),
          ],
        ),
      ),
    );
  }
}

My use case where this appeared: I have several of these SpinnerInput widgets in an app, and I want to have a single button that the user can click to set all of the spinners back to their initial default values. As seen in the app above, the behavior of the SpinnerInput widget after the action of the button has occurred is not correct for this use.

Submit value by keyboard

Hi
I'm submitting the value from keyboard to spinner,then I have to submit it by pressing green button inside spinner..so need 2 submits for a value
is there any fix?

Problem with value update

Hi, @Ali-Azmoud I have the same problem of #1 with version 0.1.2.
this is my code:

Future<void> _setCustomHours() async {
    return showDialog<void>(
      context: context,
      barrierDismissible: false,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('Set hours', textAlign: TextAlign.center,),
          content: SingleChildScrollView(
            child: ListBody(
              mainAxis: Axis.vertical,
              children: <Widget>[
                Padding(
                  padding: EdgeInsets.only(
                    top:15.0
                  ),
                ),
                Center(
                  child: SpinnerInput(
                    minValue: 1,
                    maxValue: 10,
                    step: 0.5,
                    fractionDigits: 1,
                    disabledLongPress: true,
                    disabledPopup: true,
                    plusButton: SpinnerButtonStyle(
                      elevation: 3, 
                      height: 40,
                      width: 40,
                      color: Colors.grey[300], 
                      textColor: Colors.black, 
                      borderRadius: BorderRadius.circular(3)
                    ),
                    minusButton: SpinnerButtonStyle(
                      elevation: 3, 
                      height: 40,
                      width: 40,
                      color: Colors.grey[300], 
                      textColor: Colors.black, 
                      borderRadius: BorderRadius.circular(3)
                    ),
                    middleNumberWidth: 80,
                    middleNumberStyle: TextStyle(
                      fontSize: 14,
                      fontWeight: FontWeight.bold
                    ),
                    spinnerValue: hours, //hours is a double initialized to 1.0 in the State
                    onChange: (newValue) {
                      setState(() => hours = newValue);
                    },
                  ),
                ),
              ],
            ),
          ),
          actions: <Widget>[
            FlatButton(
              child: Text('OK'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            )
          ],
        );
      },
    );
  }

When the app starts, I see the value 1.0.
If I tap + or - the value in the state gets updated, while the value I see on the view is still 1.0...

Any idea?
Thanks

Remove Hover effect

In buttons style is no option to remove the elevation effect when cursor/pointer is over the button.

this is correct or i missing something?

a flat style is more useful in some cases like mine.
Captura de pantalla de 2021-11-05 20-41-17

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.