flutter_neumorphic 3.2.0 flutter_neumorphic: ^3.2.0 copied to clipboard
A complete, ready to use, Neumorphic ui kit for Flutter. Dark theming compatible & fully customizable.
import 'package:flutter_neumorphic/flutter_neumorphic.dart';
import 'main_home.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return NeumorphicApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
themeMode: ThemeMode.light,
theme: NeumorphicThemeData(
baseColor: Color(0xFFFFFFFF),
lightSource: LightSource.topLeft,
depth: 10,
),
darkTheme: NeumorphicThemeData(
baseColor: Color(0xFF3E3E3E),
lightSource: LightSource.topLeft,
depth: 6,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key}) : super(key: key);
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: NeumorphicFloatingActionButton(
child: Icon(Icons.add, size: 30),
onPressed: () {},
),
backgroundColor: NeumorphicTheme.baseColor(context),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
NeumorphicButton(
onPressed: () {
print("onClick");
},
style: NeumorphicStyle(
shape: NeumorphicShape.flat,
boxShape: NeumorphicBoxShape.circle(),
),
padding: const EdgeInsets.all(12.0),
child: Icon(
Icons.favorite_border,
color: _iconsColor(context),
),
),
NeumorphicButton(
margin: EdgeInsets.only(top: 12),
onPressed: () {
NeumorphicTheme.of(context).themeMode =
NeumorphicTheme.isUsingDark(context)
? ThemeMode.light
: ThemeMode.dark;
},
style: NeumorphicStyle(
shape: NeumorphicShape.flat,
boxShape:
NeumorphicBoxShape.roundRect(BorderRadius.circular(8)),
),
padding: const EdgeInsets.all(12.0),
child: Text(
"Toggle Theme",
style: TextStyle(color: _textColor(context)),
)),
NeumorphicButton(
margin: EdgeInsets.only(top: 12),
onPressed: () {
Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (context) {
return FullSampleHomePage();
}));
},
style: NeumorphicStyle(
shape: NeumorphicShape.flat,
boxShape:
NeumorphicBoxShape.roundRect(BorderRadius.circular(8)),
//border: NeumorphicBorder()
),
padding: const EdgeInsets.all(12.0),
child: Text(
"Go to full sample",
style: TextStyle(color: _textColor(context)),
)),
],
),
),
);
}
Color _iconsColor(BuildContext context) {
final theme = NeumorphicTheme.of(context);
if (theme.isUsingDark) {
return theme.current.accentColor;
} else {
return null;
}
}
Color _textColor(BuildContext context) {
if (NeumorphicTheme.isUsingDark(context)) {
return Colors.white;
} else {
return Colors.black;
}
}
}