Hello i’ve adopted a youtube tutorial and made a sqlite app that works on android emulator completely however when i attempt to run on ios emulator i get the next error message:
Did not construct iOS app
Error (Xcode): File not discovered: /Functions/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphonesimulator.a
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Couldn’t construct the appliance for the simulator.
Error launching utility on Iphone 13.
My database helper file:
import 'bundle:flutter/materials.dart';
import 'bundle:sqflite/sqflite.dart' as sql;
class SQLHelper {
//methodology to create desk
static Future<void> createTables(sql.Database database) async {
await database.execute("""CREATE TABLE units(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
exercise_name TEXT,
total_weight TEXT,
total_reps TEXT,
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)
""");
}
//methodology to open the database known as db
static Future<sql.Database> db() async {
return sql.openDatabase('dbsets.db', model: 1,
onCreate: (sql.Database database, int model) async {
print('Creating Desk');
await createTables(database); //calling that create desk methodology above
});
}
//methodology to create an merchandise to insert into the database desk
static Future<int> createItem(
String exercise_name,
String? total_weight,
String? total_reps,
) async {
ultimate db = await SQLHelper.db(); //opening the database
ultimate knowledge = {
'exercise_name': exercise_name,
'total_weight': total_weight,
'total_reps': total_reps,
'date': DateTime.now().toString()
}; //making map to insert
ultimate id = await db.insert(
//inserting that knowledge map
'units',
knowledge, //objects is desk identify and knowledge is the map we made
conflictAlgorithm: sql
.ConflictAlgorithm.exchange); //greatest observe to stop duplicates
return id;
}
//this can return an inventory of maps
//will get known as when app is launched and can get all our shit from the database
static Future<Listing<Map<String, dynamic>>> getItems() async {
//getItems will probably be a Listing
ultimate db = await SQLHelper.db(); //get connection
return db.question('units', orderBy: "id");
}
//methodology for getting 1 merchandise from the database based mostly on id
static Future<Listing<Map<String, dynamic>>> getItem(int id) async {
ultimate db = await SQLHelper.db();
return db.question('units',
the place: "id = ?", whereArgs: https://stackoverflow.com/q/76079525, restrict: 1); //restrict 1 means get just one
}
//UPDATING AN ENTRY
static Future<int> updateItem(
int id,
String exercise_name,
String? total_weight,
String? total_reps,
) async {
ultimate db = await SQLHelper.db();
ultimate knowledge = {
'exercise_name': exercise_name,
'total_weight': total_weight,
'total_reps': total_reps,
'date': DateTime.now().toString()
}; //
ultimate end result =
await db.replace('units', knowledge, the place: "id= ?", whereArgs: https://stackoverflow.com/q/76079525);
return end result;
}
//Deleting an Entry
static Future<void> deleteItem(int id) async {
ultimate db = await SQLHelper.db();
strive {
await db.delete("units", the place: "id = ?", whereArgs: https://stackoverflow.com/q/76079525);
} catch (err) {
debugPrint("One thing went unsuitable when deleting an merchandise: $err");
}
}
}
and my predominant.dart
import 'bundle:flutter/cupertino.dart';
import 'bundle:flutter/materials.dart';
import 'bundle:labud_fit_concept/sql_helper.dart';
void predominant() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({tremendous.key});
// This widget is the foundation of your utility.
@override
Widget construct(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colours.blue,
),
dwelling: const MyHomePage(title: 'Flutter Demo Dwelling Web page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({tremendous.key, required this.title});
ultimate String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
//creating an inventory of maps
Listing<Map<String, dynamic>> _sets = [];
bool _isLoading = true;
//this methodology will retailer every thing from out database in knowledge
void _refreshSets() async {
ultimate knowledge = await SQLHelper.getItems(); //getItems returns an inventory of maps
setState(() {
_sets = knowledge;
_isLoading = false; //completed loading
});
}
//now to name this refreshJournals methodology
@override
void initState() {
// TODO: implement initState
_refreshSets();
print("variety of units: ${_sets.size}");
}
ultimate TextEditingController _exercisenameController = TextEditingController();
ultimate TextEditingController _totalweightController = TextEditingController();
ultimate TextEditingController _totalrepsController = TextEditingController();
void _showForm(int? id) async {
if (id != null) {
// id == null -> create new merchandise
// id != null -> replace an current merchandise
ultimate existingSet = _sets.firstWhere((factor) => factor['id'] == id);
_exercisenameController.textual content = existingSet['exercise_name'];
_totalweightController.textual content = existingSet['total_weight'];
_totalrepsController.textual content = existingSet['total_reps'];
}
showModalBottomSheet(
context: context,
elevation: 5,
isScrollControlled: true,
builder: (_) => Container(
padding: EdgeInsets.solely(
prime: 15,
left: 15,
proper: 15,
// this can forestall the tender keyboard from protecting the textual content fields
backside: MediaQuery.of(context).viewInsets.backside + 120,
),
youngster: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.finish,
youngsters: [
TextField(
controller: _exercisenameController,
decoration:
const InputDecoration(hintText: 'Exercise Name'),
),
const SizedBox(
height: 10,
),
TextField(
controller: _totalweightController,
decoration: const InputDecoration(hintText: 'Weight'),
),
const SizedBox(
height: 10,
),
TextField(
controller: _totalrepsController,
decoration: const InputDecoration(hintText: 'Reps'),
),
const SizedBox(
height: 20,
),
ElevatedButton(
//button to confirm entry
onPressed: () async {
// Save new journal
if (id == null) {
//if the item doesnt exist
await _addItem();
}
if (id != null) {
//if it exists update it instead
await _updateItem(id);
}
// Clear the text fields
_exercisenameController.text="";
_totalweightController.text="";
_totalrepsController.text="";
//closing the popup
Navigator.of(context).pop();
},
//the text of the button change depending on if its new or updating an existing
child: Text(id == null ? 'Create New' : 'Update'),
)
],
),
));
}
// Insert a brand new journal to the database
Future<void> _addItem() async {
await SQLHelper.createItem(_exercisenameController.textual content,
_totalweightController.textual content, _totalrepsController.textual content);
_refreshSets(); //getting all of our database calls once more
print("variety of journals: ${_sets.size}");
}
// Replace an current journal
Future<void> _updateItem(int id) async {
await SQLHelper.updateItem(id, _exercisenameController.textual content,
_totalweightController.textual content, _totalrepsController.textual content);
_refreshSets();
}
// Delete an merchandise
void _deleteItem(int id) async {
await SQLHelper.deleteItem(id);
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content material: Textual content('Efficiently deleted a Set!'),
));
_refreshSets();
}
@override
Widget construct(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Textual content(widget.title),
),
physique: ListView.builder(
//so its a listview so we use our _journals checklist to construct it
itemCount: _sets.size,
itemBuilder: (context, index) => Card(
coloration: Shade.fromARGB(255, 129, 142, 255),
margin: const EdgeInsets.all(15),
youngster: CupertinoListTile(
title: Textual content(_sets[index]['exercise_name']),
subtitle: Textual content(_sets[index]['total_weight']),
trailing: SizedBox(
width: 100,
youngster: Row(
youngsters: [
IconButton(
onPressed: () => _showForm(_sets[index]['id']),
icon: Icon(Icons.edit),
),
IconButton(
onPressed: () => _deleteItem(_sets[index]['id']),
icon: Icon(Icons.delete),
),
],
),
),
),
)),
floatingActionButton: FloatingActionButton(
youngster: const Icon(Icons.add),
onPressed: () => _showForm(null),
),
);
}
}