Skip to content

Instantly share code, notes, and snippets.

View austinevick's full-sized avatar
🎯
Focusing

Augustine Victor austinevick

🎯
Focusing
View GitHub Profile
@austinevick
austinevick / FlexRow.kt
Created April 11, 2024 06:18 — forked from vganin/FlexRow.kt
Jetpack Compose simple flex-wrap container
@Composable
fun FlowRow(
horizontalGap: Dp = 0.dp,
verticalGap: Dp = 0.dp,
alignment: Alignment.Horizontal = Alignment.Start,
content: @Composable () -> Unit,
) = Layout(content = content) { measurables, constraints ->
val horizontalGapPx = horizontalGap.toPx().roundToInt()
val verticalGapPx = verticalGap.toPx().roundToInt()
@austinevick
austinevick / .dart
Created February 15, 2024 21:45
Flutter searchAnchor demo
class SearchAnchorDemo extends StatefulWidget {
const SearchAnchorDemo({super.key});
@override
State<SearchAnchorDemo> createState() => _SearchAnchorDemoState();
}
class _SearchAnchorDemoState extends State<SearchAnchorDemo> {
List<String> fruits = [
@austinevick
austinevick / .dart
Created January 11, 2024 10:49
Custom range input formatter
import 'package:flutter/services.dart';
class CustomRangeTextInputFormatter extends TextInputFormatter {
final double min;
final double max;
CustomRangeTextInputFormatter({required this.min, required this.max});
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
@austinevick
austinevick / .dart
Last active January 11, 2024 10:47
Programmatically scroll to top
class ScrollToTopWidgetWrapper extends StatefulWidget {
final Widget child;
const ScrollToTopWidgetWrapper({super.key, required this.child});
@override
State<ScrollToTopWidgetWrapper> createState() =>
_ScrollToTopWidgetWrapperState();
}
class _ScrollToTopWidgetWrapperState extends State<ScrollToTopWidgetWrapper> {
@austinevick
austinevick / .dart
Created September 30, 2023 03:36
Flutter paginated list with rest API
import 'dart:convert';
import 'package:http/http.dart'; //Add http package to pubspec.yaml
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; //Add infinite_scroll_pagination package to pubspec.yaml
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
@austinevick
austinevick / .dart
Created July 11, 2023 16:33
Calculate percentage and progress
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
@austinevick
austinevick / .dart
Created April 26, 2023 17:09
WhatsApp floating header in flutter
import 'package:flutter/material.dart';
import 'package:page_transition/page_transition.dart';
class HomeView extends StatefulWidget {
const HomeView({super.key});
@override
State<HomeView> createState() => _HomeViewState();
}
final homeViewFutureProvider = FutureProvider.family(
(ref, WidgetRef _ref) async =>
ref.watch(homeViewModelProvider).getWeather(_ref));
class HomeView extends StatelessWidget {
const HomeView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final homeViewModelProvider = Provider((ref) => HomeViewModel());
class HomeViewModel {
Future<WeatherResponseModel> getWeather(WidgetRef ref) async {
try {
final location = await Location.instance.getLocation();
final model = WeatherModel(
latitude: location.latitude!, longitude: location.longitude!);
print(model.latitude);
@austinevick
austinevick / .dart
Last active September 8, 2022 12:59
class LandingView extends StatelessWidget {
const LandingView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Consumer(builder: (context, ref, child) {
final storage = ref.read(storageProvider);
return Scaffold(
body: SafeArea(
minimum: const EdgeInsets.all(16),