App6 v2 : My Books - Learning New Widgets



  1. CupertinoButton
  2. An iOS-style button.

    Takes in a text or an icon that fades out and in on touch. May optionally have a background.

    The padding defaults to 16.0 pixels. When using a CupertinoButton within a fixed height parent, like a CupertinoNavigationBar, a smaller, or even EdgeInsets.zero, should be used to prevent clipping larger child widgets.

    Some properties of CupertinoButton Class:

    1. borderRadius : BorderRadius?
    2. The radius of the button's corners when it has a background color.

    3. child : Widget
    4. The widget below this widget in the tree.

    5. color : Color?
    6. The color of the button's background.

    7. onPressed :
    8. The callback that is called when the button is tapped or otherwise activated.

    9. padding : EdgeInsetsGeometry?
    10. The amount of space to surround the child inside the bounds of the button.

    Example :


        Scaffold(

          body: Center(

            child: CupertinoButton(

              child: const Text("Click Me !"),

              onPressed: () {

                print("Clicked=");

              },

              borderRadius: BorderRadius.circular(20),

              color: Colors.lightBlue,

              padding: const EdgeInsets.all(8),

            ),

          ),

        )



    CupertinoButton Flutter

  3. CupertinoPicker
  4. An iOS-styled picker.

    Displays its children widgets on a wheel for selection and calls back when the currently selected item changes.

    By default, the first child in children will be the initially selected child. The index of a different child can be specified in scrollController, to make that child the initially selected child.

    Can be used with showCupertinoModalPopup to display the picker modally at the bottom of the screen. When calling showCupertinoModalPopup, be sure to set semanticsDismissible to true to enable dismissing the modal via semantics.

    Sizes itself to its parent. All children are sized to the same size based on itemExtent.

    By default, descendent texts are shown with CupertinoTextThemeData.pickerTextStyle.

    Some properties of CupertinoPicker Class:

    1. children : List<Widget>
    2. The widgets.

    3. backgroundColor : Color?
    4. Background color behind the children.

    5. itemExtent : double
    6. The uniform height of all children.

    7. magnification : double
    8. The zoomed-in rate of the magnifier, if it is used.

    9. onSelectedItemChanged :
    10. An option callback when the currently centered item changes.

    11. selectionOverlay : Widget?
    12. A widget overlaid on the picker to highlight the currently selected entry.

    Example :


            CupertinoPicker(

              children: const [

                Text("Choice 1"),

                Text("Choice 2"),

                Text("Choice 3"),

                Text("Choice 4"),

                Text("Choice 5"),

                Text("Choice 6"),

                Text("Choice 7"),

                Text("Choice 8")

              ],

              backgroundColor: Colors.white38,

              itemExtent: 30,

              magnification: 1.5,

              onSelectedItemChanged: (int val) {

                selected = val;

              },

            ),



    CupertinoPicker Flutter

  5. CupertinoTabBar
  6. An iOS-styled bottom navigation tab bar.

    Displays multiple tabs using BottomNavigationBarItem with one tab being active, the first tab by default.

    This StatelessWidget doesn't store the active tab itself. You must listen to the onTap callbacks and call

    setState with a new currentIndex for the new selection to reflect. This can also be done automatically by wrapping this with a CupertinoTabScaffold. Tab changes typically trigger a switch between Navigators, each with its own navigation stack, per standard

    iOS design. This can be done by using CupertinoTabViews inside each tab builder in CupertinoTabScaffold. If the given backgroundColor's opacity is not 1.0 (which is the case by default), it will produce a blurring effect to the content behind it.

    Some properties of CupertinoTabBar Class:

    1. activeColor : Color?
    2. The foreground color of the icon and title for the BottomNavigationBarItem of the selected tab.

    3. backgroundColor : Color?
    4. The background color of the tab bar. If it contains transparency, the tab bar will automatically produce a blurring effect to the content behind it.

    5. currentIndex : int
    6. The index into items of the current active item.

    7. iconSize : double
    8. The size of all of the BottomNavigationBarItem icons.

    9. inactiveColor : Color
    10. The foreground color of the icon and title for the BottomNavigationBarItems in the unselected state.

    11. items : List<BottomNavigationBarItem>
    12. The interactive items laid out within the bottom navigation bar.

    13. onTap :
    14. The callback that is called when a item is tapped.

    Example :


    int selected = 0;

      final texts = ['RED''BLUE''GREEN'];

      final colors = [Colors.redColors.blueColors.green];

      @override

      Widget build(BuildContext context) {

        return Scaffold(

          bodyCenter(

            childText(texts[selected]),

          ),

          bottomNavigationBarCupertinoTabBar(

            currentIndexselected,

            iconSize50,

            activeColorColors.white,

            inactiveColorColors.grey,

            backgroundColorcolors[selected],

            onTap: (int val) {

              setState(() {

                selected = val;

              });

            },

            itemsconst [

              BottomNavigationBarItem(iconIcon(Icons.arrow_left)),

              BottomNavigationBarItem(iconIcon(Icons.arrow_drop_up)),

              BottomNavigationBarItem(iconIcon(Icons.arrow_right))

            ],

          ),

        );

      }



    CupertinoTabBar Flutter

  7. CupertinoTextField
  8. An iOS-style text field.

    A text field lets the user enter text, either with a hardware keyboard or with an onscreen keyboard.

    This widget corresponds to both a UITextField and an editable UITextView on iOS.

    The text field calls the onChanged callback whenever the user changes the text in the field. If the user indicates that they are done typing in the field (e.g., by pressing a button on the soft keyboard), the text field calls the onSubmitted callback.

    It's important to always use characters when dealing with user input text that may contain complex characters. This will ensure that extended grapheme clusters and surrogate pairs are treated as single characters, as they appear to the user.

    Some properties of CupertinoTextField Class:

    1. controller : TextEditingController?
    2. Controls the text being edited.

    3. decoration : BoxDecoration?
    4. Controls the BoxDecoration of the box behind the text input.

    5. keyboardType : TextInputType
    6. The type of keyboard to use for editing the text.

    7. placeholder : String?
    8. A lighter colored placeholder hint that appears on the first line of the text field when the text entry is empty.

    9. style : TextStyle?
    10. The style to use for the text being edited.

    11. textAlign : TextAlign
    12. How the text should be aligned horizontally.

    Example :


              CupertinoTextField(

                controllertec,

                decorationBoxDecoration(

                  colorColors.white70,

                  borderBorder.all(width2,colorColors.black45),

                  borderRadiusBorderRadius.circular(10)

                ),

                keyboardTypeTextInputType.number,

                placeholder"Age",

                styleconst TextStyle(colorColors.blue),

                textAlignTextAlign.center,

              )



    CupertinoTextField

  9. CupertinoNavigationBar
  10. An iOS-styled navigation bar.

    The navigation bar is a toolbar that minimally consists of a widget, normally a page title, in the middle of the toolbar.

    Some properties of CupertinoNavigationBar Class:

    1. backgroundColor : Color?
    2. The background color of the navigation bar. If it contains transparency, the tab bar will automatically produce a blurring effect to the content behind it.

    3. leading : Widget?
    4. Widget to place at the start of the navigation bar. Normally a back button for a normal page or a cancel button for full page dialogs.

    5. middle : Widget?
    6. Widget to place in the middle of the navigation bar. Normally a title or a segmented control.

    7. trailing : Widget?
    8. Widget to place at the end of the navigation bar. Normally additional actions taken on the page such as a search or edit function

    Example :


        Scaffold(

          appBar: CupertinoNavigationBar(

            backgroundColor: Colors.lightGreenAccent,

            leading: Icon(Icons.home),

            middle: Text("Home"),

            trailing: Icon(Icons.travel_explore),

          ),

        )



    CupertinoNavigationBar Flutter