Last active
December 7, 2022 09:33
-
-
Save balinux/f14b9f3d11133ae435635bea5969644f to your computer and use it in GitHub Desktop.
Flutter component
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
appBar: AppBar( | |
elevation: 0, | |
backgroundColor: Colors.transparent, | |
foregroundColor: kPrimaryColor, | |
title: Text("QR Code"), | |
), |
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
import 'package:flutter/material.dart'; | |
import 'package:wastemecha/screens/home/dashboard.dart'; | |
import 'package:wastemecha/screens/welcome/welcome_screen.dart'; | |
import 'package:wastemecha/services/shared_pref.dart'; | |
class LandingScreen extends StatefulWidget { | |
const LandingScreen({Key key}) : super(key: key); | |
@override | |
_LandingScreenState createState() => _LandingScreenState(); | |
} | |
class _LandingScreenState extends State<LandingScreen> { | |
SharedPref sharedPref = SharedPref(); | |
@override | |
Widget build(BuildContext context) { | |
return FutureBuilder<String>( | |
future: sharedPref.readStringToSp('apiToken'), | |
builder: (BuildContext context, AsyncSnapshot<String> snapshot) { | |
if (snapshot.hasData) { | |
if (snapshot.data != null) { | |
return const Dashboard(); | |
} else { | |
return const WelcomeScreen(); | |
} | |
} else { | |
return const Scaffold( | |
body: Center( | |
child: CircularProgressIndicator(), | |
), | |
); | |
} | |
}); | |
} | |
} |
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
boxShadow: [ | |
BoxShadow( | |
color: widget.backgroundColor.withOpacity(0.7), | |
blurRadius: 8.0, | |
offset: Offset(0.0, 5.0), | |
),] |
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
Container( | |
padding: EdgeInsets.all(10), | |
width: size.width * 0.6, | |
height: size.height * 0.3, | |
decoration: BoxDecoration( | |
border: Border.all(color: kPrimaryColor), | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(20)), | |
alignment: Alignment.center, | |
// child: QrImage( | |
// data: 'This is a simple QR code', | |
// version: QrVersions.auto, | |
// size: 320, | |
// gapless: false, | |
// ), | |
), |
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
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(20), | |
boxShadow: [ | |
BoxShadow( | |
offset: Offset(0, 11), | |
blurRadius: 50, | |
color: kPrimaryColor) | |
]), |
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
Container( | |
child: DraggableScrollableSheet( | |
initialChildSize: 0.3, | |
minChildSize: 0.3, | |
maxChildSize: 0.8, | |
builder: (BuildContext context, myscrollController) { | |
return Container( | |
color: Colors.white, | |
child: ListView.builder( | |
controller: myscrollController, | |
itemCount: 25, | |
itemBuilder: (BuildContext context, int index) { | |
return ListTile( | |
title: Text( | |
'Dish $index', | |
style: TextStyle(color: Colors.black54), | |
)); | |
}, | |
), | |
); | |
}, | |
), | |
), |
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
Container( | |
child: SvgPicture.asset( | |
"assets/icons/marker-start.svg", | |
width: 20, | |
height: 20, | |
fit: BoxFit.scaleDown, | |
)) |
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
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
begin: Alignment.topCenter, | |
end: Alignment.bottomCenter, | |
colors: [Color(0xFF72c6f9),Color(0xFFf4fdff)] | |
) | |
), |
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
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(20), | |
boxShadow: [ | |
BoxShadow( | |
offset: Offset(0, 11), | |
blurRadius: 50, | |
color: kPrimaryColor) | |
]), |
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
Column( | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
Align( | |
alignment: Alignment.centerLeft, | |
child: Text("Nama Aktivitas")), | |
TextFormField( | |
controller: _textEditingController, | |
decoration: InputDecoration( | |
hintText: "Please Enter Text", | |
border: OutlineInputBorder()), | |
) | |
], | |
) |
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
TextFormField( | |
controller: _textEditingController, | |
decoration: InputDecoration( | |
hintText: "Please Enter Text", | |
border: OutlineInputBorder()), | |
) |
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
Container( | |
width: 40, | |
height: 40, | |
decoration: BoxDecoration( | |
color: Colors.blue[200], | |
borderRadius: BorderRadius.circular(50), | |
image: const DecorationImage( | |
image: NetworkImage( | |
"https://api.lorem.space/image/face?w=150&h=150"), | |
fit: BoxFit.cover, | |
), | |
), | |
) |
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
Container( | |
alignment: Alignment.center, | |
width: size.width, | |
height: 100, | |
child: Image( | |
fit: BoxFit.cover, | |
image: AssetImage("assets/logo_unud.png"), | |
), | |
) |
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
ClipRRect( | |
borderRadius: BorderRadius.all(Radius.circular(20)), | |
child: Image( | |
width: 84, | |
height: 84, | |
image: AssetImage( | |
'assets/avatar/cute.jpg', | |
), | |
fit: BoxFit.cover, | |
), | |
), |
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
Image( | |
image: AssetImage('assets/images/exploration_image.png'), | |
) |
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
// MarkerLayerOptions( | |
// markers: customMarker(exploreList).toList(), | |
// ), | |
Iterable<Marker> customMarker(List<ExplorationDataLocal> exploreList) { | |
Iterable<Marker> dataMarker = exploreList.map((e) { | |
return Marker( | |
width: 100.0, | |
height: 100.0, | |
point: LatLng(e.latitude, e.longitude), | |
builder: (ctx) => const Icon( | |
Icons.place, | |
color: mBlueColor, | |
), | |
); | |
}); | |
return dataMarker; | |
} |
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
List<ExplorationDataLocal> exploreList = []; | |
void getExplore() { | |
final keys = exploreBox.keys; | |
keys.forEach((element) { | |
print("exp: ${element}"); | |
final dataExplore = exploreBox.get(element); | |
setState(() { | |
exploreList.add(dataExplore); | |
}); | |
}); | |
} |
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
import 'package:flutter/cupertino.dart'; | |
import 'package:intl/intl.dart'; | |
class MoneyFormat { | |
final int money; | |
MoneyFormat({@required this.money}); | |
// var f = NumberFormat('###.0#', 'en_US'); | |
// var f = NumberFormat('#,##0.00', 'id_ID'); //2.000.000.00 | |
var f = NumberFormat('#,##0.##', 'id_ID'); //2.000.000 | |
// toMoneyFormat() => {print(f.format(12.345))}; | |
// String toRupiah() => f.format(money).toString(); | |
String toRupiah() => 'Rp. ${f.format(money)}'; | |
} | |
// how to use it | |
// MoneyFormat(money: 2000000).toRupiah(), | |
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
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { | |
context | |
.read<ExplorationProvider>() | |
.setidStep(data[active].key); | |
}); |
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
Widget buildListensor(List<SensorDataLocal> sensorDataLocal) { | |
return ListView.builder( | |
itemCount: sensorDataLocal.length, | |
itemBuilder: (BuildContext context, int index) { | |
int reverseIndex = sensorDataLocal.length - 1 - index; | |
final data = sensorDataLocal[reverseIndex]; | |
return ListTile( | |
leading: Icon(Icons.data_saver_off), | |
title: Text(data.localData), | |
// subtitle: Text(data.createdAt.toString()), | |
subtitle: | |
Text(DateFormat('yyyy-MM-dd – kk:mm').format(data.createdAt)), | |
); | |
}); | |
} |
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
Timer(const Duration(seconds: 2), _getPlace); |
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
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:intl/intl.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Time Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(title: 'Flutter Time Demo'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
String _timeString; | |
@override | |
void initState() { | |
_timeString = _formatDateTime(DateTime.now()); | |
Timer.periodic(Duration(seconds: 1), (Timer t) => _getTime()); | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Text(_timeString), | |
), | |
); | |
} | |
void _getTime() { | |
final DateTime now = DateTime.now(); | |
final String formattedDateTime = _formatDateTime(now); | |
setState(() { | |
_timeString = formattedDateTime; | |
}); | |
} | |
String _formatDateTime(DateTime dateTime) { | |
return DateFormat('MM/dd/yyyy hh:mm:ss').format(dateTime); | |
} | |
} |
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
import 'package:flutter/material.dart'; | |
import 'package:udayanamobile/utils/constants.dart'; | |
Future<void> showModal(BuildContext context, [Size size]) { | |
return showModalBottomSheet<void>( | |
shape: RoundedRectangleBorder( | |
borderRadius: BorderRadius.vertical(top: Radius.circular(25.0)), | |
), | |
backgroundColor: Colors.blue, | |
context: context, | |
builder: (BuildContext context) { | |
return Container( | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.only( | |
topLeft: Radius.circular(20), topRight: Radius.circular(20)), | |
color: unudBackgroundGreyColor, | |
), | |
padding: EdgeInsets.only(left: defaultPadding, right: defaultPadding), | |
height: size.height * 0.3, | |
child: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
mainAxisSize: MainAxisSize.min, | |
children: <Widget>[ | |
Row( | |
children: [ | |
Text("Wifi Name"), | |
Text("TP"), | |
], | |
), | |
const Text('Modal BottomSheet'), | |
ElevatedButton( | |
child: const Text('Close BottomSheet'), | |
onPressed: () => Navigator.pop(context), | |
) | |
], | |
), | |
), | |
); | |
}, | |
); | |
} |
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
Future<void> showInformastionForm(BuildContext context) async { | |
return await showModalBottomSheet( | |
context: context, | |
builder: (builder) { | |
return Container( | |
height: 350.0, | |
color: Colors.transparent, //could change this to Color(0xFF737373), | |
//so you don't have to change MaterialApp canvasColor | |
child: Container( | |
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.only( | |
topLeft: const Radius.circular(10.0), | |
topRight: const Radius.circular(10.0))), | |
child: Center( | |
child: Text("This is a modal sheet"), | |
)), | |
); | |
}); | |
} | |
} |
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
SvgPicture.asset( | |
'assets/icon/click.svg', | |
fit: BoxFit.contain, | |
height: 60, | |
width: 60, | |
), |
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
TextFormField( | |
validator: (productName) { | |
if (productName == null || productName.isEmpty) { | |
return 'Mohon masukkan data barang'; | |
} | |
return null; | |
}, | |
controller: productNameController, | |
onTap: () {}, | |
// controller: _textEditingController, | |
decoration: InputDecoration( | |
filled: true, | |
fillColor: textDisableColor.withOpacity(0.1), | |
enabledBorder: UnderlineInputBorder( | |
borderSide: BorderSide(color: Colors.white), | |
borderRadius: BorderRadius.circular(5.0), | |
), | |
focusedBorder: OutlineInputBorder( | |
borderSide: BorderSide(color: Colors.white, width: 2.0), | |
borderRadius: BorderRadius.circular(5.0), | |
), | |
hintText: "Ketik nama barang", | |
hintStyle: TextStyle(color: textDisableColor.withOpacity(0.6)), | |
prefixIcon: Padding( | |
padding: EdgeInsets.all(5), | |
child: Icon( | |
Icons.create, | |
color: textDisableColor, | |
), | |
), | |
), | |
); |
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
TextFormField( | |
onTap: () {}, | |
// controller: _textEditingController, | |
decoration: InputDecoration( | |
filled: true, | |
fillColor: textDisableColor.withOpacity(0.1), | |
enabledBorder: UnderlineInputBorder( | |
borderSide: BorderSide(color: Colors.white), | |
borderRadius: BorderRadius.circular(25.7), | |
), | |
focusedBorder: OutlineInputBorder( | |
borderSide: BorderSide(color: Colors.white, width: 2.0), | |
borderRadius: BorderRadius.circular(25.0), | |
), | |
hintText: "Cari disini", | |
hintStyle: TextStyle(color: textDisableColor), | |
prefixIcon: Padding( | |
padding: EdgeInsets.all(5), | |
child: Icon( | |
Icons.search, | |
color: textDisableColor, | |
), | |
), | |
), | |
), |
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
TextFormField( | |
// controller: _textEditingController, | |
decoration: const InputDecoration( | |
hintText: "Cari lokasi penjualan anda", | |
hintStyle: TextStyle(color: kTextColor), | |
focusedBorder: OutlineInputBorder( | |
borderSide: BorderSide(color: kTextColor)), | |
border: OutlineInputBorder( | |
borderSide: BorderSide(color: kTextColor), | |
borderRadius: | |
BorderRadius.all(Radius.circular(40)))), | |
), |
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
TextFormField( | |
// controller: _textEditingController, | |
decoration: const InputDecoration( | |
hintText: "Cari lokasi penjualan anda", | |
hintStyle: TextStyle(color: kTextColor), | |
prefixIcon: Padding( | |
padding: EdgeInsets.all(5), | |
child: Icon( | |
Icons.place, | |
color: kPrimaryColor, | |
), | |
), | |
suffixIcon: Padding( | |
padding: EdgeInsets.all(5), | |
child: Icon( | |
Icons.cancel, | |
color: mSubtitleColor, | |
), | |
), | |
focusedBorder: OutlineInputBorder( | |
borderSide: BorderSide(color: kTextColor)), | |
border: OutlineInputBorder( | |
borderSide: BorderSide(color: kTextColor), | |
borderRadius: | |
BorderRadius.all(Radius.circular(40)))), | |
), |
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
// datetime_picker_formfield: ^2.0.0 | |
DateTimeField( | |
format: formatTime, | |
onShowPicker: (context, currentValue) async { | |
final time = await showTimePicker( | |
context: context, | |
initialTime: TimeOfDay.fromDateTime( | |
currentValue ?? DateTime.now()), | |
); | |
return DateTimeField.convert(time); | |
}, | |
), |
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
List Method .map() in Dart and Flutter : https://www.youtube.com/watch?v=6xWVWDvmqeU; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment