Last active
August 29, 2024 18:05
-
-
Save jhaym3s/80c0ff23833e1432c0a972e35db770c1 to your computer and use it in GitHub Desktop.
random stuffs I searched
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
final bodyHeight =MediaQuery.of(context).size.height - (MediaQuery.of(context).padding.top + kToolbarHeight); | |
LengthLimitingTextInputFormatter(100)// | |
WillPopScope( | |
onWillPop: () async => Navigator.push( | |
context, MaterialPageRoute(builder: (context) => AppLayout())), | |
//adding shadow | |
Container( | |
height: 70, | |
decoration: BoxDecoration( | |
boxShadow: [ | |
BoxShadow( | |
color: Colors.black.withOpacity(0.2), | |
blurRadius: 4.0, | |
spreadRadius: 2.0, | |
offset: Offset(0, -2), | |
), | |
], | |
), // Set the elevation valu | |
) | |
ScaffoldMessenger.of(context).hideCurrentSnackBar(); | |
class CustomProgressBar extends StatelessWidget { | |
final double width; | |
final int value; | |
final int totalValue; | |
const CustomProgressBar({super.key, required this.width, required this.value, required this.totalValue}); | |
@override | |
Widget build(BuildContext context) { | |
double ratio = value / totalValue; | |
return Row(mainAxisAlignment: MainAxisAlignment.center, children: [ | |
Stack( | |
children: [ | |
Container( | |
width: width, | |
height: 4.dy, | |
decoration: BoxDecoration(color: Colors.grey[300], | |
borderRadius: BorderRadius.circular(5), | |
), | |
), | |
Material( | |
borderRadius: BorderRadius.circular(5), | |
child: AnimatedContainer( | |
height: 4.dy, | |
width: width * ratio, | |
duration: Duration(milliseconds: totalValue), | |
decoration: BoxDecoration( | |
color: | |
(ratio < 0.3) | |
? Colors.red | |
: (ratio < 0.6) | |
? Colors.orange | |
: (ratio < 0.9) | |
? Colors.amber | |
: Colors.green, | |
borderRadius: BorderRadius.circular(5))), | |
), | |
], | |
) | |
]); | |
} | |
} | |
Future<dynamic> fetchUrlFromBackend() async { | |
DateTime now = DateTime.now(); | |
String url = kUrl == "pluto.vpay.africa" | |
? "https://storage.googleapis.com/burls/st/data.json" | |
: "https://storage.googleapis.com/burls/pr/data.json"; | |
//"https://storage.googleapis.com/burls/st/data.json?x=timestamp" | |
Dio dio = Dio(); | |
try { | |
Response response = await dio | |
.get( | |
url, | |
options: Options( | |
headers: { | |
'Cache-Control': 'no-cache', | |
}, | |
), | |
) | |
.timeout(const Duration(seconds: 10)); | |
return response.data["url"]; | |
} on DioException catch (error, stackTrace) { | |
printOnlyInDebug(error.response?.statusCode); | |
final apiError = NetworkException.fromDioError(error); | |
return Future.error(apiError, stackTrace); | |
} catch (e) { | |
print("Error accessing default URL: $e"); | |
rethrow; | |
} | |
} | |
//comment section | |
TextFormField( | |
controller: houseAddressController, | |
maxLines: null, // Allow unlimited lines | |
decoration: InputDecoration( | |
hintText: 'Write your comment here...', | |
border: OutlineInputBorder(), | |
fillColor: Colors.grey[200], | |
filled: true, | |
), | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment