Switch

Switch

Switch({Key key, @required bool value, @required ValueChanged onChanged, Color activeColor, Color activeTrackColor, Color inactiveThumbColor, Color inactiveTrackColor, ImageProvider activeThumbImage, ImageProvider inactiveThumbImage, MaterialTapTargetSize materialTapTargetSize, DragStartBehavior dragStartBehavior: DragStartBehavior.down })

açıklama

Açma / kapama düğmeleri sağlayan widget.

parametreler

Switch(
  value: _giveVerse,
  onChanged: (bool newValue) {
    setState(() {
      _giveVerse = newValue;
    });
  },
)


Switch({
@required bool value,
@required ValueChanged onChanged,
Color activeColor,
Color activeTrackColor,
Color inactiveThumbColor,
Color inactiveTrackColor,
ImageProvider activeThumbImage,
ImageProvider inactiveThumbImage,
MaterialTapTargetSize materialTapTargetSize,
DragStartBehavior dragStartBehavior: DragStartBehavior.down
})

örnek uygulama

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


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

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

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State>MyHomePage< {

  bool _value = false;
  void _onChange(bool value)
  {
    setState(() {
      _value = value;
    });

  }
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("Flutter Application"),
      ),
      body: new Container(
        padding: new EdgeInsets.all(32.0),
        child: new Column(
          children: [
      new Switch(value: _value, onChanged: (bool value)
      {

        _onChange(value);
      }

      ),new SwitchListTile(
          title: new Text("Click me"),
          activeColor: Colors.red,

          value: _value,
          onChanged: (bool value){
_onChange(value);
        
      })
          ],
        ),
      ),

    );
  }
}

Bir cevap yazın

KAPAT
%d blogcu bunu beğendi: