We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to send http request in Flutter and show the result in my app. But I have an error. this is my code:
import 'dart:convert'; import 'package:requests/home_page_free.dart'; import 'package:requests/home_page_video.dart'; import 'package:dots_indicator/dots_indicator.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class HomePageBody extends StatefulWidget { const HomePageBody({super.key}); @override State<HomePageBody> createState() => _HomePageBodyState(); } class _HomePageBodyState extends State<HomePageBody> { PageController freeController = PageController(viewportFraction: 0.85); PageController proController = PageController(viewportFraction: 0.85); var _freeCurrentPageValue = 0.0; var _proCurrentPageValue = 0.0; var _freeScaleFactor = 0.8; var _proScaleFactor = 0.8; double _height = 320; List<MainFree> _free_items = []; @override void initState() { freeController.addListener(() { setState(() { _freeCurrentPageValue = freeController.page!; }); }); proController.addListener(() { setState(() { _proCurrentPageValue = proController.page!; }); }); freeItem(); super.initState(); } @override void dispose() { freeController.dispose(); proController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Container( child: SingleChildScrollView( child: Column( children: [ Container( height: MediaQuery.of(context).size.height/3.6, child: PageView.builder( controller: freeController, itemCount: _free_items.length, itemBuilder: (context, position){ return _freePageItem(_free_items[index]); }), ), ), ), ); } Widget _freePageItem(int index, MainFree free){ Matrix4 matrix4 = new Matrix4.identity(); if (index == _freeCurrentPageValue.floor()) { var currScale = 1 - (_freeCurrentPageValue - index) * (1 - _freeScaleFactor); var currTrans = _height * (1 - currScale) / 2; matrix4 = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, currTrans, 0); } else if (index == _freeCurrentPageValue.floor() + 1) { var currScale = _freeScaleFactor + (_freeCurrentPageValue - index + 1) * (1 - _freeScaleFactor); var currTrans = _height * (1 - currScale) / 2; matrix4 = Matrix4.diagonal3Values(1, currScale, 1); matrix4 = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, currTrans, 0); } else if (index == _freeCurrentPageValue.floor() - 1) { var currScale = 1 - (_freeCurrentPageValue - index) * (1 - _freeScaleFactor); var currTrans = _height * (1 - currScale) / 2; matrix4 = Matrix4.diagonal3Values(1, currScale, 1); matrix4 = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, currTrans, 0); } else { var currScale = 0.8; matrix4 = Matrix4.diagonal3Values(1, currScale, 1)..setTranslationRaw(0, _height * (1 - _freeScaleFactor) / 2, 1); } return Transform( transform: matrix4, child: Stack( children: [ Container( height: MediaQuery.of(context).size.height/6, margin: EdgeInsets.only(left: 5, right: 5), decoration: BoxDecoration( borderRadius: BorderRadius.circular(30), color: Colors.deepOrange, image: DecorationImage( fit: BoxFit.cover, image: AssetImage( free.app_image ) ) ), ), ], ), ); } void freeItem() async{ var url = Uri.https('www.geors.ir', '/api_free/', {'q': '{http}'}); var response = await get(url); print(utf8.decode(response.bodyBytes)); setState(() { var free_json = json.decode(utf8.decode(response.bodyBytes)); for (var i in free_json){ var free_items = MainFree(i['title'], i['app_image'], i['category'], i['tech_count'], i['views'], i['meta_description']); _free_items.add(free_items); } }); } }
it raise this error:
Error: Too few positional arguments: 2 required, 1 given. return _freePageItem(_free_items[index]); ^
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am trying to send http request in Flutter and show the result in my app. But I have an error.
this is my code:
it raise this error:
The text was updated successfully, but these errors were encountered: