Skip to content

Instantly share code, notes, and snippets.

@korchix
Created January 29, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korchix/388ef61c294740f2fa4ac0ee5f5c1f5f to your computer and use it in GitHub Desktop.
Save korchix/388ef61c294740f2fa4ac0ee5f5c1f5f to your computer and use it in GitHub Desktop.
light / dark toggel + neumorphism
// copied from https://github.com/createdbymitch/tutorialsoftui/blob/master/lib/main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool darkMode = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: darkMode ? Colors.grey[850] : Colors.grey[300],
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 200,
height: 200,
child: Icon(Icons.android, size: 80, color: darkMode ? Colors.white : Colors.black),
decoration: BoxDecoration(
color: darkMode ? Colors.grey[850] : Colors.grey[300],
borderRadius: BorderRadius.all(Radius.circular(50)),
boxShadow: [
BoxShadow(
color: darkMode ? Colors.black54 : Colors.grey[500],
offset: Offset(4.0, 4.0),
blurRadius: 15.0,
spreadRadius: 1.0),
BoxShadow(
color: darkMode ? Colors.grey[800] : Colors.white,
offset: Offset(-4.0, -4.0),
blurRadius: 15.0,
spreadRadius: 1.0),
]),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 50, right: 3),
child: FlatButton(
color: Colors.white,
child: Text('Light', style: TextStyle(color: Colors.black),),
onPressed: () {
setState(() {
darkMode = false;
}); },
),
),
Padding(
padding: EdgeInsets.only(top: 50, left: 3),
child: FlatButton(
color: Colors.black,
child: Text('Dark', style: TextStyle(color: Colors.white),),
onPressed: () {
setState(() {
darkMode = true;
});
},
),
),
],
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment