| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- import '/flutter_flow/flutter_flow_theme.dart';
- import '/flutter_flow/flutter_flow_util.dart';
- import '/flutter_flow/flutter_flow_widgets.dart';
- import '/flutter_flow/upload_data.dart';
- import 'dart:ui';
- import '/custom_code/actions/index.dart' as actions;
- import 'package:flutter/material.dart';
- import 'package:flutter_spinkit/flutter_spinkit.dart';
- import 'package:google_fonts/google_fonts.dart';
- import 'package:provider/provider.dart';
- import 'kanweg_test_upload_model.dart';
- export 'kanweg_test_upload_model.dart';
- class KanwegTestUploadWidget extends StatefulWidget {
- const KanwegTestUploadWidget({super.key});
- static String routeName = 'kanwegTestUpload';
- static String routePath = '/kanwegTestUpload';
- @override
- State<KanwegTestUploadWidget> createState() => _KanwegTestUploadWidgetState();
- }
- class _KanwegTestUploadWidgetState extends State<KanwegTestUploadWidget>
- with RouteAware {
- late KanwegTestUploadModel _model;
- final scaffoldKey = GlobalKey<ScaffoldState>();
- @override
- void initState() {
- super.initState();
- _model = createModel(context, () => KanwegTestUploadModel());
- }
- @override
- void dispose() {
- routeObserver.unsubscribe(this);
- _model.dispose();
- super.dispose();
- }
- @override
- void didUpdateWidget(KanwegTestUploadWidget oldWidget) {
- super.didUpdateWidget(oldWidget);
- _model.widget = widget;
- }
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- final route = DebugModalRoute.of(context);
- if (route != null) {
- routeObserver.subscribe(this, route);
- }
- debugLogGlobalProperty(context);
- }
- @override
- void didPopNext() {
- if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
- setState(() => _model.isRouteVisible = true);
- debugLogWidgetClass(_model);
- }
- }
- @override
- void didPush() {
- if (mounted && DebugFlutterFlowModelContext.maybeOf(context) == null) {
- setState(() => _model.isRouteVisible = true);
- debugLogWidgetClass(_model);
- }
- }
- @override
- void didPop() {
- _model.isRouteVisible = false;
- }
- @override
- void didPushNext() {
- _model.isRouteVisible = false;
- }
- @override
- Widget build(BuildContext context) {
- DebugFlutterFlowModelContext.maybeOf(context)
- ?.parentModelCallback
- ?.call(_model);
- context.watch<FFAppState>();
- return GestureDetector(
- onTap: () {
- FocusScope.of(context).unfocus();
- FocusManager.instance.primaryFocus?.unfocus();
- },
- child: Scaffold(
- key: scaffoldKey,
- backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
- body: SafeArea(
- top: true,
- child: Column(
- mainAxisSize: MainAxisSize.max,
- children: [
- FFButtonWidget(
- onPressed: () async {
- final selectedMedia = await selectMediaWithSourceBottomSheet(
- context: context,
- allowPhoto: true,
- );
- if (selectedMedia != null &&
- selectedMedia.every(
- (m) => validateFileFormat(m.storagePath, context))) {
- safeSetState(() =>
- _model.isDataUploading_uploadDataTestbutton = true);
- var selectedUploadedFiles = <FFUploadedFile>[];
- try {
- selectedUploadedFiles = selectedMedia
- .map((m) => FFUploadedFile(
- name: m.storagePath.split('/').last,
- bytes: m.bytes,
- height: m.dimensions?.height,
- width: m.dimensions?.width,
- blurHash: m.blurHash,
- originalFilename: m.originalFilename,
- ))
- .toList();
- } finally {
- _model.isDataUploading_uploadDataTestbutton = false;
- }
- if (selectedUploadedFiles.length == selectedMedia.length) {
- safeSetState(() {
- _model.uploadedLocalFile_uploadDataTestbutton =
- selectedUploadedFiles.first;
- });
- } else {
- safeSetState(() {});
- return;
- }
- }
- _model.uploadResult = await actions.bestandUpload(
- _model.uploadedLocalFile_uploadDataTestbutton,
- 'https://uitgaanskrant.com/en/flutterdrup/bestand_upload/upload.json',
- FFAppState().userSessionname,
- FFAppState().userSessionid,
- FFAppState().userToken,
- );
- ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(
- content: Text(
- getJsonField(
- _model.uploadResult,
- r'''$''',
- ).toString(),
- style: TextStyle(
- color: FlutterFlowTheme.of(context).primaryText,
- ),
- ),
- duration: Duration(milliseconds: 8000),
- backgroundColor: FlutterFlowTheme.of(context).secondary,
- ),
- );
- safeSetState(() {});
- },
- text: FFLocalizations.of(context).getText(
- 'mw7suah8' /* Test Upload */,
- ),
- options: FFButtonOptions(
- height: 40.0,
- padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0),
- iconPadding:
- EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
- color: FlutterFlowTheme.of(context).primary,
- textStyle: FlutterFlowTheme.of(context).titleSmall.override(
- font: GoogleFonts.roboto(
- fontWeight: FlutterFlowTheme.of(context)
- .titleSmall
- .fontWeight,
- fontStyle:
- FlutterFlowTheme.of(context).titleSmall.fontStyle,
- ),
- color: Colors.white,
- letterSpacing: 0.0,
- fontWeight:
- FlutterFlowTheme.of(context).titleSmall.fontWeight,
- fontStyle:
- FlutterFlowTheme.of(context).titleSmall.fontStyle,
- ),
- elevation: 0.0,
- borderRadius: BorderRadius.circular(8.0),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
- }
|