How To Set Button Opacity Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 09-10-2020

Opacity also known as Alpha makes the widget or View transparent according to given value between 0.1 to 1. In flutter we would use Opacity widget to make child widget transparent so when they will show on screen they will become lighter or you can say transparent and their below view will be visible as they became transparent.

How To Set Button Opacity Using Flutter Android App

 Button Opacity 

Complete Code For BUtton Opacity In Flutter
Main.dart

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
        home: Scaffold(
            appBar: AppBar(
              centerTitle: true,
                backgroundColor: Colors.indigo[300],
                title: Text('Set Button Opacity')
            ),
            body: Center(
                child: Opacity(
                  opacity: 0.7,
                  child: RaisedButton(
                    onPressed: () {print('Button Clicked');},
                    child: Text(' Button With Opacity '),
                    color: Colors.indigo[300],
                    textColor: Colors.white,
                    padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                  ),
                )
            )
        )
    );
  }
}

Related Post