How to use inkwell class for responding images in flutter?

This Article is posted by bloggeraatit at 9/20/2019 4:05:34 AM




In this article you will know how to use the inkwell class to navigate by clicking images. 

This is the code of main.dart file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}
class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Inkwell App"),
        ),
        body: Center(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              
              //mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text("Example of inkwell widget"),
                
                InkWell(
                  child: Image.asset("image/colors.jpg"),
                  onTap: () {
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => NewPage()));
                  },
                )
              ],
            ),
        ),
        
        );
  }
}
class NewPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Next Page"),
      ),
      body: Text("."),
    );
  }
}


Tags: inkwell








0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.


© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com