skip to Main Content

How to pass flutter riverpod ref.read() function to another widget

Here is my Custom reusable Widget code. import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; class MyFloatingActionButton extends ConsumerWidget { final Function(ProviderRef ref) onPressed; MyFloatingActionButton(this.onPressed); @override Widget build(BuildContext context, WidgetRef ref) { return FloatingActionButton( onPressed: () => onPressed, tooltip: 'Increment', child: Icon(Icons.add), ); }…

VIEW QUESTION

Align items in horizontal ListView.builder – Flutter

I have this code : FutureBuilder( future: _data, builder: (context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return const Center(child: CustomLoadingAnimation()); } else { var data = snapshot.data; return Container( decoration: BoxDecoration( color: primaryFlashColor, borderRadius: BorderRadius.circular(20)), height: 14.h, width: 100.w, child:…

VIEW QUESTION

fromJSON method not being called in Flutter

I am trying to call this method but TempReceiptModel.fromJSON is not being called. Future<TempReceiptModel?> getTempReceipt({ required UserModel? user, }) async { TempReceiptModel? tempReceipt; try { // print(tempReceipt.) SharedPreferences prefs = await SharedPreferences.getInstance(); String? accessToken = prefs.getString('accesstoken'); String? userID = user?.user_id;…

VIEW QUESTION
Back To Top
Search