rameez khan
rameez khan

Reputation: 359

Flutter how can i show icon on half box

I need to know how can I show the icon on the half end of the container. Like this

enter image description here

Just want to add this arrow on blank container

Upvotes: 1

Views: 863

Answers (1)

bluenile
bluenile

Reputation: 6029

You can achieve the effect with a Stack with Overflow visible or Clip behavior set Clip.none and Positioned widget.

I've used overflow: Overflow.visible in code below however it has been deprecated so you can use clipBehavior: Clip.none, instead.

Please see working code below :

import 'package:flutter/material.dart';

final Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Stack(
      overflow: Overflow.visible,
      children: [
        Container(width: 175, height: 50, color: Colors.white),
        Positioned(
          left: 165,
          bottom: 15,
          child: Container(
            height: 20,
            width: 20,
            decoration:
                BoxDecoration(shape: BoxShape.circle, color: Colors.grey),
            child: Icon(Icons.add, color: Colors.black, size: 16),
          ),
        ),
      ],
    );
  }
}

Upvotes: 1

Related Questions