Let’s understand step by step of how to achieve the neumorphic effect in flutter containers, but first if you are new and want a complete setup and want to build your first app instantly, then click here, now let’s jump directly into our topic.
Introduction: Neumorphic Effect In Flutter
As we have learnt so far, is that containers have only an outside shadow, if you want to know how to customize a container then click here. Using neumorphic, we can give it even an inside shadow, we can control the direction, color etc. Let’s understand it now:
Installation
You need to use this package and it is the latest version. Of course, you can search for this package in pub.dev as well. Write this line inside your pubspec.yaml file dependencies section. Then run pub get to import the package in your app.
Neumorphic
SafeArea( child: Scaffold( body: Center( child: Neumorphic( child: Container( height: 100, width: 100, color: Colors.white, ), ), )), )
- Define scaffold.
- Use its body constructor and give it a center child so the content will be shown in the center of the screen.
- As we can see, the container is defined here with some width and height, and having a white background color.
- Let’s wrap this container with neumorphic class and see how the container will look now.
As you can see, the container is dropping a shadow, which we haven’t defined in the container decoration class. This shadow comes from the neumorphic class. Let’s now customize our neumorphic class to see all the other hidden features that this class possess.
Neumorphic Style
style: NeumorphicStyle()
Depth
style: NeumorphicStyle(depth: -4)
Light Source
lightSource: LightSource.bottomRight
Neumorphic Box Shape
boxShape: NeumorphicBoxShape.circle()
Intensity
intensity: .9
Disable Depth
disableDepth: true
Shadow Dark Color Emboss
shadowDarkColorEmboss: Colors.green
Shadow Light Color Emboss
shadowLightColorEmboss: Colors.green
Opposite Shadow Light Source
oppositeShadowLightSource: true
Draw Surface Above Child
drawSurfaceAboveChild: false
Some Designs Of Neumorphic Effect
Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Neumorphic( style: NeumorphicStyle( depth: -4, intensity: .9, ), child: Container( height: 100, width: 100, color: Colors.white, ), ), SizedBox(height: 20), Neumorphic( style: NeumorphicStyle( boxShape: NeumorphicBoxShape.circle(), depth: -4, intensity: .9, ), child: Container( height: 100, width: 100, color: Colors.white, ), ), SizedBox(height: 20), Neumorphic( style: NeumorphicStyle( boxShape: NeumorphicBoxShape.circle(), depth: 4, intensity: .9, ), child: Container( height: 100, width: 100, color: Colors.white, ), ), SizedBox(height: 20), Neumorphic( style: NeumorphicStyle( shadowDarkColorEmboss: Colors.pink.shade400, depth: -4, intensity: .9, ), child: Container( height: 100, width: 100, color: Colors.white, ), ), SizedBox(height: 20), Neumorphic( style: NeumorphicStyle( oppositeShadowLightSource: true, shadowDarkColorEmboss: Colors.green.shade400, depth: -4, intensity: .9, ), child: Container( height: 100, width: 100, color: Colors.white, ), ), ], ), )
Click here to learn how to create a beautiful neumorphic Flutter login UI design.
Conclusion
That’s all for this article, we hope you enjoyed it and have learned how to implement and customize the neumorphic effect in Flutter.
We’d also be glad to see you visit our other tutorials on Flutter app development and Python programming. Thank you for reading this one.