Customize the container shape - flutter

How to achieve following shape in flutter without using plugins? I want to implement the customized container using clippath. I'm trying to use lineTo() method. I did not get exactly this one.

try this package, clippy_flutter, using Point:
Point(
triangleHeight: 30.0,
edge: Edge.LEFT,
child: Container(
color: Colors.pink,
width: 100.0,
height: 100.0,
child: Center(child: Text('Point')),
),
),
and then stack them and overlap a little at the egde.

Related

How Flutter adds a top-level view (similar to iOS adding to a window)

The widget is always displayed on the screen, just like in iOS, adding controls to the window. How to achieve it, thank you! Grateful!
Add this to your MaterialApp to remove it
MaterialApp(
debugShowCheckedModeBanner: false,
)
You can use Banner widget that actually displays debug banner.
docs link : https://api.flutter.dev/flutter/widgets/Banner-class.html
Banner(
location: BannerLocation.topEnd,
message: "",
child: Icon(Icons.help), //you can pass anything here as widget
color: Colors.transparent,
),
Have a look at this. Flutter provides a default Banner widget.It is somewhat similar to the debug banner what we are used to of seeing on the top-right corner on a flutter app in debug mode.
https://api.flutter.dev/flutter/widgets/Banner-class.html
You can use Stack Widget to overlay Widgets over one another. For example:
Stack(
children: <Widget>[
Container(
width: 100,
height: 100,
color: Colors.red,
),
Container(
width: 90,
height: 90,
color: Colors.green,
),
Container(
width: 80,
height: 80,
color: Colors.blue,
),
],
)
The Banner widget realises this by creating a CustomPainter, take a look at the Implementation. But I think a Stack would be the better choice here if you are using Widgets.

Is it possible to Repeat Icons in flutter like ImageRepeat

I am wondering if it is possible to repeat an actual icon widget like the image I have attached.
Currently getting this result using ImageRepeat but would like to be able to use and actual icon so it can be modular and the icon can change.
( the repeating image can currently change but I don't want to have to create 100 images of icons. )
Current Solution:
SizedBox.expand(
child: Image.asset(
_backGroundImage,
repeat: ImageRepeat.repeat,
)),
try Wrap:
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.orange,
child: Wrap(
children: List<Widget>.generate(2000, (int index) {
return Icon(Icons.add);
}),
),
),

Draw a stripe with Box decoration

I want to decorate a container with a single stripe down the middle with white on each side like in the picture, I'm guessing I need to use Linear Gradient but I am struggling to get it right.Any Ideas?
Single Stripe Pic
Easy, You need to create a container and make a child of it as Stack and further create a container with aligned it to center. Give it some width and decorate it with linear gradient that's all
Here's some code I've written to help you. Feel free to customize on top of it and use within your app. Cheers!
Container(
width: 200,
height: 150,
color: Colors.white,
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Container(
width: 50,
color: Colors.red,
),
)
],
),
);

Why can't I write sematicLabel in Flutter

I am quite a beginner at Flutter so I have a question why can't I fit sematicLabel in here?
Container doesn't have a property called semanticLabel. You can use instead Semantics.
Semantics(
label: 'Venus',
child: Container(
child: Image.asset('assets/images/venus.png'),
height: 200,
width: 200,
),
)

How to avoid Image Area showing Blue before Loading App

I am loading a rectangle logo saved as a .jpg into a CircleAvatar in my App.
When I am restarting my App, the area where the logo is loading appears blue for a few seconds. Then the real logo appears.
This Widget is found within a Stack.
This is how I transform my 1080x1073 image into a round logo within Flutter.
Container(
width: size.width * 0.5,
height: size.width * 0.5,
child: CircleAvatar(
backgroundImage: AssetImage('assets/images/logo.jpg'),
),
),
Does this happen because my image is too big? How should I handle this problem?
P.S. I am testing this on Visual Studio Code.
By default the background color is set to blue, you can modify the property and it will show whatever color you assign to it.
Container(
width: size.width * 0.5,
height: size.width * 0.5,
child: CircleAvatar(
backgroundColor: Colors.red, //here
backgroundImage: AssetImage('assets/images/logo.jpg'),
),
),
This has more to do with the delay it takes to load an image. You can change the background color like Yudhishthir suggested if the color is the actual problem or you can pre-fetch the image so that the image loads before anything is built.
This answer describes how to do the image pre-fetch using the precacheImage function.
This Cookbook solution is designed for this situation. Just replace the CircularProgressIndicator with whatever you want to show before the image is loaded.
https://flutter.dev/docs/cookbook/images/fading-in-images
Had similar blue background then changed to InkWell:
child: InkWell(
onTap: () async {
myFunc();
},
child: Container(
width: 50,
height: 50,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(shape: BoxShape.circle),
child: Image.asset(
'assets/images/mybutton.png',
fit: BoxFit.cover,
),
),
),