Created
January 12, 2020 22:00
-
-
Save sebaslogen/9e5786857c44361769609be3e453a650 to your computer and use it in GitHub Desktop.
Flutter Neumorphism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
int _counter = 0; | |
final colors = [ | |
Colors.blue, | |
Colors.pinkAccent, | |
Colors.purpleAccent, | |
Colors.redAccent | |
]; | |
void _incrementCounter() { | |
setState(() { | |
_counter++; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.orange, | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Slider( | |
value: _counter.ceilToDouble(), | |
onChanged: (newVal) { | |
setState(() { | |
_counter = newVal.floor(); | |
}); | |
}, | |
activeColor: colors[_counter], | |
min: 0, | |
max: colors.length.ceilToDouble() - 1, | |
divisions: colors.length - 1, | |
label: "$_counter", | |
), | |
Container( | |
width: 200, | |
height: 50, | |
child: Icon(Icons.shopping_cart, size: 40), | |
decoration: BoxDecoration( | |
color: Colors.orange, | |
borderRadius: BorderRadius.all(Radius.circular(20)), | |
boxShadow: [ | |
BoxShadow( | |
color: Colors.orange[800], | |
offset: Offset(4.0,4.0), | |
blurRadius: 15.0, | |
spreadRadius: 1.0 | |
), | |
BoxShadow( | |
color: Colors.orange[300], | |
offset: Offset(-4.0,-4.0), | |
blurRadius: 15.0, | |
spreadRadius: 1.0 | |
), | |
], | |
), | |
), | |
SizedBox(height: 20), | |
Text( | |
'You have pushed the button this many times:', | |
), | |
Text( | |
'$_counter', | |
style: Theme.of(context).textTheme.display1, | |
), | |
], | |
), | |
), | |
floatingActionButton: FloatingActionButton( | |
onPressed: _incrementCounter, | |
tooltip: 'Increment', | |
child: Icon(Icons.add), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment