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

Flutter: Gridview list with both images and videos throwing an error

I have no idea what this error message means: lib/main.dart:29:19: Error: The argument type 'Object' can't be assigned to the parameter type 'Widget?'. 'Object' is from 'dart:core'. 'Widget' is from 'package:flutter/src/widgets/framework.dart' >('../../flutter/packages/flutter/lib/src/widgets/framework.dart'). ? Image.network('https://picsum.photos/200/300') ^ Failed to compile application. body:…

VIEW QUESTION
Back To Top
Search