Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter increment decrement widget

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kadir_alkan_kuafor/models/general_model.dart';
import 'package:kadir_alkan_kuafor/models/number_increment_decrement_model.dart';
 
class NumberIncrementDecrement extends StatefulWidget {
  final NumberIncrementDecrementModel numberIncrementDecrementModel;
 
  NumberIncrementDecrement({Key key, this.numberIncrementDecrementModel})
      : super(key: key);
 
  @override
  State<statefulwidget> createState() => _NumberIncrementDecrementState(
      numberIncrementDecrementModel: this.numberIncrementDecrementModel);
}
 
class _NumberIncrementDecrementState extends State<numberincrementdecrement> {
  General general = new General();
 
  TextEditingController controller = TextEditingController();
  final NumberIncrementDecrementModel numberIncrementDecrementModel;
 
  _NumberIncrementDecrementState({
    @required this.numberIncrementDecrementModel,
  });
 
  @override
  void initState() {
    super.initState();
    controller.addListener(onChange);
  }
 
  void onChange() {
    this.numberIncrementDecrementModel.value=int.parse(controller.text.replaceAll("Adet", "").trim());
  }
  @override
  Widget build(BuildContext context) {
    return new Row(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <widget>[
        SizedBox(
            width: 25,
            height: 48,
            child: GestureDetector(
              onTap: () => minus(),
              child: Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.only(
                          topLeft: new Radius.circular(5),
                          bottomLeft: new Radius.circular(5)),
                      border: Border.all(width: 2, color: Colors.white)),
                  child: Icon(Icons.remove, color: Colors.black)),
            )),
        SizedBox(
          width: 80,
          height: 50,
          child: TextField(
            autofocus: false,
            controller: controller,
            keyboardType: TextInputType.number,
            textAlign: TextAlign.center,
            style: TextStyle(color: Colors.yellow),
            inputFormatters: [WhitelistingTextInputFormatter.digitsOnly],
            decoration: InputDecoration(
              contentPadding: EdgeInsets.all(8.0),
              hintText: this.numberIncrementDecrementModel.value.toString()+" Adet",
              hintStyle: TextStyle(color: Colors.yellow),
              enabledBorder: const OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.zero),
                borderSide: const BorderSide(color: Colors.white, width: 2.0),
              ),
              focusedBorder: const OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.zero),
                borderSide: const BorderSide(color: Colors.white, width: 2.0),
              ),
            ),
          ),
        ),
        SizedBox(
            width: 25,
            height: 48,
            child: GestureDetector(
              onTap: () => add(),
              child: Container(
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.only(
                          topRight: new Radius.circular(5),
                          bottomRight: new Radius.circular(5)),
                      border: Border.all(width: 2, color: Colors.white)),
                  child: Icon(Icons.add, color: Colors.black)),
            )),
      ],
    );
  }
 
  void add() {
    setState(() {
      this.numberIncrementDecrementModel.value++;
      controller.text = this.numberIncrementDecrementModel.value.toString()+' Adet';
    });
  }
 
  void minus() {
    setState(() {
      if (this.numberIncrementDecrementModel.value != 0) this.numberIncrementDecrementModel.value--;
      controller.text = this.numberIncrementDecrementModel.value.toString()+' Adet';
    });
  }
}
</widget></numberincrementdecrement></statefulwidget>
Comment

PREVIOUS NEXT
Code Example
Dart :: How use late in Dart 
Dart :: ~/ vs / dart 
Dart :: flutter build async 
Dart :: How to create maps by mentioning generic in flutter 
Dart :: tooltip flutter 
Dart :: ruby on rails db migrate 
Dart :: restrick platform orientation flutter 
Dart :: Add glow or shadow to flutter widget 
Dart :: flutter button sound effects 
Dart :: Flutter Text new fline 
Dart :: flutter sizedbo 
Dart :: add sound to my flutter app 
Dart :: flutter conditional parent widget 
Dart :: Remove space between widgets in row flutter 
Dart :: flutter main.dart example 
Dart :: dart add list to list 
Swift :: random string swift 
Swift :: conert data to string swift 
Swift :: xcode get info from text field 
Swift :: firebase nil value equals 
Swift :: swift + time delay call main thread 
Swift :: button sizetofit not working swift 
Swift :: Return multiple value of different types swift 
Swift :: swift test if simulator 
Swift :: remove padding hstack swiftui 
Swift :: string to double swift 
Swift :: how to set the spacing of a collection view swift 
Swift :: swift arrays 
Swift :: swft image 
Swift :: Swift Remove an Element from an Array 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =