LoginSignup
9
4

More than 3 years have passed since last update.

[Flutter] InkWellは意外に強い

Last updated at Posted at 2019-02-15

InkWellを最近愛用してる、

たとえは、Widgetにタッチインターフェースを使いたい時に使用する。

実際に使ったコード例1。

main.dart
InkWell(
                    onTap: (){
                      Navigator.of(context).pushReplacement(
                        MaterialPageRoute(builder:
                        (context) => InputRedPage(
                          origCurrency: widget.currencyone,
                          convCurrency: widget.currencytwo,
                        ))
                      );

                    },
                    child: Text(widget.currencyVal.toString(),
                      style: TextStyle(color: Colors.white,
                        fontSize: 100.0,),),
                  ),


onTapで、画面移動に便利。
TextやContainerによく使う。

GestureDetectorもありますが、これよりには
InkWellに最近ハマった。

実際に使ったコード例2。

main.dart
 InkWell(
          onTap: () {
            Fluttertoast.showToast(
                msg: "button check",
                toastLength: Toast.LENGTH_SHORT,
                gravity: ToastGravity.CENTER,
                timeInSecForIos: 1,
                backgroundColor: Colors.red,
                textColor: Colors.white,
                fontSize: 16.0);

          },
          borderRadius: BorderRadius.circular(30.0),
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Container(
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(30.0),
                  color: Colors.white,
                  border: Border.all(color: Colors.cyan)),
              height: 35.0,
              width: 150.0,
              child: Center(
                child: Text(
                  "Button Text 1",
                  style: TextStyle(
                    color: Colors.black,
                  ),
                ),
              ),
            ),
          ),
        ),

これを使うべきとかのは決まっていない。
自分の好みで大丈夫。

9
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
4